searchparking.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view>
  3. <u-navbar
  4. title="我的停车"
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{ background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"
  10. >
  11. </u-navbar>
  12. <template v-if="projectFlag !== 'zhenning'">
  13. <view class="tab-fixed">
  14. <u-tabs-swiper
  15. activeColor="#008CFF"
  16. ref="tabs"
  17. :list="tabList"
  18. :current="tabCurrent"
  19. @change="tabChange"
  20. :is-scroll="false"
  21. swiperWidth="100%"
  22. />
  23. </view>
  24. </template>
  25. <mescroll-body
  26. ref="mescrollRef"
  27. @init="mescrollInit"
  28. @down="downCallback"
  29. @up="upCallback"
  30. height="calc(100vh - 84px)"
  31. :top="projectFlag === 'zhenning' ? 0 : '50rpx'"
  32. >
  33. <view class="parkinglist">
  34. <view class="parkinglist-item" v-for="(item, index) in parkinglist" :key="index" @click="navigation(item.latitude, item.longitude)">
  35. <view class="up u-flex u-row-between">
  36. <view class="vehicle-no">{{ item.vehicleNo || item.parkingNo || '-' }}</view>
  37. <view class="space-name">{{ item.spaceName || item.parkingName || '-' }}</view>
  38. </view>
  39. <view class="down u-flex u-row-left">
  40. <u-icon name="map-fill" color="#008CFF" size="28"></u-icon>
  41. <view class="road-name" v-if="tabCurrentItem.value === 'park'">{{ item.parkingName || '-' }}</view>
  42. <view class="road-name" v-else>{{ item.roadName || '-' }}</view>
  43. </view>
  44. </view>
  45. </view>
  46. </mescroll-body>
  47. <u-toast ref="uToast" />
  48. </view>
  49. </template>
  50. <script>
  51. import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
  52. export default {
  53. mixins: [MescrollMixin], // 使用mixin
  54. data() {
  55. return {
  56. parkinglist: [],
  57. tabCurrent: 0,
  58. tabCurrentItem: {},
  59. tabList: [
  60. { name: '路段', value: 'road' },
  61. { name: '停车场', value: 'park' }
  62. ],
  63. // 当前位置信息
  64. currentPosition: {
  65. latitude: '',
  66. longitude: ''
  67. },
  68. currentPositionHover: {
  69. latitude: '',
  70. longitude: ''
  71. }
  72. };
  73. },
  74. onLoad() {
  75. this.tabCurrentItem = this.tabList[this.tabCurrent];
  76. // this.getLocation();
  77. },
  78. onShow() {},
  79. methods: {
  80. /**
  81. * 获取当前位置信息
  82. * @date 2022-10-09
  83. * @returns {any}
  84. */
  85. getLocation() {
  86. const that = this;
  87. if (navigator.geolocation) {
  88. // 判断是否有这个对象
  89. navigator.geolocation.getCurrentPosition(function (pos) {
  90. console.log('经度:' + pos.coords.longitude + '纬度:' + pos.coords.latitude);
  91. that.currentPosition.latitude = pos.coords.latitude;
  92. that.currentPosition.longitude = pos.coords.longitude;
  93. });
  94. } else {
  95. uni.getLocation({
  96. type: 'gcj02',
  97. success: function (res) {
  98. console.log('当前位置的经度:' + res.longitude);
  99. console.log('当前位置的纬度:' + res.latitude);
  100. that.currentPosition.latitude = res.latitude;
  101. that.currentPosition.longitude = res.longitude;
  102. }
  103. });
  104. }
  105. },
  106. customBack() {
  107. this.$u.route({
  108. type: 'switchTab',
  109. url: 'pages/index/index'
  110. });
  111. },
  112. tabChange(cur) {
  113. this.tabCurrent = cur;
  114. this.tabCurrentItem = this.tabList[cur];
  115. this.mescroll.resetUpScroll();
  116. },
  117. /**
  118. * 导航
  119. * */
  120. navigation(lat, lon) {
  121. // this.currentPositionHover = { longitude: lon, latitude: lat }
  122. if (lat && lon) {
  123. uni.openLocation({
  124. latitude: parseFloat(lat),
  125. longitude: parseFloat(lon),
  126. scale: 18
  127. });
  128. } else {
  129. this.$refs.uToast.show({
  130. title: '该停车点未设置经纬度!',
  131. type: 'warning'
  132. });
  133. }
  134. },
  135. // 多地图选择
  136. /**
  137. * 描述
  138. * @date 2022-10-09
  139. * @param {any} item
  140. * @returns {any}
  141. */
  142. mapSelectConfirm(item) {
  143. const name = item[0].label;
  144. switch (name) {
  145. case '腾讯地图':
  146. location.href = `https://apis.map.qq.com/uri/v1/routeplan?type=drive&from=我的位置&fromcoord=${this.currentPosition.latitude},${this.currentPosition.longitude}&to=${this.currentPositionHover.areaName}&tocoord=${this.currentPositionHover.latitude},${this.currentPositionHover.longitude}&policy=1&referer=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL`;
  147. break;
  148. case '百度地图':
  149. location.href = `http://api.map.baidu.com/marker?location=
  150. ${this.currentPositionHover.latitude},${this.currentPositionHover.longitude}&title=目的地&content=${this.currentPositionHover.areaName}
  151. &output=html&src=webapp.baidu.openAPIdemo`;
  152. break;
  153. case '高德地图':
  154. location.href = `https://uri.amap.com/navigation?from=${this.currentPosition.longitude},${this.currentPosition.latitude},我的位置&to=${this.currentPositionHover.longitude},${this.currentPositionHover.latitude},${this.currentPositionHover.areaName}&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0`;
  155. break;
  156. }
  157. },
  158. downCallback() {
  159. this.mescroll.resetUpScroll();
  160. },
  161. upCallback(page) {
  162. if (this.tabCurrentItem.value === 'park') {
  163. this.getParkingLotParkingList(page);
  164. } else {
  165. this.getRoadParkingList(page);
  166. }
  167. },
  168. /**
  169. * 获取路段我的停车
  170. */
  171. getRoadParkingList({ num, size }) {
  172. this.$u.api
  173. .getOrderList({
  174. orderStatus: 1,
  175. pageNum: num,
  176. pageSize: size
  177. })
  178. .then((res) => {
  179. //设置列表数据
  180. let curPageData = res.data.pageInfo.rows;
  181. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  182. let curPageLen = curPageData.length;
  183. let totalPage = res.data.pageInfo.pages;
  184. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  185. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  186. // 请求成功,隐藏加载状态
  187. //后台接口有返回列表的总页数 totalPage
  188. this.mescroll.endByPage(curPageLen, totalPage);
  189. if (this.parkinglist.length <= 0) {
  190. this.listEmpty = true;
  191. }
  192. });
  193. },
  194. /**
  195. * 获取停车场我的停车
  196. */
  197. getParkingLotParkingList({ num, size }) {
  198. this.$u.api
  199. .getRoomParkingApi({
  200. orderStatus: 1,
  201. pageNum: num,
  202. pageSize: size
  203. })
  204. .then((res) => {
  205. //设置列表数据
  206. let curPageData = res.data.pageInfo.rows;
  207. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  208. let curPageLen = curPageData.length;
  209. let totalPage = res.data.pageInfo.pages;
  210. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  211. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  212. // 请求成功,隐藏加载状态
  213. //后台接口有返回列表的总页数 totalPage
  214. this.mescroll.endByPage(curPageLen, totalPage);
  215. if (this.parkinglist.length <= 0) {
  216. this.listEmpty = true;
  217. }
  218. });
  219. }
  220. }
  221. };
  222. </script>
  223. <style lang="scss">
  224. @import './searchparking.scss';
  225. </style>