orderDet.vue 18 KB

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