orderDet.vue 18 KB

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