index.vue 34 KB

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