searchparking.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <u-navbar title="我的停车" title-color="#fff" :custom-back="customBack" :border-bottom="false"
  4. back-icon-color="#CCE8FF" :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }">
  5. </u-navbar>
  6. <view class="tab-fixed">
  7. <u-tabs-swiper activeColor="#008CFF" ref="tabs" :list="tabList" :current="tabCurrent" @change="tabChange"
  8. :is-scroll="false" swiperWidth="100%"></u-tabs-swiper>
  9. </view>
  10. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  11. height="calc(100vh - 84px)" top="50rpx">
  12. <view class="parkinglist">
  13. <view class="parkinglist-item" v-for="(item,index) in parkinglist" :key="item.id"
  14. @click="navigation(item.latitude, item.longitude)">
  15. <view class="up u-flex u-row-between">
  16. <view class="vehicle-no">{{item.vehicleNo}}</view>
  17. <view class="space-name">{{item.spaceName}}</view>
  18. </view>
  19. <view class="down u-flex u-row-left">
  20. <u-icon name="map-fill" color="#008CFF" size="28"></u-icon>
  21. <view class="road-name">{{item.roadName}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </mescroll-body>
  26. <u-toast ref="uToast" />
  27. </view>
  28. </template>
  29. <script>
  30. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  31. export default {
  32. mixins: [MescrollMixin], // 使用mixin
  33. data() {
  34. return {
  35. parkinglist: [],
  36. tabCurrent: 0,
  37. tabCurrentItem: {},
  38. tabList: [
  39. {
  40. name: '路段',
  41. value: 'road'
  42. },
  43. {
  44. name: '停车场',
  45. value: 'park'
  46. }
  47. ]
  48. }
  49. },
  50. onLoad() {
  51. this.tabCurrentItem = this.tabList[this.tabCurrent]
  52. },
  53. onShow() {
  54. },
  55. methods: {
  56. customBack() {
  57. this.$u.route({
  58. type: 'switchTab',
  59. url: 'pages/index/index'
  60. });
  61. },
  62. tabChange(cur) {
  63. this.tabCurrent = cur
  64. this.tabCurrentItem = this.tabList[cur]
  65. this.mescroll.resetUpScroll();
  66. },
  67. /**
  68. * 导航
  69. * */
  70. navigation(lat, lon) {
  71. uni.openLocation({
  72. latitude: parseFloat(lat),
  73. longitude: parseFloat(lon),
  74. scale: 18
  75. })
  76. },
  77. downCallback() {
  78. this.mescroll.resetUpScroll();
  79. },
  80. upCallback(page) {
  81. if (this.tabCurrentItem.value === 'park') {
  82. this.getParkingLotParkingList(page)
  83. } else {
  84. this.getRoadParkingList(page)
  85. }
  86. },
  87. /**
  88. * 获取路段我的停车
  89. */
  90. getRoadParkingList({ num, size }) {
  91. this.$u.api.getOrderList({
  92. orderStatus: 1,
  93. pageNum: num,
  94. pageSize: size
  95. })
  96. .then(res => {
  97. //设置列表数据
  98. let curPageData = res.data.pageInfo.rows;
  99. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  100. let curPageLen = curPageData.length;
  101. let totalPage = res.data.pageInfo.pages;
  102. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  103. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  104. // 请求成功,隐藏加载状态
  105. //后台接口有返回列表的总页数 totalPage
  106. this.mescroll.endByPage(curPageLen, totalPage);
  107. if (this.parkinglist.length <= 0) {
  108. this.listEmpty = true
  109. };
  110. }).catch(err => {
  111. this.$refs.uToast.show({
  112. title: err.msg,
  113. type: 'error',
  114. });
  115. });
  116. },
  117. /**
  118. * 获取停车场我的停车
  119. */
  120. getParkingLotParkingList({ num, size }) {
  121. this.$u.api.getRoomParkingApi({
  122. orderStatus: 1,
  123. pageNum: num,
  124. pageSize: size
  125. })
  126. .then(res => {
  127. //设置列表数据
  128. let curPageData = res.data.pageInfo.rows;
  129. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  130. let curPageLen = curPageData.length;
  131. let totalPage = res.data.pageInfo.pages;
  132. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  133. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  134. // 请求成功,隐藏加载状态
  135. //后台接口有返回列表的总页数 totalPage
  136. this.mescroll.endByPage(curPageLen, totalPage);
  137. if (this.parkinglist.length <= 0) {
  138. this.listEmpty = true
  139. };
  140. }).catch(err => {
  141. this.$refs.uToast.show({
  142. title: err.msg,
  143. type: 'error',
  144. });
  145. });
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. @import './searchparking.scss'
  152. </style>