index.vue 33 KB

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