xcDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <view>
  3. <view style="position: relative;">
  4. <view>
  5. <map id="map" style="width: 100%; height: 46vh;" :latitude="latitude" :longitude="longitude"
  6. :markers="covers" :polyline="polyline">
  7. </map>
  8. </view>
  9. <view class="listbb" v-if="orderList.length > 0">
  10. <scroll-view scroll-y="true" style="width: 750rpx;height: 790rpx;">
  11. <view v-for="(item,index) in orderList" v-if="item.status == 3 || item.status == 4">
  12. <view class="boxa">
  13. <view class="flex align-center justify-between" style="padding: 30rpx 0rpx 0rpx 30rpx;">
  14. <view style="font-weight: bold;">
  15. <view>{{item.appointmentStartTime}}-{{item.appointmentEndTime}}</view>
  16. </view>
  17. </view>
  18. <view class="order_city">
  19. <view class="flex align-center add_name justify-between"
  20. style="margin: 0rpx 0rpx 4rpx;">
  21. <view class="flex align-center">
  22. <view class="green"></view>{{item.shipAddress}}
  23. </view>
  24. <view class="item_juli">{{item.startDistance}}km</view>
  25. </view>
  26. <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/up.png'" class="order_up"></image>
  27. <view class="flex align-center add_name justify-between">
  28. <view class="flex align-center">
  29. <view class="orgin"></view>{{item.deliveryAddress}}
  30. </view>
  31. <view class="item_juli">{{item.endDistance}}km</view>
  32. </view>
  33. <view class="flex align-center justify-between" style="margin-top: 24rpx;">
  34. <view class="flex align-center">
  35. <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/person.png'" style="width: 30rpx;height: 31rpx;">
  36. </image>
  37. <view style="margin-left: 16rpx;" class="add_name">
  38. {{item.appointmentNum}}人乘坐·{{item.appointmentType == 1 ? '独享' : '拼车'}}
  39. </view>
  40. </view>
  41. <view class="item_juli">订单里程{{item.kmDistance}}km</view>
  42. </view>
  43. </view>
  44. <view class="margin-tb-sm" style="width: 100%;height:1rpx;background: #F2F2F2;"></view>
  45. <view class="flex align-center justify-between padding-lr ">
  46. <view class="flex align-center" @click="bindPhone()">
  47. <view>
  48. <view class="">{{item.shipUserName}}</view>
  49. <!-- <view class="margin-top-xs">{{item.shipUserPhones}}</view> -->
  50. </view>
  51. <view class="flex margin-left-sm">
  52. <image src="/my/static/phone.png" style="width: 22rpx;height: 30rpx;">
  53. </image>
  54. </view>
  55. </view>
  56. <view style="color: #FF2020;font-size: 32rpx;font-weight: bold;">
  57. <text>¥</text><text style="font-size: 42rpx;">{{item.driveMoney}}</text>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- <view class="boxs" style="margin-top: 28rpx;">
  62. <view class="flex align-center justify-between padding-lr">
  63. <view class="flex align-center">
  64. <image src="/static/image/shifuAvatar.png"
  65. style="width: 90rpx;height: 90rpx;border-radius: 50rpx;">
  66. </image>
  67. <view class="margin-left-sm">
  68. <view class="">{{item.shipUserName}}</view>
  69. <view class="margin-top-xs">{{item.shipUserPhones}}</view>
  70. </view>
  71. </view>
  72. <view class="flex" v-if="item.status == 3">
  73. <image src="/my/static/phone.png" @click="bindPhone()"
  74. style="width: 32rpx;height: 40rpx;">
  75. </image>
  76. </view>
  77. </view>
  78. </view> -->
  79. </view>
  80. </scroll-view>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import QQMapWX from '@/components/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js'
  87. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  88. export default {
  89. data() {
  90. return {
  91. orderList: [],
  92. latitude: '',
  93. longitude: '',
  94. qqmapsdk: {}, // 腾讯地图小程序的SDK
  95. covers: [], // 地图上面的标记点
  96. to: { // 目的地坐标
  97. latitude: '',
  98. longitude: '',
  99. },
  100. polyline: [], //路线
  101. polylines: '',
  102. driverRouteId: '',
  103. indentNumber: '',
  104. order: {
  105. appointmentStartTime: ''
  106. },
  107. isVip: false,
  108. waypointsList: [],
  109. waypoints: '', //途径点
  110. globalImages: '',
  111. }
  112. },
  113. onLoad(option) {
  114. waitForGlobalImages().then((path) => {
  115. console.log('✅ 全局图片路径:', path)
  116. this.globalImages = path
  117. })
  118. // 实例化API核心类
  119. // DU7BZ-S6GCJ-Y46FR-XIEGB-4EKBZ-ZMFA4
  120. this.$Request.getT('/app/common/type/282').then(res => { //师傅端腾讯地图key
  121. if (res.code === 0) {
  122. this.qqmapsdk = new QQMapWX({
  123. key: res.data.value // 自己申请的key值
  124. })
  125. }
  126. });
  127. if (option.driverRouteId) {
  128. this.driverRouteId = option.driverRouteId;
  129. this.selectDriverRouteByUserId();
  130. }
  131. },
  132. onShow() {},
  133. methods: {
  134. //获取我的行程
  135. selectDriverRouteByUserId() {
  136. let data = {
  137. userId: uni.getStorageSync('userId'),
  138. driverRouteId: this.driverRouteId
  139. }
  140. this.$Request.getT('/app/driverRoute/selectDriverRouteById', data).then(res => {
  141. if (res.code == 0 && res.data) {
  142. let from = {
  143. lat: res.data.shipAddressLatitude,
  144. lng: res.data.shipAddressLongitude,
  145. address: res.data.shipAddress,
  146. }
  147. let to = {
  148. lat: res.data.deliveryAddressLatitude,
  149. lng: res.data.deliveryAddressLongitude,
  150. address: res.data.deliveryAddress,
  151. }
  152. this.waypointsList = [from, to]
  153. console.log(this.waypointsList, '4444444')
  154. this.latitude = res.data.shipAddressLatitude
  155. this.longitude = res.data.shipAddressLongitude
  156. this.to.latitude = res.data.deliveryAddressLatitude
  157. this.to.longitude = res.data.deliveryAddressLongitude
  158. this.getMyOrderListByRounteId();
  159. } else {
  160. this.getMyOrderListByRounteId();
  161. }
  162. })
  163. },
  164. // 一键导航
  165. openMap(latitude, longitude, name) {
  166. uni.openLocation({
  167. latitude: latitude - 0, //要去的纬度-地址
  168. longitude: longitude - 0, //要去的经度-地址
  169. name: name, //地址名称
  170. address: name, //详细地址名称
  171. success: function() {
  172. console.log('导航成功');
  173. },
  174. fail: function(error) {
  175. console.log(error)
  176. }
  177. });
  178. },
  179. bindPhone() {
  180. uni.makePhoneCall({
  181. phoneNumber: this.order.shipUserPhone //仅为示例
  182. });
  183. },
  184. getMyOrderListByRounteId() {
  185. let driverId = this.$queue.getData('driverId');
  186. if (!driverId) {
  187. return;
  188. }
  189. let userId = this.$queue.getData('userId');
  190. let latitude = uni.getStorageSync('latitude');
  191. let longitude = uni.getStorageSync('longitude');
  192. let data = {
  193. page: 1,
  194. limit: 10,
  195. latitude: latitude,
  196. longitude: longitude,
  197. driverUserId: userId,
  198. appointmentType: '',
  199. driverRouteIds: this.driverRouteId,
  200. driverRouteId: this.driverRouteId,
  201. status: '',
  202. driverId: driverId,
  203. sort: 3
  204. }
  205. let that = this;
  206. this.$Request.getT('/app/orders/selectOrdersList', data).then(res => {
  207. uni.hideLoading()
  208. if (res.code == 0) {
  209. this.order = res.data.list[0]
  210. this.orderList = res.data.list
  211. let waypoints = ''
  212. let dData = {
  213. id: 1,
  214. latitude: that.waypointsList[0].lat,
  215. longitude: that.waypointsList[0].lng,
  216. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/qi.png' : '',
  217. width: 32,
  218. height: 44,
  219. callout: { //自定义标记点上方的气泡窗口 点击有效
  220. content: that.waypointsList[0].address, //文本
  221. color: '#333333', //文字颜色
  222. fontSize: 10, //文本大小
  223. padding: 10, //附近留白
  224. borderRadius: 6, //边框圆角
  225. bgColor: '#FFFFFF', //背景颜色
  226. display: 'ALWAYS', //常显
  227. },
  228. }
  229. that.covers = []
  230. that.covers.push(dData)
  231. res.data.list.forEach((d,index) => {
  232. // waypoints: that.latitude + ',' + that.longitude + ';' + that.to.latitude + ',' + that.to
  233. // .longitude, //客户的位置是途径点
  234. // latitude: this.order.shipAddressLatitude,
  235. // longitude: this.order.shipAddressLongitude,
  236. // latitude: this.order.deliveryAddressLatitude,
  237. // longitude: this.order.deliveryAddressLongitude,
  238. let dDatas = {
  239. id: index + 2,
  240. latitude: d.shipAddressLatitude,
  241. longitude: d.shipAddressLongitude,
  242. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/qi.png' : '',
  243. width: 32,
  244. height: 44,
  245. callout: { //自定义标记点上方的气泡窗口 点击有效
  246. content: d.shipAddress, //文本
  247. color: '#333333', //文字颜色
  248. fontSize: 10, //文本大小
  249. padding: 10, //附近留白
  250. borderRadius: 6, //边框圆角
  251. bgColor: '#FFFFFF', //背景颜色
  252. display: 'ALWAYS', //常显
  253. },
  254. }
  255. that.covers.push(dDatas)
  256. dDatas = {
  257. id: index + 3,
  258. latitude: d.deliveryAddressLatitude,
  259. longitude: d.deliveryAddressLongitude,
  260. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/zd.png' : '',
  261. // iconPath: '../../static/logo.png',
  262. width: 32,
  263. height: 44,
  264. callout: { //自定义标记点上方的气泡窗口 点击有效
  265. content: d.deliveryAddress, //文本
  266. color: '#333333', //文字颜色
  267. fontSize: 10, //文本大小
  268. padding: 10, //附近留白
  269. borderRadius: 6, //边框圆角
  270. bgColor: '#FFFFFF', //背景颜色
  271. display: 'ALWAYS', //常显
  272. },
  273. }
  274. that.covers.push(dDatas)
  275. if (waypoints) {
  276. waypoints = waypoints + ';' + d.shipAddressLatitude + ',' + d.shipAddressLongitude + ';' + d.deliveryAddressLatitude + ',' + d.deliveryAddressLongitude
  277. } else {
  278. waypoints = d.shipAddressLatitude + ',' + d.shipAddressLongitude + ';' + d.deliveryAddressLatitude + ',' + d.deliveryAddressLongitude
  279. }
  280. });
  281. // console.log(this.covers)
  282. dData = {
  283. id: this.covers.length + 1,
  284. latitude: that.waypointsList[1].lat,
  285. longitude: that.waypointsList[1].lng,
  286. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/zd.png' : '',
  287. width: 32,
  288. height: 44,
  289. callout: { //自定义标记点上方的气泡窗口 点击有效
  290. content: that.waypointsList[1].address, //文本
  291. color: '#333333', //文字颜色
  292. fontSize: 10, //文本大小
  293. padding: 10, //附近留白
  294. borderRadius: 6, //边框圆角
  295. bgColor: '#FFFFFF', //背景颜色
  296. display: 'ALWAYS', //常显
  297. },
  298. }
  299. this.covers.push(dData)
  300. this.routePlanning(waypoints)
  301. }
  302. });
  303. },
  304. getorderDet() {
  305. let userId = this.$queue.getData('userId');
  306. let driverRouteId = this.$queue.getData('driverRouteId')
  307. let data = {
  308. ordersId: this.indentNumber,
  309. driverRouteId: driverRouteId,
  310. driverRouteId: this.driverRouteId,
  311. driverUserId: userId
  312. }
  313. this.$Request.getT('/app/orders/selectOrdersDetails', data).then(res => {
  314. if (res.code === 0) {
  315. this.order = res.data
  316. // if (this.order.shipUserPhone) {
  317. // let mobile = this.order.shipUserPhone
  318. // this.order.shipPhone = mobile.substring(0, 3) + "****" + mobile.substring(7)
  319. // }
  320. this.latitude = this.order.shipAddressLatitude
  321. this.longitude = this.order.shipAddressLongitude
  322. this.to.latitude = this.order.deliveryAddressLatitude
  323. this.to.longitude = this.order.deliveryAddressLongitude
  324. this.covers = [{
  325. id: 1,
  326. latitude: this.waypointsList[0].lat,
  327. longitude: this.waypointsList[0].lng,
  328. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/qi.png' : '',
  329. width: 32,
  330. height: 44,
  331. callout: { //自定义标记点上方的气泡窗口 点击有效
  332. content: this.waypointsList[0].address, //文本
  333. color: '#333333', //文字颜色
  334. fontSize: 10, //文本大小
  335. padding: 10, //附近留白
  336. borderRadius: 6, //边框圆角
  337. bgColor: '#FFFFFF', //背景颜色
  338. display: 'ALWAYS', //常显
  339. },
  340. }, {
  341. id: 2,
  342. latitude: this.order.shipAddressLatitude,
  343. longitude: this.order.shipAddressLongitude,
  344. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/qi.png' : '',
  345. // iconPath: '../../static/logo.png',
  346. width: 32,
  347. height: 44,
  348. callout: { //自定义标记点上方的气泡窗口 点击有效
  349. content: this.order.shipAddress, //文本
  350. color: '#333333', //文字颜色
  351. fontSize: 10, //文本大小
  352. padding: 10, //附近留白
  353. borderRadius: 6, //边框圆角
  354. bgColor: '#FFFFFF', //背景颜色
  355. display: 'ALWAYS', //常显
  356. },
  357. }, {
  358. id: 3,
  359. latitude: this.order.deliveryAddressLatitude,
  360. longitude: this.order.deliveryAddressLongitude,
  361. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/zd.png' : '',
  362. // iconPath: '../../static/logo.png',
  363. width: 32,
  364. height: 44,
  365. callout: { //自定义标记点上方的气泡窗口 点击有效
  366. content: this.order.deliveryAddress, //文本
  367. color: '#333333', //文字颜色
  368. fontSize: 10, //文本大小
  369. padding: 10, //附近留白
  370. borderRadius: 6, //边框圆角
  371. bgColor: '#FFFFFF', //背景颜色
  372. display: 'ALWAYS', //常显
  373. },
  374. }, {
  375. id: 4,
  376. latitude: this.waypointsList[1].lat,
  377. longitude: this.waypointsList[1].lng,
  378. iconPath: this.globalImages ? this.globalImages + 'imgs/static/image/zd.png' : '',
  379. width: 32,
  380. height: 44,
  381. callout: { //自定义标记点上方的气泡窗口 点击有效
  382. content: this.waypointsList[1].address, //文本
  383. color: '#333333', //文字颜色
  384. fontSize: 10, //文本大小
  385. padding: 10, //附近留白
  386. borderRadius: 6, //边框圆角
  387. bgColor: '#FFFFFF', //背景颜色
  388. display: 'ALWAYS', //常显
  389. },
  390. }]
  391. // this.polylines = this.order.polyline
  392. this.routePlanning(waypoints)
  393. } else {
  394. uni.showModal({
  395. title: '温馨提示',
  396. content: '当前订单已结束!',
  397. showCancel: false,
  398. confirmText: '确认',
  399. success: res => {
  400. uni.navigateBack();
  401. }
  402. });
  403. }
  404. });
  405. },
  406. // 步行路线规划
  407. routePlanning(waypoints) {
  408. let that = this
  409. // latitude: that.latitude,
  410. // longitude: that.longitude
  411. console.log(that.latitude + ',' + that.longitude + ';' + that.to.latitude + ',' + that.to
  412. .longitude, '2222222')
  413. that.qqmapsdk.direction({
  414. mode: 'driving', // 驾车
  415. from: { // 起始位置(当前位置)坐标
  416. latitude: that.waypointsList[0].lat,
  417. longitude: that.waypointsList[0].lng
  418. },
  419. waypoints: waypoints,
  420. // waypoints: that.latitude + ',' + that.longitude + ';' + that.to.latitude + ',' + that.to
  421. // .longitude, //客户的位置是途径点
  422. to: {
  423. latitude: that.waypointsList[1].lat,
  424. longitude: that.waypointsList[1].lng,
  425. }, // 目的地位置坐标(我的终点)
  426. success(res) {
  427. console.log(res, '=======')
  428. // var coors = JSON.parse(that.polylines)
  429. // console.log(coors,'11111111111111')
  430. var coors = res.result.routes[0].polyline
  431. // console.log(coors2,'11111111111111')
  432. var pl = [] // 点串数组
  433. // 坐标解压(返回的点串坐标,通过前向差分进行压缩)
  434. var kr = 1000000
  435. for (var i = 2; i < coors.length; i++) {
  436. coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr
  437. }
  438. // 将解压后的坐标放入点串数组pl中
  439. for (var i = 0; i < coors.length; i += 2) {
  440. pl.push({
  441. latitude: coors[i],
  442. longitude: coors[i + 1]
  443. })
  444. }
  445. console.log(pl,'plplplplpl')
  446. // 设置polyline属性,将路线显示出来,将解压坐标第一个数据作为起点
  447. that.polyline = [{
  448. points: pl,
  449. color: '#346EF6',
  450. width: 4
  451. }]
  452. },
  453. fail(e) {
  454. console.log(e)
  455. },
  456. })
  457. }
  458. }
  459. }
  460. </script>
  461. <style lang="less">
  462. page {
  463. background: #F5F5F5;
  464. }
  465. .boxs {
  466. background: #FFFFFF;
  467. border-radius: 24rpx;
  468. margin: 30rpx;
  469. padding: 30rpx 0;
  470. }
  471. .item_shunlu {
  472. width: 210rpx;
  473. height: 80rpx;
  474. background: #EFF4FF;
  475. border-radius: 0px 24rpx 0px 50rpx;
  476. text-align: center;
  477. line-height: 80rpx;
  478. font-family: Source Han Sans CN;
  479. font-weight: bold;
  480. font-size: 32rpx;
  481. color: #346EF6;
  482. }
  483. .order_city {
  484. padding: 10rpx 30rpx 10rpx;
  485. font-weight: bold;
  486. color: #1A1A1A;
  487. }
  488. .order_up {
  489. width: 6rpx;
  490. height: 24rpx;
  491. margin-left: 16rpx;
  492. }
  493. .listbb {
  494. position: absolute;
  495. left: 0;
  496. right: 0;
  497. /* #ifdef H5 */
  498. top: 700rpx;
  499. /* #endif */
  500. /* #ifndef H5 */
  501. top: 670rpx;
  502. /* #endif */
  503. }
  504. .boxa {
  505. background: #FFFFFF;
  506. border-radius: 24rpx;
  507. margin: 30rpx;
  508. padding: 0rpx 0rpx 30rpx;
  509. }
  510. .addbox {
  511. display: flex;
  512. align-items: center;
  513. justify-content: space-between;
  514. padding: 0 30rpx;
  515. height: 110rpx;
  516. border-radius: 16rpx;
  517. }
  518. .add_cont {
  519. display: flex;
  520. align-items: center;
  521. }
  522. .add_tit {
  523. font-size: 30rpx;
  524. font-family: PingFang SC;
  525. font-weight: bold;
  526. color: #333333;
  527. }
  528. .bg {
  529. background: #F5F5F5;
  530. }
  531. .bgs {
  532. background: #F5F8FF;
  533. }
  534. .remkbtn {
  535. width: 100%;
  536. height: 98rpx;
  537. background: #346EF6;
  538. border-radius: 16rpx;
  539. font-size: 28rpx;
  540. font-family: PingFang SC;
  541. font-weight: bold;
  542. color: #FFFFFF;
  543. display: flex;
  544. align-items: center;
  545. justify-content: center;
  546. line-height: 98rpx;
  547. margin-top: 40rpx;
  548. }
  549. .green {
  550. width: 16rpx;
  551. height: 16rpx;
  552. background: #1FC657;
  553. border-radius: 50%;
  554. margin-right: 20rpx;
  555. margin-left: 10rpx;
  556. }
  557. .orgin {
  558. width: 16rpx;
  559. height: 16rpx;
  560. background: #FBAC04;
  561. border-radius: 50%;
  562. margin-right: 20rpx;
  563. margin-left: 10rpx;
  564. }
  565. .user {
  566. background: #FFFFFF;
  567. border-radius: 24rpx;
  568. padding: 30rpx;
  569. margin: 30rpx;
  570. display: flex;
  571. align-items: center;
  572. }
  573. .btn {
  574. width: 690rpx;
  575. height: 100rpx;
  576. background: #346EF6;
  577. border-radius: 24rpx;
  578. font-size: 28rpx;
  579. font-family: PingFang SC;
  580. font-weight: bold;
  581. color: #FFFFFF;
  582. display: flex;
  583. align-items: center;
  584. justify-content: center;
  585. margin: 0 auto;
  586. }
  587. .item_juli {
  588. font-family: PingFang SC;
  589. font-weight: 500;
  590. font-size: 26rpx;
  591. color: #999999;
  592. }
  593. </style>