index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="information">
  3. <!-- header -->
  4. <cu-custom bgColor="bg-gradual-blue" isBack><view slot="content">设备信息</view></cu-custom>
  5. <!-- section -->
  6. <view v-for="(item, index) in value.value" :key="index" class="bg-white padding-top-sm radius margin-lr margin-top">
  7. <view class="padding-sm">
  8. <view class="padding-bottom-sm text-black text-bold ">{{ item.name }}:{{ item.tel }}</view>
  9. <view class="padding-bottom-sm text-black text-bold ">车型:{{ item.model }}</view>
  10. <view class="text-black text-bold ">车牌号:{{ item.number }}</view>
  11. </view>
  12. <button style="border-radius: 0 0 6rpx 6rpx;" @click="onClick(item)" class="cu-btn block bg-green padding-tb-sm">换绑</button>
  13. </view>
  14. <van-empty v-if="value.value.length == 0 && value.no_more" description="暂无设备" />
  15. <view v-else :class="!value.no_more && value.pageCount <= value.totalPage ? 'cu-load bg-grey loading margin-top' : 'cu-load bg-grey over margin-top'"></view>
  16. <!-- footer -->
  17. <view class="footer">
  18. <view class="footer-concent cu-bar tabbar bg-white">
  19. <view class="action text-green"></view>
  20. <view class="action text-gray"></view>
  21. <view class="action text-gray add-action">
  22. <button @click="addClick" class="cu-btn cuIcon-add bg-green shadow"></button>
  23. 添加
  24. </view>
  25. <view class="action text-gray"></view>
  26. <view class="action text-gray"></view>
  27. </view>
  28. </view>
  29. <!-- 功能工具 -->
  30. <van-dialog id="van-dialog" />
  31. </view>
  32. </template>
  33. <script>
  34. import Dialog from '@/wxcomponents/vant/dist/dialog/dialog';
  35. export default {
  36. data() {
  37. return {
  38. value: {
  39. no_more: false, //没有更多
  40. pageCount: 1,
  41. totalPage: 1,
  42. value: []
  43. }
  44. };
  45. },
  46. onShow() {
  47. this.value = {
  48. no_more: false, //没有更多
  49. pageCount: 1,
  50. totalPage: 1,
  51. value: []
  52. };
  53. this.request();
  54. },
  55. // 页面上拉触底事件
  56. onReachBottom: function() {
  57. this.request();
  58. },
  59. methods: {
  60. // 请求
  61. async request() {
  62. var { pageCount, totalPage, no_more, value } = JSON.parse(JSON.stringify(this.value));
  63. if (pageCount > totalPage) return false;
  64. var res = await this.$global.request({
  65. url: '/customer/vehicle/',
  66. method: 'get',
  67. header: {
  68. 'Content-Type': 'application/x-www-form-urlencoded',
  69. Authorization: uni.getStorageSync('token')
  70. },
  71. data: { page: pageCount, limit: 20 }
  72. });
  73. pageCount++;
  74. totalPage = res.totalPage;
  75. if (pageCount > totalPage) no_more = true;
  76. value = value.concat(res.data);
  77. this.value = { pageCount, totalPage, no_more, value };
  78. },
  79. // 换绑
  80. onClick(item) {
  81. Dialog.confirm({ title: '提示', message: '确定换绑该设备?' })
  82. .then(() => this.vehicleChange(item))
  83. .catch(() => false);
  84. },
  85. // 换绑请求
  86. async vehicleChange(item) {
  87. uni.navigateTo({
  88. url: `/pages/binding/index?value=${JSON.stringify(item)}`
  89. });
  90. },
  91. // 添加设备
  92. addClick() {
  93. uni.navigateTo({
  94. url: '/pages/binding/index'
  95. });
  96. }
  97. }
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. .information {
  102. .footer {
  103. height: calc(150rpx + env(safe-area-inset-bottom));
  104. .footer-concent {
  105. position: fixed;
  106. z-index: 9999;
  107. bottom: 0;
  108. left: 0;
  109. width: 100%;
  110. }
  111. }
  112. }
  113. </style>