index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  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://file.qxtech.top/${driver.driverAvatar}-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">
  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">
  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://file.qxtech.top/${driver.driverAvatar}-200.jpg`">
  120. </u-avatar>
  121. </view>
  122. <view class="driver-info">
  123. <view class="driver-name">{{ driver.driverName || '王师傅 编号D1002' }}</view>
  124. <view class="driver-car">秋香代驾</view>
  125. </view>
  126. <view class="driver-option">
  127. <view class="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">
  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://file.qxtech.top/${driver.driverAvatar}-200.jpg`">
  164. </u-avatar>
  165. </view>
  166. <view class="driver-info">
  167. <view class="driver-name">{{ driver.driverName || '王师傅 编号D1002' }}</view>
  168. <view class="driver-car">秋香代驾</view>
  169. </view>
  170. <view class="driver-option">
  171. <view class="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">
  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://file.qxtech.top/${driver.driverAvatar}-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">
  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. },
  666. computed: {
  667. formatTimer() {
  668. return `${this.minutes.toString().padStart(2, '0')}:${this.seconds.toString().padStart(2, '0')}`;
  669. }
  670. },
  671. onReady() {
  672. this.map = uni.createMapContext('Map', this)
  673. // 如果start 有值则不进行初始化
  674. },
  675. onLoad(option) {
  676. let that = this
  677. // 获取地址选择页面传来的数据
  678. const eventChannel = this.getOpenerEventChannel();
  679. if (JSON.stringify(eventChannel) !== '{}') {
  680. eventChannel.on('address', function (data) {
  681. if (uni.getStorageSync('form')) {
  682. that.form = JSON.parse(uni.getStorageSync('form'))
  683. }
  684. that.form[option.type] = data.address
  685. that.latitude = data.latitude
  686. that.longitude = data.longitude
  687. that.form[option.type + 'Location'].lat = data.latitude
  688. that.form[option.type + 'Location'].lng = data.longitude
  689. // 如果起点和终点都设置,绘制出路线
  690. if (that.form.start && that.form.end) {
  691. that.go()
  692. }
  693. })
  694. }
  695. if (option.type !== 'start') {
  696. this.initPosition()
  697. }
  698. // 读取是否存在进行中的订单
  699. const tripId = uni.getStorageSync('tripId');
  700. if (tripId.length > 1) {
  701. uni.showLoading({
  702. title: '加载订单中...'
  703. });
  704. this.hangupObj.queryId = tripId;
  705. if (uni.getStorageSync('form')) {
  706. that.form = JSON.parse(uni.getStorageSync('form'))
  707. }
  708. uni.hideLoading();
  709. this.startTimer();
  710. }
  711. },
  712. created() {
  713. }
  714. }
  715. </script>
  716. <style lang="scss" scoped>
  717. .trip {
  718. display: flex;
  719. flex-direction: column;
  720. height: 78vh;
  721. .map {
  722. height: 70vh;
  723. flex: 1;
  724. position: relative;
  725. .current {
  726. position: absolute;
  727. left: 50%;
  728. top: 50%;
  729. transform: translate(-50%, calc(-50% - 40rpx));
  730. width: 40rpx;
  731. height: 68rpx;
  732. }
  733. .btn {
  734. position: absolute;
  735. bottom: 20%;
  736. right: 20rpx;
  737. width: 60rpx;
  738. height: 60rpx;
  739. }
  740. }
  741. .content {
  742. width: 100%;
  743. height: 530rpx;
  744. border-radius: 16rpx 16rpx 0 0;
  745. background-color: transparent;
  746. position: absolute;
  747. bottom: 0;
  748. .img {
  749. height: 180rpx;
  750. width: 100%;
  751. margin-top: -60rpx;
  752. }
  753. .operation {
  754. width: 100%;
  755. height: 424rpx;
  756. padding: 28rpx 24rpx;
  757. background: #FFFFFF;
  758. border-radius: 20rpx 20rpx 20rpx 20rpx;
  759. position: absolute;
  760. bottom: 0rpx;
  761. left: 50%;
  762. transform: translateX(-50%);
  763. box-sizing: border-box;
  764. display: flex;
  765. flex-direction: column;
  766. align-items: center;
  767. .start-box {
  768. display: flex;
  769. align-items: center;
  770. justify-content: space-between;
  771. margin: 0 52rpx;
  772. width: 100%;
  773. .start {
  774. font-weight: bold;
  775. color: #222222;
  776. font-size: 28rpx;
  777. display: flex;
  778. align-items: center;
  779. .point {
  780. width: 16rpx;
  781. height: 16rpx;
  782. background: #07AC82;
  783. margin-left: 24rpx;
  784. margin-right: 20rpx;
  785. border-radius: 50%;
  786. }
  787. .green {
  788. color: #07AC82;
  789. max-width: 424rpx;
  790. white-space: nowrap;
  791. overflow: hidden;
  792. text-overflow: ellipsis;
  793. display: inline-block;
  794. }
  795. }
  796. .jiantou {
  797. float: right;
  798. width: 20rpx;
  799. height: 20rpx;
  800. }
  801. }
  802. .end {
  803. display: flex;
  804. align-items: center;
  805. width: 100%;
  806. height: 116rpx;
  807. line-height: 116rpx;
  808. text-indent: 36rpx;
  809. background: #F0F0F0;
  810. border-radius: 16rpx 16rpx 16rpx 16rpx;
  811. font-weight: bold;
  812. color: #222222;
  813. font-size: 40rpx;
  814. margin-top: 28rpx;
  815. margin-bottom: 24rpx;
  816. .point {
  817. margin: 0 20rpx 0 24rpx;
  818. width: 16rpx;
  819. height: 16rpx;
  820. background: #FF4A39;
  821. border-radius: 50%;
  822. }
  823. }
  824. .btn {
  825. width: 100%;
  826. line-height: 80rpx;
  827. text-align: center;
  828. // background: #;
  829. border-radius: 40rpx 40rpx 40rpx 40rpx;
  830. margin-top: 28rpx;
  831. font-weight: bold;
  832. color: #FFFFFF;
  833. font-size: 28rpx;
  834. }
  835. }
  836. .call-operation {
  837. width: 100%;
  838. height: 538rpx;
  839. padding: 28rpx 24rpx;
  840. background: #FFFFFF;
  841. border-radius: 20rpx;
  842. position: absolute;
  843. bottom: 0rpx;
  844. left: 50%;
  845. transform: translateX(-50%);
  846. box-sizing: border-box;
  847. .call-img {
  848. width: 266rpx;
  849. height: 266rpx;
  850. margin: 0 auto;
  851. image {
  852. width: 100%;
  853. height: 100%;
  854. }
  855. }
  856. .title {
  857. font-size: 36rpx;
  858. color: #222222;
  859. font-weight: bold;
  860. margin-bottom: 10rpx;
  861. // text-align: left;
  862. }
  863. .call-btn {
  864. width: 344rpx;
  865. margin: 0 auto;
  866. }
  867. }
  868. .driver-operation {
  869. background: #F9F9F9;
  870. border-radius: 20rpx;
  871. height: 526rpx;
  872. padding: 28rpx 24rpx;
  873. .desc {
  874. display: flex;
  875. justify-content: space-between;
  876. align-items: center;
  877. .title {
  878. display: flex;
  879. flex-direction: column;
  880. .desc-title {
  881. font-size: 36rpx;
  882. color: #222222;
  883. font-weight: bold;
  884. }
  885. .desc-subtitle {
  886. font-size: 24rpx;
  887. color: #222222;
  888. margin-top: 24rpx;
  889. }
  890. }
  891. .car-img {
  892. width: 234rpx;
  893. height: 122rpx;
  894. image {
  895. width: 100%;
  896. height: 100%;
  897. }
  898. }
  899. }
  900. .driver-card {
  901. background: #FFFFFF;
  902. margin-top: 22rpx;
  903. padding: 28rpx 22rpx;
  904. border-radius: 20rpx;
  905. .driver {
  906. display: flex;
  907. .driver-avatar {
  908. height: 100rpx;
  909. width: 100rpx;
  910. }
  911. .driver-info {
  912. flex: 1;
  913. margin-left: 20rpx;
  914. display: flex;
  915. flex-direction: column;
  916. justify-content: space-between;
  917. .driver-name {
  918. font-size: 32rpx;
  919. color: #222222;
  920. font-weight: bold;
  921. }
  922. .driver-car {
  923. font-size: 24rpx;
  924. color: #999999;
  925. }
  926. }
  927. .driver-option {
  928. display: flex;
  929. .call,
  930. .customer {
  931. width: 60rpx;
  932. height: 60rpx;
  933. margin-left: 20rpx;
  934. image {
  935. height: 100%;
  936. width: 100%;
  937. }
  938. }
  939. }
  940. }
  941. .price-box {
  942. display: flex;
  943. justify-content: flex-end;
  944. margin-top: 20rpx;
  945. padding-top: 28rpx;
  946. border-top: 1px solid #F0F0F0;
  947. .price {
  948. font-size: 32rpx;
  949. color: #FF4A39;
  950. font-weight: bold;
  951. margin-right: 40%;
  952. }
  953. .jiantou {
  954. width: 20rpx;
  955. height: 20rpx;
  956. image {
  957. height: 100%;
  958. width: 100%;
  959. }
  960. }
  961. }
  962. }
  963. }
  964. .drivering-operation {
  965. background: #F9F9F9;
  966. border-radius: 20rpx;
  967. height: 416rpx;
  968. padding: 28rpx 24rpx;
  969. .desc {
  970. display: flex;
  971. justify-content: space-between;
  972. align-items: center;
  973. .title {
  974. display: flex;
  975. flex-direction: column;
  976. .desc-title {
  977. font-size: 36rpx;
  978. color: #222222;
  979. font-weight: bold;
  980. }
  981. .desc-subtitle {
  982. font-size: 24rpx;
  983. color: #222222;
  984. margin-top: 24rpx;
  985. }
  986. }
  987. .car-img {
  988. width: 234rpx;
  989. height: 122rpx;
  990. image {
  991. width: 100%;
  992. height: 100%;
  993. }
  994. }
  995. }
  996. .driver-card {
  997. background: #FFFFFF;
  998. margin-top: 22rpx;
  999. padding: 28rpx 22rpx;
  1000. border-radius: 20rpx;
  1001. .driver {
  1002. display: flex;
  1003. .driver-avatar {
  1004. height: 100rpx;
  1005. width: 100rpx;
  1006. }
  1007. .driver-info {
  1008. flex: 1;
  1009. margin-left: 20rpx;
  1010. display: flex;
  1011. flex-direction: column;
  1012. justify-content: space-between;
  1013. .driver-name {
  1014. font-size: 32rpx;
  1015. color: #222222;
  1016. font-weight: bold;
  1017. }
  1018. .driver-car {
  1019. font-size: 24rpx;
  1020. color: #999999;
  1021. }
  1022. }
  1023. .driver-option {
  1024. display: flex;
  1025. .call,
  1026. .customer {
  1027. width: 60rpx;
  1028. height: 60rpx;
  1029. margin-left: 20rpx;
  1030. image {
  1031. height: 100%;
  1032. width: 100%;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. }
  1038. }
  1039. .await-operation {
  1040. background: #F9F9F9;
  1041. border-radius: 20rpx;
  1042. height: 424rpx;
  1043. padding: 28rpx 24rpx;
  1044. .desc {
  1045. display: flex;
  1046. justify-content: space-between;
  1047. align-items: center;
  1048. .title {
  1049. display: flex;
  1050. flex-direction: column;
  1051. .desc-title {
  1052. font-size: 36rpx;
  1053. color: #222222;
  1054. font-weight: bold;
  1055. }
  1056. .desc-subtitle {
  1057. font-size: 24rpx;
  1058. color: #222222;
  1059. margin-top: 24rpx;
  1060. }
  1061. }
  1062. .car-img {
  1063. width: 234rpx;
  1064. height: 122rpx;
  1065. image {
  1066. width: 100%;
  1067. height: 100%;
  1068. }
  1069. }
  1070. }
  1071. .driver-card {
  1072. background: #FFFFFF;
  1073. margin-top: 22rpx;
  1074. padding: 28rpx 22rpx;
  1075. border-radius: 20rpx;
  1076. .driver {
  1077. display: flex;
  1078. .driver-avatar {
  1079. height: 100rpx;
  1080. width: 100rpx;
  1081. }
  1082. .driver-info {
  1083. flex: 1;
  1084. margin-left: 20rpx;
  1085. display: flex;
  1086. flex-direction: column;
  1087. justify-content: space-between;
  1088. .driver-name {
  1089. font-size: 32rpx;
  1090. color: #222222;
  1091. font-weight: bold;
  1092. }
  1093. .driver-car {
  1094. font-size: 24rpx;
  1095. color: #999999;
  1096. }
  1097. }
  1098. .driver-option {
  1099. display: flex;
  1100. .call,
  1101. .customer {
  1102. width: 60rpx;
  1103. height: 60rpx;
  1104. margin-left: 20rpx;
  1105. image {
  1106. height: 100%;
  1107. width: 100%;
  1108. }
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. .order-operation {
  1115. background: #F9F9F9;
  1116. border-radius: 20rpx;
  1117. height: 424rpx;
  1118. padding: 28rpx 24rpx;
  1119. .desc {
  1120. display: flex;
  1121. justify-content: space-between;
  1122. align-items: center;
  1123. .title {
  1124. display: flex;
  1125. flex-direction: column;
  1126. .desc-title {
  1127. font-size: 36rpx;
  1128. color: #222222;
  1129. font-weight: bold;
  1130. }
  1131. .desc-subtitle {
  1132. font-size: 24rpx;
  1133. color: #222222;
  1134. margin-top: 24rpx;
  1135. }
  1136. }
  1137. .car-img {
  1138. width: 234rpx;
  1139. height: 122rpx;
  1140. image {
  1141. width: 100%;
  1142. height: 100%;
  1143. }
  1144. }
  1145. }
  1146. .driver-card {
  1147. background: #FFFFFF;
  1148. margin-top: 22rpx;
  1149. padding: 28rpx 22rpx;
  1150. border-radius: 20rpx;
  1151. .driver {
  1152. display: flex;
  1153. .driver-avatar {
  1154. height: 100rpx;
  1155. width: 100rpx;
  1156. }
  1157. .driver-info {
  1158. flex: 1;
  1159. margin-left: 20rpx;
  1160. display: flex;
  1161. flex-direction: column;
  1162. justify-content: space-between;
  1163. .driver-name {
  1164. font-size: 32rpx;
  1165. color: #222222;
  1166. font-weight: bold;
  1167. }
  1168. .driver-car {
  1169. font-size: 24rpx;
  1170. color: #999999;
  1171. }
  1172. }
  1173. .driver-option {
  1174. display: flex;
  1175. .call,
  1176. .customer {
  1177. width: 60rpx;
  1178. height: 60rpx;
  1179. margin-left: 20rpx;
  1180. image {
  1181. height: 100%;
  1182. width: 100%;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. .price-box {
  1188. display: flex;
  1189. justify-content: flex-end;
  1190. margin-top: 20rpx;
  1191. padding-top: 28rpx;
  1192. border-top: 1px solid #F0F0F0;
  1193. .price {
  1194. font-size: 32rpx;
  1195. color: #FF4A39;
  1196. font-weight: bold;
  1197. margin-right: 40%;
  1198. }
  1199. .jiantou {
  1200. width: 20rpx;
  1201. height: 20rpx;
  1202. image {
  1203. height: 100%;
  1204. width: 100%;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. }
  1210. .charging-box {
  1211. width: 100%;
  1212. height: 100%;
  1213. background: linear-gradient(180deg, #FF7365 0%, #F9F9F9 70%, #FFF 100%);
  1214. border-radius: 40rpx 40rpx 0rpx 0rpx;
  1215. box-sizing: border-box;
  1216. padding: 40rpx 32rpx;
  1217. .box {
  1218. padding: 30rpx;
  1219. background: #fff;
  1220. border-radius: 20rpx 20rpx 20rpx 20rpx;
  1221. .item {
  1222. font-weight: bold;
  1223. color: #222222;
  1224. font-size: 28rpx;
  1225. position: relative;
  1226. // padding: 14rpx 0;
  1227. line-height: 70rpx;
  1228. height: 70rpx;
  1229. padding-left: 32rpx;
  1230. .jiantou {
  1231. width: 20rpx;
  1232. height: 20rpx;
  1233. position: absolute;
  1234. top: 50%;
  1235. right: 0%;
  1236. transform: translateY(-50%);
  1237. }
  1238. &::before {
  1239. content: '';
  1240. position: absolute;
  1241. top: 50%;
  1242. left: 0;
  1243. transform: translateY(-50%);
  1244. width: 16rpx;
  1245. height: 16rpx;
  1246. border-radius: 50%;
  1247. background: #07AC82;
  1248. }
  1249. }
  1250. .end.item {
  1251. border-bottom: 2rpx solid #F0F0F0;
  1252. &::before {
  1253. background: #FF4A39;
  1254. }
  1255. }
  1256. .price {
  1257. font-size: 28rpx;
  1258. color: #FF4A39;
  1259. margin: 22rpx auto 0;
  1260. text-align: center;
  1261. position: relative;
  1262. .num {
  1263. font-weight: bold;
  1264. font-size: 30rpx;
  1265. }
  1266. .jiantou {
  1267. width: 20rpx;
  1268. height: 20rpx;
  1269. position: absolute;
  1270. top: 50%;
  1271. right: 0%;
  1272. transform: translateY(-50%);
  1273. }
  1274. }
  1275. }
  1276. .btn {
  1277. width: 100%;
  1278. line-height: 80rpx;
  1279. text-align: center;
  1280. background: #FF4A39;
  1281. border-radius: 40rpx 40rpx 40rpx 40rpx;
  1282. margin-top: 28rpx;
  1283. font-weight: bold;
  1284. color: #FFFFFF;
  1285. font-size: 28rpx;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. </style>