searchparking.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 || '-' }}</view>
  37. <view class="space-name">{{ item.spaceName || '-' }}</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. };
  69. },
  70. onLoad() {
  71. this.tabCurrentItem = this.tabList[this.tabCurrent];
  72. // this.getLocation();
  73. },
  74. onShow() {},
  75. methods: {
  76. /**
  77. * 获取当前位置信息
  78. * @date 2022-10-09
  79. * @returns {any}
  80. */
  81. getLocation() {
  82. const that = this;
  83. if (navigator.geolocation) {
  84. // 判断是否有这个对象
  85. navigator.geolocation.getCurrentPosition(function (pos) {
  86. console.log('经度:' + pos.coords.longitude + '纬度:' + pos.coords.latitude);
  87. that.currentPosition.latitude = pos.coords.latitude;
  88. that.currentPosition.longitude = pos.coords.longitude;
  89. });
  90. } else {
  91. uni.getLocation({
  92. type: 'gcj02',
  93. success: function (res) {
  94. console.log('当前位置的经度:' + res.longitude);
  95. console.log('当前位置的纬度:' + res.latitude);
  96. that.currentPosition.latitude = res.latitude;
  97. that.currentPosition.longitude = res.longitude;
  98. }
  99. });
  100. }
  101. },
  102. customBack() {
  103. this.$u.route({
  104. type: 'switchTab',
  105. url: 'pages/index/index'
  106. });
  107. },
  108. tabChange(cur) {
  109. this.tabCurrent = cur;
  110. this.tabCurrentItem = this.tabList[cur];
  111. this.mescroll.resetUpScroll();
  112. },
  113. /**
  114. * 导航
  115. * */
  116. navigation(lat, lon) {
  117. uni.openLocation({
  118. latitude: parseFloat(lat),
  119. longitude: parseFloat(lon),
  120. scale: 18
  121. });
  122. },
  123. // 多地图选择
  124. /**
  125. * 描述
  126. * @date 2022-10-09
  127. * @param {any} item
  128. * @returns {any}
  129. */
  130. mapSelectConfirm(item) {
  131. const name = item[0].label;
  132. switch (name) {
  133. case '腾讯地图':
  134. 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`;
  135. break;
  136. case '百度地图':
  137. location.href = `http://api.map.baidu.com/marker?location=
  138. ${this.currentPositionHover.latitude},${this.currentPositionHover.longitude}&title=目的地&content=${this.currentPositionHover.areaName}
  139. &output=html&src=webapp.baidu.openAPIdemo`;
  140. break;
  141. case '高德地图':
  142. 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`;
  143. break;
  144. }
  145. },
  146. downCallback() {
  147. this.mescroll.resetUpScroll();
  148. },
  149. upCallback(page) {
  150. if (this.tabCurrentItem.value === 'park') {
  151. this.getParkingLotParkingList(page);
  152. } else {
  153. this.getRoadParkingList(page);
  154. }
  155. },
  156. /**
  157. * 获取路段我的停车
  158. */
  159. getRoadParkingList({ num, size }) {
  160. this.$u.api
  161. .getOrderList({
  162. orderStatus: 1,
  163. pageNum: num,
  164. pageSize: size
  165. })
  166. .then((res) => {
  167. //设置列表数据
  168. let curPageData = res.data.pageInfo.rows;
  169. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  170. let curPageLen = curPageData.length;
  171. let totalPage = res.data.pageInfo.pages;
  172. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  173. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  174. // 请求成功,隐藏加载状态
  175. //后台接口有返回列表的总页数 totalPage
  176. this.mescroll.endByPage(curPageLen, totalPage);
  177. if (this.parkinglist.length <= 0) {
  178. this.listEmpty = true;
  179. }
  180. })
  181. .catch((err) => {
  182. this.$refs.uToast.show({
  183. title: err.msg,
  184. type: 'error'
  185. });
  186. console.log('vehicleList ', err);
  187. });
  188. },
  189. /**
  190. * 获取停车场我的停车
  191. */
  192. getParkingLotParkingList({ num, size }) {
  193. this.$u.api
  194. .getRoomParkingApi({
  195. orderStatus: 1,
  196. pageNum: num,
  197. pageSize: size
  198. })
  199. .then((res) => {
  200. //设置列表数据
  201. let curPageData = res.data.pageInfo.rows;
  202. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  203. let curPageLen = curPageData.length;
  204. let totalPage = res.data.pageInfo.pages;
  205. if (num == 1) this.parkinglist = []; //如果是第一页需手动置空列表
  206. this.parkinglist = this.parkinglist.concat(curPageData); //追加新数据
  207. // 请求成功,隐藏加载状态
  208. //后台接口有返回列表的总页数 totalPage
  209. this.mescroll.endByPage(curPageLen, totalPage);
  210. if (this.parkinglist.length <= 0) {
  211. this.listEmpty = true;
  212. }
  213. })
  214. .catch((err) => {
  215. this.$refs.uToast.show({
  216. title: err.msg,
  217. type: 'error'
  218. });
  219. });
  220. }
  221. }
  222. };
  223. </script>
  224. <style lang="scss">
  225. @import './searchparking.scss';
  226. </style>