index.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493
  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. cancelText: '下次再说',
  740. confirmText: '立即开通',
  741. success(res) {
  742. console.log(res)
  743. if (res.confirm) {
  744. uni.navigateTo({
  745. url: '/my/memberCenter/index'
  746. })
  747. }
  748. if (res.cancel) {
  749. uni.navigateBack()
  750. }
  751. }
  752. })
  753. }
  754. } else {
  755. uni.showModal({
  756. title: '请登录',
  757. confirmText: '去登录',
  758. success(res) {
  759. console.log(res);
  760. if (res.confirm) {
  761. uni.navigateTo({
  762. url: `/login/login/login?redirect=/trip/index/index`
  763. })
  764. }
  765. }
  766. })
  767. }
  768. }
  769. }
  770. </script>
  771. <style lang="scss" scoped>
  772. .trip {
  773. display: flex;
  774. flex-direction: column;
  775. height: 78vh;
  776. .map {
  777. height: 70vh;
  778. flex: 1;
  779. position: relative;
  780. .current {
  781. position: absolute;
  782. left: 50%;
  783. top: 50%;
  784. transform: translate(-50%, calc(-50% - 40rpx));
  785. width: 40rpx;
  786. height: 68rpx;
  787. }
  788. .btn {
  789. position: absolute;
  790. bottom: 20%;
  791. right: 20rpx;
  792. width: 60rpx;
  793. height: 60rpx;
  794. }
  795. }
  796. .content {
  797. width: 100%;
  798. height: 530rpx;
  799. border-radius: 16rpx 16rpx 0 0;
  800. background-color: transparent;
  801. position: absolute;
  802. bottom: 0;
  803. .img {
  804. height: 180rpx;
  805. width: 100%;
  806. margin-top: -60rpx;
  807. }
  808. .operation {
  809. width: 100%;
  810. height: 424rpx;
  811. padding: 28rpx 24rpx;
  812. background: #FFFFFF;
  813. border-radius: 20rpx 20rpx 20rpx 20rpx;
  814. position: absolute;
  815. bottom: 0rpx;
  816. left: 50%;
  817. transform: translateX(-50%);
  818. box-sizing: border-box;
  819. display: flex;
  820. flex-direction: column;
  821. align-items: center;
  822. .start-box {
  823. display: flex;
  824. align-items: center;
  825. justify-content: space-between;
  826. margin: 0 52rpx;
  827. width: 100%;
  828. .start {
  829. font-weight: bold;
  830. color: #222222;
  831. font-size: 28rpx;
  832. display: flex;
  833. align-items: center;
  834. .point {
  835. width: 16rpx;
  836. height: 16rpx;
  837. background: #07AC82;
  838. margin-left: 24rpx;
  839. margin-right: 20rpx;
  840. border-radius: 50%;
  841. }
  842. .green {
  843. color: #07AC82;
  844. max-width: 424rpx;
  845. white-space: nowrap;
  846. overflow: hidden;
  847. text-overflow: ellipsis;
  848. display: inline-block;
  849. }
  850. }
  851. .jiantou {
  852. float: right;
  853. width: 20rpx;
  854. height: 20rpx;
  855. }
  856. }
  857. .end {
  858. display: flex;
  859. align-items: center;
  860. width: 100%;
  861. height: 116rpx;
  862. line-height: 116rpx;
  863. text-indent: 36rpx;
  864. background: #F0F0F0;
  865. border-radius: 16rpx 16rpx 16rpx 16rpx;
  866. font-weight: bold;
  867. color: #222222;
  868. font-size: 40rpx;
  869. margin-top: 28rpx;
  870. margin-bottom: 24rpx;
  871. .point {
  872. margin: 0 20rpx 0 24rpx;
  873. width: 16rpx;
  874. height: 16rpx;
  875. background: #FF4A39;
  876. border-radius: 50%;
  877. }
  878. .place {
  879. width: 90%;
  880. text-indent: 0;
  881. word-break: break-all;
  882. // 超出部分变成...
  883. display: -webkit-box;
  884. -webkit-box-orient: vertical;
  885. -webkit-line-clamp: 1;
  886. overflow: hidden;
  887. text-overflow: ellipsis;
  888. }
  889. }
  890. .btn {
  891. width: 100%;
  892. line-height: 80rpx;
  893. text-align: center;
  894. // background: #;
  895. border-radius: 40rpx 40rpx 40rpx 40rpx;
  896. margin-top: 28rpx;
  897. font-weight: bold;
  898. color: #FFFFFF;
  899. font-size: 28rpx;
  900. }
  901. }
  902. .call-operation {
  903. width: 100%;
  904. height: 538rpx;
  905. padding: 28rpx 24rpx;
  906. background: #FFFFFF;
  907. border-radius: 20rpx;
  908. position: absolute;
  909. bottom: 0rpx;
  910. left: 50%;
  911. transform: translateX(-50%);
  912. box-sizing: border-box;
  913. .call-img {
  914. width: 266rpx;
  915. height: 266rpx;
  916. margin: 0 auto;
  917. image {
  918. width: 100%;
  919. height: 100%;
  920. }
  921. }
  922. .title {
  923. font-size: 36rpx;
  924. color: #222222;
  925. font-weight: bold;
  926. margin-bottom: 10rpx;
  927. // text-align: left;
  928. }
  929. .call-btn {
  930. width: 344rpx;
  931. margin: 0 auto;
  932. }
  933. }
  934. .driver-operation {
  935. background: #F9F9F9;
  936. border-radius: 20rpx;
  937. height: 526rpx;
  938. padding: 28rpx 24rpx;
  939. .desc {
  940. display: flex;
  941. justify-content: space-between;
  942. align-items: center;
  943. .title {
  944. display: flex;
  945. flex-direction: column;
  946. .desc-title {
  947. font-size: 36rpx;
  948. color: #222222;
  949. font-weight: bold;
  950. }
  951. .desc-subtitle {
  952. font-size: 24rpx;
  953. color: #222222;
  954. margin-top: 24rpx;
  955. }
  956. }
  957. .car-img {
  958. width: 234rpx;
  959. height: 122rpx;
  960. image {
  961. width: 100%;
  962. height: 100%;
  963. }
  964. }
  965. }
  966. .driver-card {
  967. background: #FFFFFF;
  968. margin-top: 22rpx;
  969. padding: 28rpx 22rpx;
  970. border-radius: 20rpx;
  971. .driver {
  972. display: flex;
  973. .driver-avatar {
  974. height: 100rpx;
  975. width: 100rpx;
  976. }
  977. .driver-info {
  978. flex: 1;
  979. margin-left: 20rpx;
  980. display: flex;
  981. flex-direction: column;
  982. justify-content: space-between;
  983. .driver-name {
  984. font-size: 32rpx;
  985. color: #222222;
  986. font-weight: bold;
  987. }
  988. .driver-car {
  989. font-size: 24rpx;
  990. color: #999999;
  991. }
  992. }
  993. .driver-option {
  994. display: flex;
  995. .call,
  996. .customer {
  997. width: 60rpx;
  998. height: 60rpx;
  999. margin-left: 20rpx;
  1000. image {
  1001. height: 100%;
  1002. width: 100%;
  1003. }
  1004. }
  1005. }
  1006. }
  1007. .price-box {
  1008. display: flex;
  1009. justify-content: flex-end;
  1010. margin-top: 20rpx;
  1011. padding-top: 28rpx;
  1012. border-top: 1px solid #F0F0F0;
  1013. .price {
  1014. font-size: 32rpx;
  1015. color: #FF4A39;
  1016. font-weight: bold;
  1017. margin-right: 40%;
  1018. }
  1019. .jiantou {
  1020. width: 20rpx;
  1021. height: 20rpx;
  1022. image {
  1023. height: 100%;
  1024. width: 100%;
  1025. }
  1026. }
  1027. }
  1028. }
  1029. }
  1030. .drivering-operation {
  1031. background: #F9F9F9;
  1032. border-radius: 20rpx;
  1033. height: 416rpx;
  1034. padding: 28rpx 24rpx;
  1035. .desc {
  1036. display: flex;
  1037. justify-content: space-between;
  1038. align-items: center;
  1039. .title {
  1040. display: flex;
  1041. flex-direction: column;
  1042. .desc-title {
  1043. font-size: 36rpx;
  1044. color: #222222;
  1045. font-weight: bold;
  1046. }
  1047. .desc-subtitle {
  1048. font-size: 24rpx;
  1049. color: #222222;
  1050. margin-top: 24rpx;
  1051. }
  1052. }
  1053. .car-img {
  1054. width: 234rpx;
  1055. height: 122rpx;
  1056. image {
  1057. width: 100%;
  1058. height: 100%;
  1059. }
  1060. }
  1061. }
  1062. .driver-card {
  1063. background: #FFFFFF;
  1064. margin-top: 22rpx;
  1065. padding: 28rpx 22rpx;
  1066. border-radius: 20rpx;
  1067. .driver {
  1068. display: flex;
  1069. .driver-avatar {
  1070. height: 100rpx;
  1071. width: 100rpx;
  1072. }
  1073. .driver-info {
  1074. flex: 1;
  1075. margin-left: 20rpx;
  1076. display: flex;
  1077. flex-direction: column;
  1078. justify-content: space-between;
  1079. .driver-name {
  1080. font-size: 32rpx;
  1081. color: #222222;
  1082. font-weight: bold;
  1083. }
  1084. .driver-car {
  1085. font-size: 24rpx;
  1086. color: #999999;
  1087. }
  1088. }
  1089. .driver-option {
  1090. display: flex;
  1091. .call,
  1092. .customer {
  1093. width: 60rpx;
  1094. height: 60rpx;
  1095. margin-left: 20rpx;
  1096. image {
  1097. height: 100%;
  1098. width: 100%;
  1099. }
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. .await-operation {
  1106. background: #F9F9F9;
  1107. border-radius: 20rpx;
  1108. height: 424rpx;
  1109. padding: 28rpx 24rpx;
  1110. .desc {
  1111. display: flex;
  1112. justify-content: space-between;
  1113. align-items: center;
  1114. .title {
  1115. display: flex;
  1116. flex-direction: column;
  1117. .desc-title {
  1118. font-size: 36rpx;
  1119. color: #222222;
  1120. font-weight: bold;
  1121. }
  1122. .desc-subtitle {
  1123. font-size: 24rpx;
  1124. color: #222222;
  1125. margin-top: 24rpx;
  1126. }
  1127. }
  1128. .car-img {
  1129. width: 234rpx;
  1130. height: 122rpx;
  1131. image {
  1132. width: 100%;
  1133. height: 100%;
  1134. }
  1135. }
  1136. }
  1137. .driver-card {
  1138. background: #FFFFFF;
  1139. margin-top: 22rpx;
  1140. padding: 28rpx 22rpx;
  1141. border-radius: 20rpx;
  1142. .driver {
  1143. display: flex;
  1144. .driver-avatar {
  1145. height: 100rpx;
  1146. width: 100rpx;
  1147. }
  1148. .driver-info {
  1149. flex: 1;
  1150. margin-left: 20rpx;
  1151. display: flex;
  1152. flex-direction: column;
  1153. justify-content: space-between;
  1154. .driver-name {
  1155. font-size: 32rpx;
  1156. color: #222222;
  1157. font-weight: bold;
  1158. }
  1159. .driver-car {
  1160. font-size: 24rpx;
  1161. color: #999999;
  1162. }
  1163. }
  1164. .driver-option {
  1165. display: flex;
  1166. .call,
  1167. .customer {
  1168. width: 60rpx;
  1169. height: 60rpx;
  1170. margin-left: 20rpx;
  1171. image {
  1172. height: 100%;
  1173. width: 100%;
  1174. }
  1175. }
  1176. }
  1177. }
  1178. }
  1179. }
  1180. .order-operation {
  1181. background: #F9F9F9;
  1182. border-radius: 20rpx;
  1183. height: 424rpx;
  1184. padding: 28rpx 24rpx;
  1185. .desc {
  1186. display: flex;
  1187. justify-content: space-between;
  1188. align-items: center;
  1189. .title {
  1190. display: flex;
  1191. flex-direction: column;
  1192. .desc-title {
  1193. font-size: 36rpx;
  1194. color: #222222;
  1195. font-weight: bold;
  1196. }
  1197. .desc-subtitle {
  1198. font-size: 24rpx;
  1199. color: #222222;
  1200. margin-top: 24rpx;
  1201. }
  1202. }
  1203. .car-img {
  1204. width: 234rpx;
  1205. height: 122rpx;
  1206. image {
  1207. width: 100%;
  1208. height: 100%;
  1209. }
  1210. }
  1211. }
  1212. .driver-card {
  1213. background: #FFFFFF;
  1214. margin-top: 22rpx;
  1215. padding: 28rpx 22rpx;
  1216. border-radius: 20rpx;
  1217. .driver {
  1218. display: flex;
  1219. .driver-avatar {
  1220. height: 100rpx;
  1221. width: 100rpx;
  1222. }
  1223. .driver-info {
  1224. flex: 1;
  1225. margin-left: 20rpx;
  1226. display: flex;
  1227. flex-direction: column;
  1228. justify-content: space-between;
  1229. .driver-name {
  1230. font-size: 32rpx;
  1231. color: #222222;
  1232. font-weight: bold;
  1233. }
  1234. .driver-car {
  1235. font-size: 24rpx;
  1236. color: #999999;
  1237. }
  1238. }
  1239. .driver-option {
  1240. display: flex;
  1241. .call,
  1242. .customer {
  1243. width: 60rpx;
  1244. height: 60rpx;
  1245. margin-left: 20rpx;
  1246. image {
  1247. height: 100%;
  1248. width: 100%;
  1249. }
  1250. }
  1251. }
  1252. }
  1253. .price-box {
  1254. display: flex;
  1255. justify-content: flex-end;
  1256. margin-top: 20rpx;
  1257. padding-top: 28rpx;
  1258. border-top: 1px solid #F0F0F0;
  1259. .price {
  1260. font-size: 32rpx;
  1261. color: #FF4A39;
  1262. font-weight: bold;
  1263. margin-right: 40%;
  1264. }
  1265. .jiantou {
  1266. width: 20rpx;
  1267. height: 20rpx;
  1268. image {
  1269. height: 100%;
  1270. width: 100%;
  1271. }
  1272. }
  1273. }
  1274. }
  1275. }
  1276. .charging-box {
  1277. width: 100%;
  1278. height: 100%;
  1279. background: linear-gradient(180deg, #FF7365 0%, #F9F9F9 70%, #FFF 100%);
  1280. border-radius: 40rpx 40rpx 0rpx 0rpx;
  1281. box-sizing: border-box;
  1282. padding: 40rpx 32rpx;
  1283. .box {
  1284. padding: 30rpx;
  1285. background: #fff;
  1286. border-radius: 20rpx 20rpx 20rpx 20rpx;
  1287. .item {
  1288. font-weight: bold;
  1289. color: #222222;
  1290. font-size: 28rpx;
  1291. position: relative;
  1292. // padding: 14rpx 0;
  1293. line-height: 70rpx;
  1294. height: 70rpx;
  1295. padding-left: 32rpx;
  1296. .jiantou {
  1297. width: 20rpx;
  1298. height: 20rpx;
  1299. position: absolute;
  1300. top: 50%;
  1301. right: 0%;
  1302. transform: translateY(-50%);
  1303. }
  1304. &::before {
  1305. content: '';
  1306. position: absolute;
  1307. top: 50%;
  1308. left: 0;
  1309. transform: translateY(-50%);
  1310. width: 16rpx;
  1311. height: 16rpx;
  1312. border-radius: 50%;
  1313. background: #07AC82;
  1314. }
  1315. }
  1316. .end.item {
  1317. border-bottom: 2rpx solid #F0F0F0;
  1318. &::before {
  1319. background: #FF4A39;
  1320. }
  1321. }
  1322. .price {
  1323. font-size: 28rpx;
  1324. color: #FF4A39;
  1325. margin: 22rpx auto 0;
  1326. text-align: center;
  1327. position: relative;
  1328. .num {
  1329. font-weight: bold;
  1330. font-size: 30rpx;
  1331. }
  1332. .jiantou {
  1333. width: 20rpx;
  1334. height: 20rpx;
  1335. position: absolute;
  1336. top: 50%;
  1337. right: 0%;
  1338. transform: translateY(-50%);
  1339. }
  1340. }
  1341. }
  1342. .btn {
  1343. width: 100%;
  1344. line-height: 80rpx;
  1345. text-align: center;
  1346. background: #FF4A39;
  1347. border-radius: 40rpx 40rpx 40rpx 40rpx;
  1348. margin-top: 28rpx;
  1349. font-weight: bold;
  1350. color: #FFFFFF;
  1351. font-size: 28rpx;
  1352. }
  1353. }
  1354. }
  1355. }
  1356. </style>