index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  1. <template>
  2. <view class="trip">
  3. <zs-header title="出行" :backCall="backCall" color="#000"></zs-header>
  4. <map id="Map" class="map" style="width: 100%;" :scale="scale" :longitude="longitude" :latitude="latitude"
  5. :includePoints="includePoints" enable-poi :polyline="polyline" show-location :markers="markers"
  6. @regionchange="mapChange">
  7. <image class="current" v-show="step == 1" src="../../static/current.png" mode=""></image>
  8. <image class="btn" src="../../static/map-position.png" mode="" @click="myPosition"></image>
  9. </map>
  10. <view class="content">
  11. <!-- 选择地址 -->
  12. <template v-if="step == 1 || step == 2">
  13. <image class="img"
  14. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/j.png/1.png">
  15. </image>
  16. <view class="operation">
  17. <view class="start-box" @click="chooseAddress('start')">
  18. <view class="start">
  19. <view class="point"></view>
  20. 您将从 <text class="green">{{ form.start }}</text> 出发
  21. </view>
  22. <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  23. </view>
  24. <view class="end" @click="chooseAddress('end')">
  25. <view class="point"></view>
  26. {{ form.end || '您想去哪里' }}
  27. </view>
  28. <u-button @click="call()" color="#FF4A39" shape="circle" :loading="loading">
  29. 呼叫秋香代驾
  30. </u-button>
  31. </view>
  32. </template>
  33. <!-- 呼叫订单 -->
  34. <template v-if="step == 3">
  35. <view class="call-operation">
  36. <view class="title">正在全力为您寻找司机 {{ formatTimer }}</view>
  37. <view class="call-img">
  38. <image
  39. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/路径 7911@2x.png/2.png">
  40. </image>
  41. </view>
  42. <view class="call-btn">
  43. <u-button type="info" @click="hangup()" shape="circle">
  44. 取消订单
  45. </u-button>
  46. </view>
  47. </view>
  48. </template>
  49. <!-- 代驾到位 -->
  50. <template v-if="step == 4">
  51. <view class="driver-operation">
  52. <view class="desc">
  53. <viwe class="title">
  54. <view class="desc-title">
  55. 司机正在赶来,请耐心等待
  56. </view>
  57. <view class="desc-subtitle">
  58. 如需取消订单,请联系司机或客服人员
  59. </view>
  60. </viwe>
  61. <view class="car-img">
  62. <image
  63. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/微信截图_20240815144439-removebg-preview@2x.png/1.png">
  64. </image>
  65. </view>
  66. </view>
  67. <view class="driver-card">
  68. <view class="driver">
  69. <view class="driver-avatar">
  70. <u-avatar shape="circle" size="100" :src="`https://cdn.qxtech.top/avatar/driver_default-200.jpg`">
  71. </u-avatar>
  72. </view>
  73. <view class="driver-info">
  74. <view class="driver-name">{{ driver.driverName + ' ' + driver.driverId || '' }}</view>
  75. <view class="driver-car">秋香代驾</view>
  76. </view>
  77. <view class="driver-option">
  78. <view class="customer" @click="customer">
  79. <image
  80. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8090@2x.png/1.png"
  81. mode=""></image>
  82. </view>
  83. <view class="call" @click='callPhone'>
  84. <image
  85. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8089@2x.png/1.png"
  86. mode=""></image>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="price-box" @click="jump('../expense/index?priceItems='+JSON.stringify(priceItems))">
  91. <view class="price">预估<text>{{ driver.payPrice }}</text>元</view>
  92. <view class="jiantou">
  93. <image src="../../static/jiantou-icon.png" mode=""></image>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </template>
  99. <template v-if="step == 5">
  100. <view class="await-operation">
  101. <view class="desc">
  102. <viwe class="title">
  103. <view class="desc-title">
  104. 等待中...
  105. </view>
  106. <view class="desc-subtitle">
  107. 司机已到达,为避免额外费用,请尽快联系
  108. </view>
  109. </viwe>
  110. <view class="car-img">
  111. <image
  112. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/微信截图_20240815144439-removebg-preview@2x.png/1.png">
  113. </image>
  114. </view>
  115. </view>
  116. <view class="driver-card">
  117. <view class="driver">
  118. <view class="driver-avatar">
  119. <u-avatar shape="circle" size="100" :src="`https://cdn.qxtech.top/avatar/driver_default-200.jpg`">
  120. </u-avatar>
  121. </view>
  122. <view class="driver-info">
  123. <view class="driver-name">{{ driver.driverName + ' ' + driver.driverId || '' }}</view>
  124. <view class="driver-car">秋香代驾</view>
  125. </view>
  126. <view class="driver-option">
  127. <view class="customer" @click="customer">
  128. <image
  129. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8090@2x.png/1.png"
  130. mode=""></image>
  131. </view>
  132. <view class="call" @click='callPhone'>
  133. <image
  134. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8089@2x.png/1.png"
  135. mode=""></image>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </template>
  142. <!-- 开始订单 -->
  143. <template v-if="step == 6">
  144. <view class="drivering-operation">
  145. <view class="desc">
  146. <viwe class="title">
  147. <view class="desc-title">
  148. 行驶中
  149. </view>
  150. <view class="desc-subtitle">
  151. 如需取消订单,请联系司机或客服人员
  152. </view>
  153. </viwe>
  154. <view class="car-img">
  155. <image
  156. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/微信截图_20240815144439-removebg-preview@2x.png/1.png">
  157. </image>
  158. </view>
  159. </view>
  160. <view class="driver-card">
  161. <view class="driver">
  162. <view class="driver-avatar">
  163. <u-avatar shape="circle" size="100" :src="`https://cdn.qxtech.top/avatar/driver_default-200.jpg`">
  164. </u-avatar>
  165. </view>
  166. <view class="driver-info">
  167. <view class="driver-name">{{ driver.driverName + ' ' + driver.driverId || '' }}</view>
  168. <view class="driver-car">秋香代驾</view>
  169. </view>
  170. <view class="driver-option">
  171. <view class="customer" @click="customer">
  172. <image
  173. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8090@2x.png/1.png"
  174. mode=""></image>
  175. </view>
  176. <!-- <view class="call" @click='callPhone'>
  177. <image
  178. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8089@2x.png/1.png"
  179. mode=""></image>
  180. </view> -->
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. </template>
  186. <!-- 订单完成 -->
  187. <template v-if="step == 7">
  188. <view class="order-operation">
  189. <view class="desc">
  190. <viwe class="title">
  191. <view class="desc-title">
  192. 订单完成
  193. </view>
  194. <view class="desc-subtitle">
  195. 请使用微信扫码完成支付,如对价格有疑问,请联系客服人员
  196. </view>
  197. </viwe>
  198. <view class="car-img">
  199. <image
  200. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/微信截图_20240815144439-removebg-preview@2x.png/1.png">
  201. </image>
  202. </view>
  203. </view>
  204. <view class="driver-card">
  205. <view class="driver">
  206. <view class="driver-avatar">
  207. <u-avatar shape="circle" size="100" :src="`https://cdn.qxtech.top/avatar/driver_default-200.jpg`">
  208. </u-avatar>
  209. </view>
  210. <view class="driver-info">
  211. <view class="driver-name">{{ driver.driverName || '王师傅 编号D1002' }}</view>
  212. <view class="driver-car">秋香代驾</view>
  213. </view>
  214. <view class="driver-option">
  215. <view class="customer" @click="customer">
  216. <image
  217. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/组 8090@2x.png/1.png"
  218. mode=""></image>
  219. </view>
  220. </view>
  221. </view>
  222. <view class="price-box" @click="jump('../expense/index?priceItems='+JSON.stringify(priceItems))">
  223. <view class="price">需支付<text>{{ driver.payPrice }}</text>元</view>
  224. <view class="jiantou">
  225. <image src="../../static/jiantou-icon.png" mode=""></image>
  226. </view>
  227. </view>
  228. </view>
  229. </view>
  230. </template>
  231. </view>
  232. <u-action-sheet :actions="optionList" :closeOnClickOverlay="true" :closeOnClickAction="true"
  233. @close="hangupShow = false" @select="selectClick" title="取消原因" cancelText="取消" :safeAreaInsetBottom="true"
  234. :show="hangupShow">
  235. </u-action-sheet>
  236. </view>
  237. </template>
  238. <script>
  239. // 高德地图
  240. // var amapFile = require('../../libs/amap-wx.130.js');
  241. // var AMap = new amapFile.AMapWX({
  242. // key: '0ebb337dd2e77cb84e40525a5b80d640'
  243. // });
  244. // 腾讯地图
  245. var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
  246. var qqmapsdk = new QQMapWX({
  247. key: 'KX5BZ-B64RC-RO62W-AMWAZ-VVTC3-YAFXF'
  248. });
  249. import { mixin } from './mixin/index.js';
  250. export default {
  251. data() {
  252. return {
  253. step: 1,
  254. map: null,
  255. longitude: 0,
  256. latitude: 0,
  257. polyline: 0,
  258. scale: 17,
  259. flag: false, //
  260. markers: [],
  261. mapCenter: {
  262. longitude: 0,
  263. latitude: 0
  264. },
  265. includePoints: [],
  266. form: {
  267. adcode: '',
  268. start: '',
  269. startLocation: {
  270. lat: 0,
  271. lng: 0
  272. },
  273. end: '',
  274. endLocation: {
  275. lat: 0,
  276. lng: 0
  277. },
  278. taxi_fare: 0
  279. },
  280. isDraw: false,
  281. isCarDraw: false
  282. }
  283. },
  284. mixins: [mixin],
  285. methods: {
  286. backCall(step) {
  287. },
  288. // 跳转
  289. jump(url) {
  290. uni.navigateTo({
  291. url
  292. })
  293. },
  294. // 回到我的位置
  295. myPosition() {
  296. let that = this
  297. uni.getLocation({
  298. type: 'gcj02',
  299. success(res) {
  300. that.map.moveToLocation({
  301. longitude: res.longitude,
  302. latitude: res.latitude
  303. })
  304. }
  305. })
  306. },
  307. // 地图拖动
  308. mapChange(val) {
  309. // 绘制出路线后 就不能拖动地图选择起点
  310. console.log(val)
  311. console.log(this.map.getScale().then(res => { console.log(res) }))
  312. if (this.step != 1) return
  313. let that = this
  314. if (val.type == 'end') {
  315. this.mapCenter = val.target.centerLocation
  316. qqmapsdk.reverseGeocoder({
  317. location: {
  318. longitude: val.target.centerLocation.longitude,
  319. latitude: val.target.centerLocation.latitude
  320. },
  321. poi_options: 'policy=3&address_format=short&radius=30',
  322. get_poi: 1,
  323. success(r) {
  324. console.log('地图拖动', r);
  325. if (r.result.address_reference.landmark_l2._dir_desc == '内') {
  326. }
  327. // 获取最近的店铺
  328. // let arr = r.result.pois.sort((a, b) => { return a._distance - b._distance })
  329. that.form.adcode = r.result.pois[0].ad_info.adcode
  330. that.form.start = r.result.pois[0].title
  331. that.form.startLocation = r.result.pois[0].location
  332. uni.setStorageSync('city', r.result.address_component.city)
  333. },
  334. fail(e) {
  335. console.log('错误', e);
  336. }
  337. })
  338. }
  339. },
  340. // 选择地址
  341. chooseAddress(type) {
  342. uni.setStorageSync('form', JSON.stringify(this.form))
  343. uni.navigateTo({
  344. url: '../chooseAddress/index?type=' + type
  345. })
  346. },
  347. // 获取当前经纬度
  348. initPosition() {
  349. let that = this
  350. uni.getLocation({
  351. type: 'gcj02',
  352. success(res) {
  353. console.log(res);
  354. that.longitude = res.longitude
  355. that.latitude = res.latitude
  356. that.mapCenter = {
  357. longitude: res.longitude,
  358. latitude: res.latitude
  359. }
  360. that.myPosition()
  361. }
  362. })
  363. },
  364. //绘制路线
  365. go(unset = false) {
  366. if (!unset) {
  367. this.step = 2
  368. }
  369. var _this = this;
  370. //调用距离计算接口
  371. qqmapsdk.direction({
  372. mode: 'driving', //可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填
  373. //from参数不填默认当前地址
  374. from: `${_this.form.startLocation.lat},${_this.form.startLocation.lng}`,
  375. to: `${_this.form.endLocation.lat},${_this.form.endLocation.lng}`,
  376. success: function (res) {
  377. console.log('地图绘制', res);
  378. _this.form.taxi_fare = res.result.routes[0].taxi_fare.fare
  379. var ret = res;
  380. var coors = ret.result.routes[0].polyline,
  381. pl = [];
  382. //坐标解压(返回的点串坐标,通过前向差分进行压缩)
  383. var kr = 1000000;
  384. for (var i = 2; i < coors.length; i++) {
  385. coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr;
  386. }
  387. //将解压后的坐标放入点串数组pl中
  388. for (var i = 0; i < coors.length; i += 2) {
  389. pl.push({
  390. latitude: coors[i],
  391. longitude: coors[i + 1]
  392. })
  393. }
  394. //设置polyline属性,将路线显示出来,将解压坐标第一个数据作为起点
  395. _this.latitude = pl[0].latitude
  396. _this.longitude = pl[0].longitude
  397. _this.map.addMarkers({
  398. markers: [{
  399. id: 101,
  400. latitude: _this.form.startLocation.lat,
  401. longitude: _this.form.startLocation.lng,
  402. width: '41px',
  403. height: '47px',
  404. iconPath: '/static/start.png',
  405. callout: {
  406. content: _this.form.start,
  407. bgColor: '#fff',
  408. color: '#222',
  409. borderRadius: '50%',
  410. fontSize: '14px',
  411. padding: '8px',
  412. display: 'ALWAYS'
  413. }
  414. },
  415. {
  416. id: 102,
  417. latitude: _this.form.endLocation.lat,
  418. longitude: _this.form.endLocation.lng,
  419. width: '41px',
  420. height: '47px',
  421. iconPath: '/static/end.png',
  422. callout: {
  423. content: _this.form.end,
  424. bgColor: '#fff',
  425. color: '#222',
  426. borderRadius: '50%',
  427. fontSize: '14px',
  428. padding: '8px',
  429. display: 'ALWAYS'
  430. }
  431. }
  432. ],
  433. clear: true
  434. })
  435. _this.polyline = [{
  436. points: pl,
  437. color: '#39B0FF',
  438. borderColor: '#0071BC',
  439. arrowLine: true,
  440. width: 4
  441. }]
  442. setTimeout(() => {
  443. let includePoints = []
  444. includePoints.push({
  445. latitude: pl[0].latitude + 0.01,
  446. longitude: pl[0].longitude + 0.01
  447. })
  448. includePoints.push({
  449. latitude: pl[pl.length - 1].latitude - 0.01,
  450. longitude: pl[pl.length - 1].longitude - 0.01
  451. })
  452. _this.includePoints = includePoints
  453. }, 500)
  454. },
  455. fail: function (error) {
  456. console.error(error);
  457. },
  458. complete: function (res) {
  459. uni.setStorageSync('form', JSON.stringify(_this.form))
  460. }
  461. });
  462. },
  463. //绘制出行路线
  464. goToUser() {
  465. var _this = this;
  466. //调用距离计算接口
  467. qqmapsdk.direction({
  468. mode: "bicycling", //可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填
  469. //from参数不填默认当前地址
  470. from: `${_this.location.latitude},${_this.location.longitude}`,
  471. to: `${_this.form.startLocation.lat},${_this.form.startLocation.lng}`,
  472. success: function (res) {
  473. console.log("地图绘制", res);
  474. // _this.form.taxi_fare = res.result.routes[0].taxi_fare.fare
  475. var ret = res;
  476. var coors = ret.result.routes[0].polyline,
  477. pl = [];
  478. //坐标解压(返回的点串坐标,通过前向差分进行压缩)
  479. var kr = 1000000;
  480. for (var i = 2; i < coors.length; i++) {
  481. coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr;
  482. }
  483. //将解压后的坐标放入点串数组pl中
  484. for (var i = 0; i < coors.length; i += 2) {
  485. pl.push({
  486. latitude: coors[i],
  487. longitude: coors[i + 1],
  488. });
  489. }
  490. // 是否绘制过车辆 没有则绘制
  491. if (!_this.isDraw) {
  492. _this.isDraw = true;
  493. _this.map.addMarkers({
  494. markers: [
  495. {
  496. id: 100,
  497. latitude: _this.location.latitude,
  498. longitude: _this.location.longitude,
  499. width: "98rpx",
  500. height: "46rpx",
  501. iconPath: "/static/car.png",
  502. callout: {
  503. content: "正在路上",
  504. bgColor: "#fff",
  505. color: "#222",
  506. borderRadius: "50%",
  507. fontSize: "14px",
  508. padding: "8px",
  509. display: "ALWAYS",
  510. },
  511. },
  512. {
  513. id: 103,
  514. latitude: _this.form.startLocation.lat,
  515. longitude: _this.form.startLocation.lng,
  516. width: "41px",
  517. height: "47px",
  518. iconPath: "/static/start.png",
  519. callout: {
  520. content: _this.form.start,
  521. bgColor: "#fff",
  522. color: "#222",
  523. borderRadius: "50%",
  524. fontSize: "14px",
  525. padding: "8px",
  526. display: "ALWAYS",
  527. },
  528. },
  529. ],
  530. clear: true,
  531. });
  532. } else {
  533. _this.map.translateMarker(
  534. {
  535. markerId: 100,
  536. autoRotate: true,
  537. destination: {
  538. latitude: _this.location.latitude,
  539. longitude: _this.location.longitude
  540. },
  541. animationEnd() {
  542. }
  543. ,
  544. success(res) {
  545. console.log(res)
  546. }
  547. }
  548. )
  549. }
  550. _this.polyline = [
  551. {
  552. points: pl,
  553. color: "#39B0FF",
  554. borderColor: "#0071BC",
  555. arrowLine: true,
  556. width: 4,
  557. },
  558. ];
  559. },
  560. fail: function (error) {
  561. console.error(error);
  562. },
  563. complete: function (res) {
  564. console.log(res);
  565. },
  566. });
  567. },
  568. goToEnd() {
  569. var _this = this;
  570. //调用距离计算接口
  571. qqmapsdk.direction({
  572. mode: 'driving', //可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填
  573. //from参数不填默认当前地址
  574. from: `${_this.location.latitude},${_this.location.longitude}`,
  575. to: `${_this.form.endLocation.lat},${_this.form.endLocation.lng}`,
  576. success: function (res) {
  577. console.log('地图绘制', res);
  578. _this.form.taxi_fare = res.result.routes[0].taxi_fare.fare
  579. var ret = res;
  580. var coors = ret.result.routes[0].polyline,
  581. pl = [];
  582. //坐标解压(返回的点串坐标,通过前向差分进行压缩)
  583. var kr = 1000000;
  584. for (var i = 2; i < coors.length; i++) {
  585. coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr;
  586. }
  587. //将解压后的坐标放入点串数组pl中
  588. for (var i = 0; i < coors.length; i += 2) {
  589. pl.push({
  590. latitude: coors[i],
  591. longitude: coors[i + 1]
  592. })
  593. }
  594. if (!_this.isCarDraw) {
  595. _this.isCarDraw = true;
  596. _this.map.addMarkers({
  597. markers: [{
  598. id: 104,
  599. latitude: _this.location.latitude,
  600. longitude: _this.location.longitude,
  601. width: "98rpx",
  602. height: "46rpx",
  603. iconPath: "/static/car.png",
  604. callout: {
  605. content: "订单进行中",
  606. bgColor: "#fff",
  607. color: "#222",
  608. borderRadius: "50%",
  609. fontSize: "14px",
  610. padding: "8px",
  611. display: "ALWAYS",
  612. },
  613. },
  614. {
  615. id: 105,
  616. latitude: _this.form.endLocation.lat,
  617. longitude: _this.form.endLocation.lng,
  618. width: '41px',
  619. height: '47px',
  620. iconPath: '/static/end.png',
  621. callout: {
  622. content: _this.form.end,
  623. bgColor: '#fff',
  624. color: '#222',
  625. borderRadius: '50%',
  626. fontSize: '14px',
  627. padding: '8px',
  628. display: 'ALWAYS'
  629. }
  630. }
  631. ],
  632. clear: true
  633. })
  634. } else {
  635. _this.map.translateMarker({
  636. markerId: 104,
  637. autoRotate: true,
  638. destination: {
  639. latitude: _this.location.latitude,
  640. longitude: _this.location.longitude
  641. },
  642. animationEnd() {
  643. },
  644. success(res) {
  645. console.log(res)
  646. }
  647. })
  648. }
  649. _this.polyline = [{
  650. points: pl,
  651. color: '#39B0FF',
  652. borderColor: '#0071BC',
  653. arrowLine: true,
  654. width: 4
  655. }]
  656. },
  657. fail: function (error) {
  658. console.error(error);
  659. },
  660. complete: function (res) {
  661. console.log(res);
  662. }
  663. });
  664. },
  665. callPhone(){
  666. uni.makePhoneCall({
  667. phoneNumber: this.driver.driverPhone
  668. })
  669. },
  670. customer(){
  671. uni.showModal({
  672. title: '提示',
  673. content: '是否拨打客服电话0851-86889969',
  674. success: function (res) {
  675. if (res.confirm) {
  676. uni.makePhoneCall({
  677. phoneNumber: '0851-86889969'
  678. })
  679. }
  680. }
  681. })
  682. }
  683. },
  684. computed: {
  685. formatTimer() {
  686. return `${this.minutes.toString().padStart(2, '0')}:${this.seconds.toString().padStart(2, '0')}`;
  687. }
  688. },
  689. onReady() {
  690. this.map = uni.createMapContext('Map', this)
  691. // 如果start 有值则不进行初始化
  692. },
  693. onLoad(option) {
  694. let that = this
  695. // 获取地址选择页面传来的数据
  696. const eventChannel = this.getOpenerEventChannel();
  697. if (JSON.stringify(eventChannel) !== '{}') {
  698. eventChannel.on('address', function (data) {
  699. if (uni.getStorageSync('form')) {
  700. that.form = JSON.parse(uni.getStorageSync('form'))
  701. }
  702. that.form[option.type] = data.address
  703. that.latitude = data.latitude
  704. that.longitude = data.longitude
  705. that.form[option.type + 'Location'].lat = data.latitude
  706. that.form[option.type + 'Location'].lng = data.longitude
  707. // 如果起点和终点都设置,绘制出路线
  708. if (that.form.start && that.form.end) {
  709. that.go()
  710. }
  711. })
  712. }
  713. if (option.type !== 'start') {
  714. this.initPosition()
  715. }
  716. // 读取是否存在进行中的订单
  717. const tripId = uni.getStorageSync('tripId');
  718. if (tripId.length > 1) {
  719. uni.showLoading({
  720. title: '加载订单中...'
  721. });
  722. this.hangupObj.queryId = tripId;
  723. if (uni.getStorageSync('form')) {
  724. that.form = JSON.parse(uni.getStorageSync('form'))
  725. }
  726. uni.hideLoading();
  727. this.startTimer();
  728. }
  729. },
  730. created() {
  731. }
  732. }
  733. </script>
  734. <style lang="scss" scoped>
  735. .trip {
  736. display: flex;
  737. flex-direction: column;
  738. height: 78vh;
  739. .map {
  740. height: 70vh;
  741. flex: 1;
  742. position: relative;
  743. .current {
  744. position: absolute;
  745. left: 50%;
  746. top: 50%;
  747. transform: translate(-50%, calc(-50% - 40rpx));
  748. width: 40rpx;
  749. height: 68rpx;
  750. }
  751. .btn {
  752. position: absolute;
  753. bottom: 20%;
  754. right: 20rpx;
  755. width: 60rpx;
  756. height: 60rpx;
  757. }
  758. }
  759. .content {
  760. width: 100%;
  761. height: 530rpx;
  762. border-radius: 16rpx 16rpx 0 0;
  763. background-color: transparent;
  764. position: absolute;
  765. bottom: 0;
  766. .img {
  767. height: 180rpx;
  768. width: 100%;
  769. margin-top: -60rpx;
  770. }
  771. .operation {
  772. width: 100%;
  773. height: 424rpx;
  774. padding: 28rpx 24rpx;
  775. background: #FFFFFF;
  776. border-radius: 20rpx 20rpx 20rpx 20rpx;
  777. position: absolute;
  778. bottom: 0rpx;
  779. left: 50%;
  780. transform: translateX(-50%);
  781. box-sizing: border-box;
  782. display: flex;
  783. flex-direction: column;
  784. align-items: center;
  785. .start-box {
  786. display: flex;
  787. align-items: center;
  788. justify-content: space-between;
  789. margin: 0 52rpx;
  790. width: 100%;
  791. .start {
  792. font-weight: bold;
  793. color: #222222;
  794. font-size: 28rpx;
  795. display: flex;
  796. align-items: center;
  797. .point {
  798. width: 16rpx;
  799. height: 16rpx;
  800. background: #07AC82;
  801. margin-left: 24rpx;
  802. margin-right: 20rpx;
  803. border-radius: 50%;
  804. }
  805. .green {
  806. color: #07AC82;
  807. max-width: 424rpx;
  808. white-space: nowrap;
  809. overflow: hidden;
  810. text-overflow: ellipsis;
  811. display: inline-block;
  812. }
  813. }
  814. .jiantou {
  815. float: right;
  816. width: 20rpx;
  817. height: 20rpx;
  818. }
  819. }
  820. .end {
  821. display: flex;
  822. align-items: center;
  823. width: 100%;
  824. height: 116rpx;
  825. line-height: 116rpx;
  826. text-indent: 36rpx;
  827. background: #F0F0F0;
  828. border-radius: 16rpx 16rpx 16rpx 16rpx;
  829. font-weight: bold;
  830. color: #222222;
  831. font-size: 40rpx;
  832. margin-top: 28rpx;
  833. margin-bottom: 24rpx;
  834. .point {
  835. margin: 0 20rpx 0 24rpx;
  836. width: 16rpx;
  837. height: 16rpx;
  838. background: #FF4A39;
  839. border-radius: 50%;
  840. }
  841. }
  842. .btn {
  843. width: 100%;
  844. line-height: 80rpx;
  845. text-align: center;
  846. // background: #;
  847. border-radius: 40rpx 40rpx 40rpx 40rpx;
  848. margin-top: 28rpx;
  849. font-weight: bold;
  850. color: #FFFFFF;
  851. font-size: 28rpx;
  852. }
  853. }
  854. .call-operation {
  855. width: 100%;
  856. height: 538rpx;
  857. padding: 28rpx 24rpx;
  858. background: #FFFFFF;
  859. border-radius: 20rpx;
  860. position: absolute;
  861. bottom: 0rpx;
  862. left: 50%;
  863. transform: translateX(-50%);
  864. box-sizing: border-box;
  865. .call-img {
  866. width: 266rpx;
  867. height: 266rpx;
  868. margin: 0 auto;
  869. image {
  870. width: 100%;
  871. height: 100%;
  872. }
  873. }
  874. .title {
  875. font-size: 36rpx;
  876. color: #222222;
  877. font-weight: bold;
  878. margin-bottom: 10rpx;
  879. // text-align: left;
  880. }
  881. .call-btn {
  882. width: 344rpx;
  883. margin: 0 auto;
  884. }
  885. }
  886. .driver-operation {
  887. background: #F9F9F9;
  888. border-radius: 20rpx;
  889. height: 526rpx;
  890. padding: 28rpx 24rpx;
  891. .desc {
  892. display: flex;
  893. justify-content: space-between;
  894. align-items: center;
  895. .title {
  896. display: flex;
  897. flex-direction: column;
  898. .desc-title {
  899. font-size: 36rpx;
  900. color: #222222;
  901. font-weight: bold;
  902. }
  903. .desc-subtitle {
  904. font-size: 24rpx;
  905. color: #222222;
  906. margin-top: 24rpx;
  907. }
  908. }
  909. .car-img {
  910. width: 234rpx;
  911. height: 122rpx;
  912. image {
  913. width: 100%;
  914. height: 100%;
  915. }
  916. }
  917. }
  918. .driver-card {
  919. background: #FFFFFF;
  920. margin-top: 22rpx;
  921. padding: 28rpx 22rpx;
  922. border-radius: 20rpx;
  923. .driver {
  924. display: flex;
  925. .driver-avatar {
  926. height: 100rpx;
  927. width: 100rpx;
  928. }
  929. .driver-info {
  930. flex: 1;
  931. margin-left: 20rpx;
  932. display: flex;
  933. flex-direction: column;
  934. justify-content: space-between;
  935. .driver-name {
  936. font-size: 32rpx;
  937. color: #222222;
  938. font-weight: bold;
  939. }
  940. .driver-car {
  941. font-size: 24rpx;
  942. color: #999999;
  943. }
  944. }
  945. .driver-option {
  946. display: flex;
  947. .call,
  948. .customer {
  949. width: 60rpx;
  950. height: 60rpx;
  951. margin-left: 20rpx;
  952. image {
  953. height: 100%;
  954. width: 100%;
  955. }
  956. }
  957. }
  958. }
  959. .price-box {
  960. display: flex;
  961. justify-content: flex-end;
  962. margin-top: 20rpx;
  963. padding-top: 28rpx;
  964. border-top: 1px solid #F0F0F0;
  965. .price {
  966. font-size: 32rpx;
  967. color: #FF4A39;
  968. font-weight: bold;
  969. margin-right: 40%;
  970. }
  971. .jiantou {
  972. width: 20rpx;
  973. height: 20rpx;
  974. image {
  975. height: 100%;
  976. width: 100%;
  977. }
  978. }
  979. }
  980. }
  981. }
  982. .drivering-operation {
  983. background: #F9F9F9;
  984. border-radius: 20rpx;
  985. height: 416rpx;
  986. padding: 28rpx 24rpx;
  987. .desc {
  988. display: flex;
  989. justify-content: space-between;
  990. align-items: center;
  991. .title {
  992. display: flex;
  993. flex-direction: column;
  994. .desc-title {
  995. font-size: 36rpx;
  996. color: #222222;
  997. font-weight: bold;
  998. }
  999. .desc-subtitle {
  1000. font-size: 24rpx;
  1001. color: #222222;
  1002. margin-top: 24rpx;
  1003. }
  1004. }
  1005. .car-img {
  1006. width: 234rpx;
  1007. height: 122rpx;
  1008. image {
  1009. width: 100%;
  1010. height: 100%;
  1011. }
  1012. }
  1013. }
  1014. .driver-card {
  1015. background: #FFFFFF;
  1016. margin-top: 22rpx;
  1017. padding: 28rpx 22rpx;
  1018. border-radius: 20rpx;
  1019. .driver {
  1020. display: flex;
  1021. .driver-avatar {
  1022. height: 100rpx;
  1023. width: 100rpx;
  1024. }
  1025. .driver-info {
  1026. flex: 1;
  1027. margin-left: 20rpx;
  1028. display: flex;
  1029. flex-direction: column;
  1030. justify-content: space-between;
  1031. .driver-name {
  1032. font-size: 32rpx;
  1033. color: #222222;
  1034. font-weight: bold;
  1035. }
  1036. .driver-car {
  1037. font-size: 24rpx;
  1038. color: #999999;
  1039. }
  1040. }
  1041. .driver-option {
  1042. display: flex;
  1043. .call,
  1044. .customer {
  1045. width: 60rpx;
  1046. height: 60rpx;
  1047. margin-left: 20rpx;
  1048. image {
  1049. height: 100%;
  1050. width: 100%;
  1051. }
  1052. }
  1053. }
  1054. }
  1055. }
  1056. }
  1057. .await-operation {
  1058. background: #F9F9F9;
  1059. border-radius: 20rpx;
  1060. height: 424rpx;
  1061. padding: 28rpx 24rpx;
  1062. .desc {
  1063. display: flex;
  1064. justify-content: space-between;
  1065. align-items: center;
  1066. .title {
  1067. display: flex;
  1068. flex-direction: column;
  1069. .desc-title {
  1070. font-size: 36rpx;
  1071. color: #222222;
  1072. font-weight: bold;
  1073. }
  1074. .desc-subtitle {
  1075. font-size: 24rpx;
  1076. color: #222222;
  1077. margin-top: 24rpx;
  1078. }
  1079. }
  1080. .car-img {
  1081. width: 234rpx;
  1082. height: 122rpx;
  1083. image {
  1084. width: 100%;
  1085. height: 100%;
  1086. }
  1087. }
  1088. }
  1089. .driver-card {
  1090. background: #FFFFFF;
  1091. margin-top: 22rpx;
  1092. padding: 28rpx 22rpx;
  1093. border-radius: 20rpx;
  1094. .driver {
  1095. display: flex;
  1096. .driver-avatar {
  1097. height: 100rpx;
  1098. width: 100rpx;
  1099. }
  1100. .driver-info {
  1101. flex: 1;
  1102. margin-left: 20rpx;
  1103. display: flex;
  1104. flex-direction: column;
  1105. justify-content: space-between;
  1106. .driver-name {
  1107. font-size: 32rpx;
  1108. color: #222222;
  1109. font-weight: bold;
  1110. }
  1111. .driver-car {
  1112. font-size: 24rpx;
  1113. color: #999999;
  1114. }
  1115. }
  1116. .driver-option {
  1117. display: flex;
  1118. .call,
  1119. .customer {
  1120. width: 60rpx;
  1121. height: 60rpx;
  1122. margin-left: 20rpx;
  1123. image {
  1124. height: 100%;
  1125. width: 100%;
  1126. }
  1127. }
  1128. }
  1129. }
  1130. }
  1131. }
  1132. .order-operation {
  1133. background: #F9F9F9;
  1134. border-radius: 20rpx;
  1135. height: 424rpx;
  1136. padding: 28rpx 24rpx;
  1137. .desc {
  1138. display: flex;
  1139. justify-content: space-between;
  1140. align-items: center;
  1141. .title {
  1142. display: flex;
  1143. flex-direction: column;
  1144. .desc-title {
  1145. font-size: 36rpx;
  1146. color: #222222;
  1147. font-weight: bold;
  1148. }
  1149. .desc-subtitle {
  1150. font-size: 24rpx;
  1151. color: #222222;
  1152. margin-top: 24rpx;
  1153. }
  1154. }
  1155. .car-img {
  1156. width: 234rpx;
  1157. height: 122rpx;
  1158. image {
  1159. width: 100%;
  1160. height: 100%;
  1161. }
  1162. }
  1163. }
  1164. .driver-card {
  1165. background: #FFFFFF;
  1166. margin-top: 22rpx;
  1167. padding: 28rpx 22rpx;
  1168. border-radius: 20rpx;
  1169. .driver {
  1170. display: flex;
  1171. .driver-avatar {
  1172. height: 100rpx;
  1173. width: 100rpx;
  1174. }
  1175. .driver-info {
  1176. flex: 1;
  1177. margin-left: 20rpx;
  1178. display: flex;
  1179. flex-direction: column;
  1180. justify-content: space-between;
  1181. .driver-name {
  1182. font-size: 32rpx;
  1183. color: #222222;
  1184. font-weight: bold;
  1185. }
  1186. .driver-car {
  1187. font-size: 24rpx;
  1188. color: #999999;
  1189. }
  1190. }
  1191. .driver-option {
  1192. display: flex;
  1193. .call,
  1194. .customer {
  1195. width: 60rpx;
  1196. height: 60rpx;
  1197. margin-left: 20rpx;
  1198. image {
  1199. height: 100%;
  1200. width: 100%;
  1201. }
  1202. }
  1203. }
  1204. }
  1205. .price-box {
  1206. display: flex;
  1207. justify-content: flex-end;
  1208. margin-top: 20rpx;
  1209. padding-top: 28rpx;
  1210. border-top: 1px solid #F0F0F0;
  1211. .price {
  1212. font-size: 32rpx;
  1213. color: #FF4A39;
  1214. font-weight: bold;
  1215. margin-right: 40%;
  1216. }
  1217. .jiantou {
  1218. width: 20rpx;
  1219. height: 20rpx;
  1220. image {
  1221. height: 100%;
  1222. width: 100%;
  1223. }
  1224. }
  1225. }
  1226. }
  1227. }
  1228. .charging-box {
  1229. width: 100%;
  1230. height: 100%;
  1231. background: linear-gradient(180deg, #FF7365 0%, #F9F9F9 70%, #FFF 100%);
  1232. border-radius: 40rpx 40rpx 0rpx 0rpx;
  1233. box-sizing: border-box;
  1234. padding: 40rpx 32rpx;
  1235. .box {
  1236. padding: 30rpx;
  1237. background: #fff;
  1238. border-radius: 20rpx 20rpx 20rpx 20rpx;
  1239. .item {
  1240. font-weight: bold;
  1241. color: #222222;
  1242. font-size: 28rpx;
  1243. position: relative;
  1244. // padding: 14rpx 0;
  1245. line-height: 70rpx;
  1246. height: 70rpx;
  1247. padding-left: 32rpx;
  1248. .jiantou {
  1249. width: 20rpx;
  1250. height: 20rpx;
  1251. position: absolute;
  1252. top: 50%;
  1253. right: 0%;
  1254. transform: translateY(-50%);
  1255. }
  1256. &::before {
  1257. content: '';
  1258. position: absolute;
  1259. top: 50%;
  1260. left: 0;
  1261. transform: translateY(-50%);
  1262. width: 16rpx;
  1263. height: 16rpx;
  1264. border-radius: 50%;
  1265. background: #07AC82;
  1266. }
  1267. }
  1268. .end.item {
  1269. border-bottom: 2rpx solid #F0F0F0;
  1270. &::before {
  1271. background: #FF4A39;
  1272. }
  1273. }
  1274. .price {
  1275. font-size: 28rpx;
  1276. color: #FF4A39;
  1277. margin: 22rpx auto 0;
  1278. text-align: center;
  1279. position: relative;
  1280. .num {
  1281. font-weight: bold;
  1282. font-size: 30rpx;
  1283. }
  1284. .jiantou {
  1285. width: 20rpx;
  1286. height: 20rpx;
  1287. position: absolute;
  1288. top: 50%;
  1289. right: 0%;
  1290. transform: translateY(-50%);
  1291. }
  1292. }
  1293. }
  1294. .btn {
  1295. width: 100%;
  1296. line-height: 80rpx;
  1297. text-align: center;
  1298. background: #FF4A39;
  1299. border-radius: 40rpx 40rpx 40rpx 40rpx;
  1300. margin-top: 28rpx;
  1301. font-weight: bold;
  1302. color: #FFFFFF;
  1303. font-size: 28rpx;
  1304. }
  1305. }
  1306. }
  1307. }
  1308. </style>