detail.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  1. <template>
  2. <view>
  3. <view class="map" v-if="[14,16,20,30].indexOf(orderDetail.status)>-1 && orderDetail.shippingType == 1">
  4. <map style="height: 600rpx;width:750rpx" show-location id="map" ref="map" :markers="markers" :polyline="polyline">
  5. </map>
  6. </view>
  7. <!-- 核销码显示区域 -->
  8. <view class="verification-code" v-if="orderDetail.status === 20 && orderDetail.shippingType == 2">
  9. <image :src="verificationCode" mode="widthFix" style="width: 300rpx; height: 300rpx"></image>
  10. <view class="code-text">核销码: {{verificationText}}</view>
  11. <view class="code-hint">请向店员出示此核销码</view>
  12. </view>
  13. <view class="state">
  14. <view class="state-text" v-if="orderDetail.status !== 10"
  15. :style="state == 5 || state == 8?'color:#1B1C33;font-size:20px':''">
  16. {{ orderDetail.orderType === 1 ? '(自提)' : '' }}{{ stateText }}
  17. </view>
  18. <view class="state-text" v-if="state === 0">
  19. {{'等待支付 剩余'+ num(minutes)}}:{{num(seconds)}}
  20. </view>
  21. <view class="state-timeText">
  22. {{state == 0?'逾期未支付将会自动取消':''}}
  23. {{ (state == 1 || state == 2)&& orderDetail.shippingType==1?'预约送达时间':''}}
  24. {{ (state == 1 || state == 2)&& orderDetail.shippingType==2?'预约取货时间':''}}
  25. {{state == 3 || state == 4?'订单已完成':''}}
  26. {{state == 5?'订单已取消':''}}
  27. {{state == 8?'订单已取消':''}}
  28. {{orderDetail.status == 12 ? '已拼单'+ orderDetail.groupShopVo.alreadyBuyNumber + '件' : ''}}
  29. <!-- {{orderDetail.status==80&&orderDetail.status==90?'订单已取消':orderDetail.status==10&&orderDetail.status==12?'逾期未支付将会自动取消':orderDetail.status==40&&orderDetail.status==50?'订单已送达':orderDetail.status==70?'订单已取消':'预约送达时间 '}} -->
  30. </view>
  31. <view class="state-time">
  32. {{ (state == 1 || state == 2)&& orderDetail.shippingType==1?orderDetail.predictTime:''}}
  33. {{ (state == 1 || state == 2)&& orderDetail.shippingType==2?orderDetail.predictTime.replaceAll('送达','取货'):''}}
  34. <!-- {{state == 3 || state == 4?'订单已完成':''}} -->
  35. {{state == 3 || state == 4 || state == 5 || state ==8? timeFormat(orderDetail.updateTime) :''}}
  36. {{orderDetail.status == 12 ? '拼团结束:'+ orderDetail.groupShopVo.endTime : ''}}
  37. </view>
  38. <view @click="refundOrder" class="state-btn state-btn-prohibit" v-if="state == 1 && !orderDetail.payIntegral"
  39. style="margin: 12px auto;">
  40. 申请退款
  41. </view>
  42. <view style="display: flex; justify-content: center; align-items: center; margin: 12px auto;" v-if="state == 3">
  43. <view @click="orderAfterSales" class="state-btn state-btn-prohibit" style="margin: 12px auto;">
  44. 申请售后
  45. </view>
  46. <view @click="appraiseOrder" class="state-btn" style="margin: 12px auto;">
  47. 立即评价
  48. </view>
  49. </view>
  50. <view @click="orderAfterSales" class="state-btn state-btn-prohibit" v-if="orderDetail.status == 50" style="margin: 12px auto;">
  51. 申请售后
  52. </view>
  53. <view v-if="orderDetail.status === 10" style="display: flex;justify-content: center;">
  54. <view open-type="contact" class="state-btn state-btn-prohibit" style="width: 69px;"
  55. @click="naviageToPage('pages/service/service')">
  56. <button open-type="contact" class="contact-btn">客服</button>
  57. </view>
  58. <view @click="cancelOrder" class="state-btn state-btn-prohibit">
  59. 取消订单
  60. </view>
  61. <view @click="confirm" class="state-btn state-btn-ac">
  62. 立即付款
  63. </view>
  64. </view>
  65. </view>
  66. <view class="goods">
  67. <view class="goods-one" v-for="(item, index) in orderDetail.productList" :key="index">
  68. <image class="goods-img" :src="JSON.parse(item.img)[0].url"></image>
  69. <view class="goods-text">
  70. <view class="goods-tag">
  71. <view class="goods-name">{{item.productTitle}}</view>
  72. <view class="goods-price">¥{{item.price}}</view>
  73. </view>
  74. <view class="goods-number">×{{item.num}}</view>
  75. </view>
  76. </view>
  77. <view v-if="orderDetail.couponPrice" class="yt-list-cell b-b">
  78. <text class="cell-tit clamp">
  79. 优惠券减
  80. </text>
  81. <text class="cell-tip red">
  82. -¥{{ orderDetail.couponPrice | priceFormat }}
  83. </text>
  84. </view>
  85. <view class="yt-list-cell b-b">
  86. <text class="cell-tit clamp" style="color: #333333;">配送费</text>
  87. <text class="cell-tip">{{orderDetail.freightPrice}}</text>
  88. </view>
  89. <view class="yt-list-cell b-b">
  90. <text class="cell-tit clamp" style="color: #333333;">合计</text>
  91. <text class="cell-tip" v-if="!orderDetail.payIntegral">¥{{orderDetail.payPrice}}</text>
  92. <text class="cell-tip" style="color: red" v-if="orderDetail.payIntegral">积分{{orderDetail.payIntegral}}</text>
  93. </view>
  94. </view>
  95. <!-- 配送信息 -->
  96. <view class="yt-list">
  97. <view class="yt-list-cell b-b">
  98. <text class="cell-tit clamp yt-list-title">配送信息</text>
  99. </view>
  100. <view class="yt-list-cell b-b">
  101. <text class="cell-tit clamp">联系地址</text>
  102. <text class="cell-tip">{{orderDetail.userAddress}}</text>
  103. </view>
  104. <view class="yt-list-cell b-b">
  105. <text class="cell-tit clamp">联系人 </text>
  106. <text class="cell-tip ">{{orderDetail.realName}}</text>
  107. </view>
  108. <view class="yt-list-cell b-b">
  109. <text class="cell-tit clamp">期望时间 </text>
  110. <text class="cell-tip ">{{orderDetail.predictTime}}</text>
  111. </view>
  112. </view>
  113. <!-- 支付信息 -->
  114. <view class="yt-list">
  115. <view class="yt-list-cell b-b">
  116. <text class="cell-tit clamp yt-list-title">支付信息</text>
  117. </view>
  118. <view class="yt-list-cell b-b">
  119. <text class="cell-tit clamp">订单号</text>
  120. <text class="cell-tip">{{orderDetail.orderId}}</text>
  121. </view>
  122. <view class="yt-list-cell b-b">
  123. <text class="cell-tit clamp">备注信息 </text>
  124. <text class="cell-tip ">{{orderDetail.remark}}</text>
  125. </view>
  126. <view class="yt-list-cell b-b">
  127. <text class="cell-tit clamp">支付方式 </text>
  128. <text class="cell-tip ">{{showPayment(orderDetail.payChannel)}}</text>
  129. </view>
  130. <view class="yt-list-cell b-b">
  131. <text class="cell-tit clamp">下单时间 </text>
  132. <text class="cell-tip ">{{timeFormat(orderDetail.createTime)}}</text>
  133. </view>
  134. <view v-if="orderDetail.payTime" class="yt-list-cell b-b">
  135. <text class="cell-tit clamp">支付时间 </text>
  136. <text class="cell-tip ">{{timeFormat(orderDetail.payTime)}}</text>
  137. </view>
  138. </view>
  139. <!-- 底部 -->
  140. <!-- <view class="footer">
  141. <view class="price-content">
  142. <text>实付款</text>
  143. <text class="price-tip">¥</text>
  144. <text class="price">{{orderDetail.actualPrice | priceFormat}}</text>
  145. </view>
  146. <text class="submit" @click="submit">提交订单</text>
  147. </view> -->
  148. </view>
  149. </template>
  150. <script>
  151. let riderTimer = null,
  152. timerInterval = null, // 添加定时器引用
  153. mapContext = null,
  154. riderLastLocation = null
  155. export default {
  156. filters: {
  157. priceFormat(price) {
  158. return price
  159. },
  160. dateFormat(time) {
  161. return 'temp'
  162. //return formatDate(new Date(time),'yyyy-MM-dd HH:mm')
  163. }
  164. },
  165. data() {
  166. return {
  167. verificationCode: '', // 核销码图片
  168. verificationText: '', // 核销码文本
  169. timeing: '2020-03-01 13:45',
  170. minutes: 0,
  171. seconds: 0,
  172. Total: 0,
  173. distributionFee: 123, //配送费
  174. // 配送信息
  175. DisInformation: {
  176. address: '广东省深证市中山大道1号星汇维港购物',
  177. contacts: '17671467812',
  178. expectedTime: '9月21日 13:20'
  179. },
  180. // 支付信息
  181. orderInformation: {
  182. orderNumber: '4567 8123 4567 890',
  183. information: '',
  184. paymentMethod: '微信支付',
  185. orderTime: '2018-04-28 13:58',
  186. paymentTime: '2018-04-28 13:58'
  187. },
  188. orderId: '',
  189. stateText: '', //状态文字说明
  190. orderDetail1: {
  191. skuList: [{
  192. img: 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3529759643,1765872423&fm=26&gp=0.jpg',
  193. name: '芥蓝',
  194. price: 10,
  195. number: '2'
  196. },
  197. {
  198. img: 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3529759643,1765872423&fm=26&gp=0.jpg',
  199. name: '芥蓝',
  200. price: 10,
  201. number: '2'
  202. }
  203. ],
  204. totalotPrice: 0,
  205. totalPrice: 0, //商品折扣(仅算VIP和限时打折)后总价
  206. coupon: undefined,
  207. mono: '',
  208. orderDetail: [],
  209. },
  210. orderDetail: {
  211. skuList: [],
  212. totalotPrice: 0,
  213. totalPrice: 0, //商品折扣(仅算VIP和限时打折)后总价
  214. coupon: undefined,
  215. mono: '',
  216. status: 20
  217. },
  218. statusMap: {
  219. 10: '未付款',
  220. 12: '等待团购活动结束',
  221. 14: '待配货',
  222. 16: '配货中',
  223. 20: '待出库',
  224. 30: '待收货',
  225. 32: '配送异常',
  226. 40: '待评价',
  227. 50: '已完成',
  228. 60: '退款中',
  229. 70: '已退款',
  230. 80: '已取消',
  231. 90: '已取消(系统)'
  232. },
  233. state: 4,
  234. markers: [{
  235. id: 1,
  236. longitude: null,
  237. latitude: null,
  238. iconPath: '../../static/icon/18.png',
  239. width: 40,
  240. height: 40
  241. },
  242. {
  243. id: 2,
  244. longitude: null,
  245. latitude: null,
  246. iconPath: '../../static/icon/08.png',
  247. width: 40,
  248. height: 40
  249. }
  250. ],
  251. polyline: []
  252. }
  253. },
  254. watch: {
  255. second: {
  256. handler(newVal) {
  257. this.num(newVal)
  258. }
  259. },
  260. minute: {
  261. handler(newVal) {
  262. this.num(newVal)
  263. }
  264. },
  265. },
  266. computed: {
  267. includePoints() {
  268. // return this.markers.map(({
  269. // latitude,
  270. // longitude
  271. // }) => {
  272. // return {
  273. // latitude,
  274. // longitude
  275. // }
  276. // })
  277. const {
  278. latitude,
  279. longitude
  280. } = this.markers[1]
  281. return [{
  282. latitude,
  283. longitude
  284. }]
  285. }
  286. },
  287. mounted() {
  288. const that = this
  289. uni.getLocation({
  290. success() {
  291. mapContext = uni.createMapContext('map', that)
  292. },
  293. fail(e) {
  294. uni.showModal({
  295. content: e
  296. })
  297. },
  298. complete() {
  299. that.loadData()
  300. }
  301. })
  302. },
  303. onLoad(option) {
  304. this.orderId = option.orderid
  305. },
  306. onUnload() {
  307. if (timerInterval) {
  308. clearInterval(timerInterval);
  309. timerInterval = null;
  310. }
  311. if (riderTimer) {
  312. clearTimeout(riderTimer)
  313. riderTimer = null
  314. }
  315. riderLastLocation = null
  316. },
  317. methods: {
  318. naviageToPage(page, title) {
  319. const that = this
  320. this.ismask = false
  321. if (title) {
  322. console.log(title, 'jinlai')
  323. title ? title : ''
  324. uni.navigateTo({
  325. url: page + '&title=' + title
  326. })
  327. } else {
  328. console.log(title)
  329. uni.navigateTo({
  330. url: page
  331. })
  332. }
  333. // console.log(that.categoryButtomList[index].title)
  334. },
  335. //申请退款
  336. //申请退款
  337. refundOrder() {
  338. const that = this
  339. uni.showModal({
  340. title: '申请退款',
  341. content: '请填写退款原因',
  342. editable: true, // 允许输入
  343. placeholderText: '请输入退款原因', // 输入框提示文字
  344. success: (e) => {
  345. if (e.confirm) {
  346. // 检查用户是否输入了退款原因
  347. if (!e.content || e.content.trim() === '') {
  348. that.$api.msg('请输入退款原因')
  349. return
  350. }
  351. // that.submiting = true
  352. that.$api.request('get', 'order/app/refund', {
  353. orderId: this.orderDetail.orderId,
  354. reason: e.content // 添加退款原因参数
  355. }, failres => {
  356. // that.submiting = false
  357. that.$api.msg(failres.msg)
  358. }).then(res => {
  359. that.loadData()
  360. // that.submiting = false
  361. // item.status = 80
  362. })
  363. }
  364. }
  365. })
  366. },
  367. //评价订单
  368. appraiseOrder() {
  369. uni.navigateTo({
  370. url: '/pages/order/appraise?orderid=' + this.orderDetail.id
  371. })
  372. },
  373. //申请售后
  374. orderAfterSales() {
  375. uni.navigateTo({
  376. url: "/pages/order/refund?id=" + this.orderDetail.id
  377. })
  378. },
  379. //取消订单
  380. cancelOrder(item) {
  381. const that = this
  382. uni.showModal({
  383. title: '取消?',
  384. content: '您确定要取消此订单吗?',
  385. success: (e) => {
  386. if (e.confirm) {
  387. // that.submiting = true
  388. that.$api.request('get', 'order/app/cancel', {
  389. orderId: this.orderDetail.orderId
  390. }, failres => {
  391. // that.submiting = false
  392. that.$api.msg(failres.msg)
  393. }).then(res => {
  394. that.loadData()
  395. // that.submiting = false
  396. // item.status = 80
  397. })
  398. }
  399. }
  400. })
  401. },
  402. // 倒计时
  403. num(n) {
  404. return n < 10 ? '0' + n : '' + n
  405. },
  406. timer() {
  407. var _this = this;
  408. this.countDown(); // 初始化倒计时
  409. // 清除之前的定时器
  410. if (this.timerInterval) {
  411. clearInterval(this.timerInterval);
  412. }
  413. this.timerInterval = setInterval(function() {
  414. if (_this.seconds === 0) {
  415. if (_this.minutes === 0) {
  416. clearInterval(_this.timerInterval);
  417. _this.autoCancelOrder(); // 时间到,自动取消订单
  418. return;
  419. }
  420. _this.minutes--;
  421. _this.seconds = 59;
  422. } else {
  423. _this.seconds--;
  424. }
  425. // 每分钟检查一次是否需要取消订单
  426. if (_this.seconds === 0 && _this.minutes % 1 === 0) {
  427. _this.countDown(); // 重新计算剩余时间,防止客户端时间不准
  428. }
  429. }, 1000);
  430. },
  431. sum() {
  432. var x = 0;
  433. for (var i = 0; i < this.orderDetail1.productList.length; ++i) {
  434. x += this.orderDetail1.productList[i].price;
  435. }
  436. console.log(x)
  437. this.Total = x
  438. },
  439. countDown() {
  440. const now = new Date().getTime();
  441. const createTime = new Date(this.orderDetail.createTime).getTime();
  442. const expireTime = createTime + (60000 * 15); // 15分钟后过期
  443. // 如果已经过期
  444. if (now >= expireTime) {
  445. this.minutes = 0;
  446. this.seconds = 0;
  447. this.autoCancelOrder(); // 自动取消订单
  448. return;
  449. }
  450. // 计算剩余时间
  451. const remainingTime = expireTime - now;
  452. this.minutes = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
  453. this.seconds = Math.floor((remainingTime % (1000 * 60)) / 1000);
  454. // 如果剩余时间小于等于0,自动取消订单
  455. if (remainingTime <= 0) {
  456. this.minutes = 0;
  457. this.seconds = 0;
  458. this.autoCancelOrder();
  459. }
  460. },
  461. // 自动取消订单
  462. autoCancelOrder() {
  463. const that = this;
  464. if (this.orderDetail.status === 10) { // 只有未支付订单才需要取消
  465. that.$api.request('get', 'order/app/cancel', {
  466. orderId: this.orderDetail.orderId
  467. }, failres => {
  468. that.$api.msg(failres.msg);
  469. }).then(res => {
  470. //页面重新加载
  471. that.loadData(); // 刷新页面数据
  472. uni.showToast({
  473. title: '订单已自动取消',
  474. icon: 'none'
  475. });
  476. });
  477. }
  478. },
  479. //获取订单详情
  480. loadData() {
  481. const that = this
  482. that.$api.request('get', 'order/app/getOrderDetail', {
  483. orderId: that.orderId
  484. }).then(res => {
  485. that.orderDetail = res.data
  486. that.markers[0].longitude = res.data.longitude
  487. that.markers[0].latitude = res.data.latitude
  488. mapContext.moveToLocation({
  489. longitude: res.data.longitude,
  490. latitude: res.data.latitude
  491. })
  492. // 如果是自提订单且状态为待取货,获取核销码
  493. if (res.data.status === 20 && res.data.shippingType === 2) {
  494. that.getVerificationCode()
  495. }
  496. if (that.orderDetail.status === 10) {
  497. this.state = 0
  498. this.stateText = '待支付'
  499. this.timer()
  500. this.countDown()
  501. }
  502. if (res.data.status === 12) {
  503. this.state = 10
  504. this.stateText = '等待团购活动结束'
  505. }
  506. if (res.data.status === 14 || res.data.status === 16) {
  507. this.state = 1
  508. this.stateText = '备货中'
  509. this.getRiderLocation(res.data.postId, res.data.id)
  510. }
  511. if (res.data.status === 20 && res.data.shippingType===1) {
  512. this.state = 1
  513. this.stateText = '待配送'
  514. this.getRiderLocation(res.data.postId, res.data.id)
  515. }
  516. if (res.data.status === 20 && res.data.shippingType===2) {
  517. this.state = 1
  518. this.stateText = '待取货'
  519. }
  520. if (res.data.status === 30) {
  521. this.state = 2
  522. this.stateText = '配送中'
  523. this.getRiderLocation(res.data.postId, res.data.id)
  524. }
  525. if (res.data.status === 40) {
  526. this.state = 3
  527. this.stateText = '已完成'
  528. }
  529. if (res.data.status === 50) {
  530. this.state = 4
  531. this.stateText = '已完成'
  532. }
  533. if (res.data.status === 80 || res.data.status === 90) {
  534. this.state = 5
  535. this.stateText = '已取消'
  536. }
  537. if (res.data.status === 32) {
  538. this.state = 6
  539. this.stateText = '配送异常'
  540. }
  541. if (res.data.status === 60) {
  542. this.state = 7
  543. this.stateText = '退款中'
  544. }
  545. if (res.data.status === 70) {
  546. this.state = 8
  547. this.stateText = '已退款'
  548. }
  549. //this.sum()
  550. })
  551. },
  552. getRiderLocation(riderId, orderId) {
  553. this.$api.request('get', 'order/app/riderLocation', {
  554. riderId: riderId,
  555. orderId: orderId
  556. }).then(({
  557. data
  558. }) => {
  559. this.riderLocation = data
  560. this.markers[1].longitude = data.longitude
  561. this.markers[1].latitude = data.latitude
  562. if (riderLastLocation !== (data.latitude + ',' + data.longitude)) {
  563. mapContext.includePoints({
  564. padding: [100],
  565. points: [{
  566. longitude: data.longitude,
  567. latitude: data.latitude
  568. }, {
  569. longitude: this.orderDetail.longitude,
  570. latitude: this.orderDetail.latitude
  571. }],
  572. fail(e) {
  573. console.log(e)
  574. },
  575. success(res) {
  576. console.log(res)
  577. }
  578. })
  579. this.getRoute()
  580. }
  581. riderLastLocation = data.latitude + ',' + data.longitude
  582. if (riderTimer) {
  583. clearTimeout(riderTimer)
  584. riderTimer = null
  585. }
  586. riderTimer = setTimeout(() => {
  587. this.getRiderLocation(riderId, orderId)
  588. }, 30 * 1000)
  589. })
  590. },
  591. // 获取核销码
  592. getVerificationCode() {
  593. this.$api.request('get', 'order/app/verificationCode', {
  594. orderId: this.orderId
  595. }).then(res => {
  596. this.verificationCode = 'data:image/png;base64,' + res.data.image;
  597. this.verificationText = res.data.code; // 显示核销码文本
  598. })
  599. },
  600. getRoute() {
  601. var that = this;
  602. this.$api.request('get', 'https://restapi.amap.com/v5/direction/bicycling', {
  603. key: that.$api.defConfig().mapKey,
  604. origin: this.orderDetail.longitude + ',' + this.orderDetail.latitude,
  605. destination: this.riderLocation.longitude + ',' + this.riderLocation.latitude,
  606. show_fields: 'polyline'
  607. }).then(res => {
  608. const steps = res.route.paths[0].steps
  609. this.polyline = [{
  610. points: [],
  611. color: '#5298ff',
  612. width: 5
  613. }]
  614. steps.forEach(({
  615. polyline
  616. }) => {
  617. const paths = polyline.split(';')
  618. paths.forEach(el => {
  619. const _ = el.split(',')
  620. this.polyline[0].points.push({
  621. latitude: _[1],
  622. longitude: _[0]
  623. })
  624. })
  625. })
  626. })
  627. },
  628. timeFormat(time) {
  629. if (time == undefined) {
  630. return
  631. }
  632. time = time.replace(/\-/g, '/')
  633. var date = new Date(time);
  634. var month = date.getMonth() + 1 > 9 ? date.getMonth() + 1 : '0' + parseInt(date.getMonth() + 1)
  635. var day = date.getDate() > 9 ? date.getDate() : '0' + date.getDate()
  636. return date.getFullYear() + '-' + month + '-' + day + ' ' + date.getHours() + ':' + date.getMinutes()
  637. },
  638. showPayment(val) {
  639. if (val === 'BALANCE') {
  640. return '余额支付'
  641. }
  642. if (val === 'INTEGRAL') {
  643. return '积分支付'
  644. }
  645. return '微信支付'
  646. },
  647. //确认支付
  648. confirm() {
  649. // #ifdef APP-PLUS
  650. this.$api.msg('演示环境不支持支付')
  651. return
  652. // #endif
  653. uni.showLoading({})
  654. const that = this
  655. that.$api.request('get', 'order/app/wxPrepay', {
  656. orderId: this.orderDetail.orderId
  657. }, failres => {
  658. that.submiting = false
  659. that.$api.msg(failres.msg)
  660. }).then(prepayRes => {
  661. uni.hideLoading()
  662. that.submiting = false
  663. //#ifdef MP-WEIXIN
  664. const payParam = {
  665. appId: prepayRes.data.appId,
  666. nonceStr: prepayRes.data.nonceStr,
  667. package: prepayRes.data.packageValue,
  668. timeStamp: prepayRes.data.timeStamp,
  669. signType: prepayRes.data.signType,
  670. paySign: prepayRes.data.paySign,
  671. }
  672. //#endif
  673. //#ifdef APP-PLUS
  674. const payParam = {
  675. appid: prepayRes.data.appId,
  676. noncestr: prepayRes.data.nonceStr,
  677. package: prepayRes.data.packageValue,
  678. partnerid: prepayRes.data.partnerId,
  679. prepayid: prepayRes.data.prepayId,
  680. timestamp: parseInt(prepayRes.data.timeStamp),
  681. sign: prepayRes.data.sign,
  682. signType: 'MD5'
  683. }
  684. //#endif
  685. //#ifdef MP-WEIXIN || APP-PLUS
  686. uni.requestPayment({
  687. provider: 'wxpay',
  688. //#ifdef MP-WEIXIN
  689. ...payParam,
  690. //#endif
  691. //#ifdef APP-PLUS
  692. orderInfo: payParam,
  693. //#endif
  694. success: function(res) {
  695. uni.redirectTo({
  696. url: '/pages/pay/success'
  697. })
  698. },
  699. fail: function(res) {
  700. // console.log("支付过程失败");
  701. // that.$api.msg(JSON.stringify(res))
  702. },
  703. complete: function(res) {
  704. console.log("支付过程结束")
  705. }
  706. });
  707. //#endif
  708. //#ifdef H5
  709. that.$jweixin.chooseWXPay({
  710. nonceStr: prepayRes.data.nonceStr,
  711. timestamp: prepayRes.data.timeStamp,
  712. package: prepayRes.data.packageValue,
  713. signType: prepayRes.data.signType,
  714. paySign: prepayRes.data.paySign,
  715. success: (e) => {
  716. //支付成功
  717. uni.redirectTo({
  718. url: '/pages/pay/success'
  719. })
  720. },
  721. fail: function(res) {
  722. console.log("支付过程失败");
  723. that.$api.msg(JSON.stringify(res))
  724. },
  725. complete: function(res) {
  726. console.log("支付过程结束")
  727. }
  728. })
  729. //#endif
  730. })
  731. }
  732. }
  733. }
  734. </script>
  735. <style lang="scss">
  736. .verification-code {
  737. margin: 20px auto;
  738. text-align: center;
  739. padding: 20px;
  740. background: #fff;
  741. border-radius: 10px;
  742. }
  743. .code-text {
  744. margin-top: 10px;
  745. font-size: 18px;
  746. font-weight: bold;
  747. color: #333;
  748. }
  749. .code-hint {
  750. margin-top: 5px;
  751. font-size: 14px;
  752. color: #666;
  753. }
  754. page {
  755. background: $page-color-base;
  756. padding-bottom: 100upx;
  757. }
  758. .contact-btn {
  759. border: none;
  760. background-color: inherit;
  761. font-size: inherit;
  762. line-height: inherit;
  763. color: inherit;
  764. height: inherit;
  765. width: inherit;
  766. }
  767. .contact-btn::after {
  768. border: none;
  769. }
  770. .state {
  771. text-align: center;
  772. padding: 17px 0 12px;
  773. background-color: #fff;
  774. width: 100%;
  775. .state-text {
  776. font-size: 40upx;
  777. color: #2AAC34;
  778. }
  779. .state-timeText {
  780. color: #717171;
  781. font-size: 24upx;
  782. margin: 6px 0 2px;
  783. }
  784. .state-time {
  785. color: #1B1C33;
  786. font-size: 28upx;
  787. }
  788. .state-btn {
  789. width: 204upx;
  790. height: 68upx;
  791. line-height: 66upx;
  792. border-radius: 100px;
  793. margin: 0 auto;
  794. border: 1px solid #ddd;
  795. margin-top: 24upx;
  796. font-size: 15px;
  797. margin: 24upx 0 0 24upx;
  798. }
  799. .state-btn-prohibit {
  800. border-color: #C4C4CC;
  801. color: #C4C4CC;
  802. }
  803. .state-btn-ac {
  804. border-color: #2AAC34;
  805. color: #2AAC34;
  806. background-color: #2AAC34;
  807. color: #fff;
  808. }
  809. }
  810. .goods {
  811. margin-top: 20upx;
  812. background-color: #FFFFFF;
  813. overflow: hidden;
  814. .goods-one {
  815. padding: 40upx 0 30upx 0;
  816. margin: 0 30upx;
  817. height: 190upx;
  818. border-bottom: 1px solid #F1F1F1;
  819. }
  820. .goods-img {
  821. margin-top: 2upx;
  822. width: 118upx;
  823. height: 110upx;
  824. float: left;
  825. }
  826. .goods-text {
  827. margin-top: 6upx;
  828. margin-left: 32upx;
  829. width: 538upx;
  830. height: 110upx;
  831. float: left;
  832. }
  833. .goods-name {
  834. width: 500upx;
  835. line-height: 44upx;
  836. overflow: hidden;
  837. color: #333333;
  838. font-size: 32upx;
  839. }
  840. .goods-tag {
  841. margin-top: 10upx;
  842. display: flex;
  843. justify-content: space-between;
  844. align-items: cenetr;
  845. }
  846. .goods-price {
  847. float: left;
  848. color: #333333;
  849. font-size: 32upx;
  850. line-height: 44upx;
  851. }
  852. .goods-yprice {
  853. margin-left: 16upx;
  854. float: left;
  855. color: #AEAEAE;
  856. font-size: 24upx;
  857. line-height: 44upx;
  858. text-decoration: line-through;
  859. }
  860. .goods-number {
  861. float: left;
  862. color: #333333;
  863. font-size: 32upx;
  864. }
  865. }
  866. .address-section {
  867. padding: 30upx 0;
  868. background: #fff;
  869. position: relative;
  870. .order-content {
  871. display: flex;
  872. align-items: center;
  873. }
  874. .icon-shouhuodizhi {
  875. flex-shrink: 0;
  876. display: flex;
  877. align-items: center;
  878. justify-content: center;
  879. width: 90upx;
  880. color: #888;
  881. font-size: 44upx;
  882. }
  883. .cen {
  884. display: flex;
  885. flex-direction: column;
  886. flex: 1;
  887. font-size: 28upx;
  888. color: $font-color-dark;
  889. }
  890. .name {
  891. font-size: 34upx;
  892. margin-right: 24upx;
  893. }
  894. .address {
  895. margin-top: 16upx;
  896. margin-right: 20upx;
  897. color: $font-color-light;
  898. }
  899. .icon-you {
  900. font-size: 32upx;
  901. color: $font-color-light;
  902. margin-right: 30upx;
  903. }
  904. .a-bg {
  905. position: absolute;
  906. left: 0;
  907. bottom: 0;
  908. display: block;
  909. width: 100%;
  910. height: 5upx;
  911. }
  912. }
  913. .goods-section {
  914. margin-top: 16upx;
  915. background: #fff;
  916. padding-bottom: 1px;
  917. .g-header {
  918. display: flex;
  919. align-items: center;
  920. height: 84upx;
  921. padding: 0 30upx;
  922. position: relative;
  923. }
  924. .logo {
  925. display: block;
  926. width: 50upx;
  927. height: 50upx;
  928. border-radius: 100px;
  929. }
  930. .name {
  931. font-size: 30upx;
  932. color: $font-color-base;
  933. margin-left: 24upx;
  934. }
  935. .g-item {
  936. display: flex;
  937. margin: 20upx 30upx;
  938. image {
  939. flex-shrink: 0;
  940. display: block;
  941. width: 140upx;
  942. height: 140upx;
  943. border-radius: 4upx;
  944. }
  945. .right {
  946. flex: 1;
  947. padding-left: 24upx;
  948. overflow: hidden;
  949. }
  950. .title {
  951. font-size: 30upx;
  952. color: $font-color-dark;
  953. }
  954. .spec {
  955. font-size: 26upx;
  956. color: $font-color-light;
  957. }
  958. .price-box {
  959. display: flex;
  960. align-items: center;
  961. font-size: 32upx;
  962. color: $font-color-dark;
  963. padding-top: 10upx;
  964. .price {
  965. margin-bottom: 4upx;
  966. }
  967. .number {
  968. font-size: 26upx;
  969. color: $font-color-base;
  970. margin-left: 20upx;
  971. }
  972. }
  973. .step-box {
  974. position: relative;
  975. }
  976. }
  977. }
  978. .yt-list {
  979. margin-top: 16upx;
  980. background: #fff;
  981. }
  982. .yt-list-cell-bor {
  983. border-bottom: 1px solid #F1F1F1;
  984. }
  985. .yt-list-cell {
  986. display: flex;
  987. align-items: center;
  988. padding: 10upx 30upx 10upx 40upx;
  989. line-height: 70upx;
  990. position: relative;
  991. &.cell-hover {
  992. background: #fafafa;
  993. }
  994. &.b-b:after {
  995. left: 30upx;
  996. }
  997. .cell-icon {
  998. height: 32upx;
  999. width: 32upx;
  1000. font-size: 22upx;
  1001. color: #fff;
  1002. text-align: center;
  1003. line-height: 32upx;
  1004. background: #f85e52;
  1005. border-radius: 4upx;
  1006. margin-right: 12upx;
  1007. &.hb {
  1008. background: #ffaa0e;
  1009. }
  1010. &.lpk {
  1011. background: #3ab54a;
  1012. }
  1013. }
  1014. .cell-more {
  1015. align-self: center;
  1016. font-size: 24upx;
  1017. color: $font-color-light;
  1018. margin-left: 8upx;
  1019. margin-right: -10upx;
  1020. }
  1021. .cell-tit {
  1022. flex: 1;
  1023. font-size: 26upx;
  1024. color: $font-color-light;
  1025. margin-right: 10upx;
  1026. }
  1027. .cell-tip {
  1028. font-size: 26upx;
  1029. color: $font-color-dark;
  1030. &.disabled {
  1031. color: $font-color-light;
  1032. }
  1033. &.active {
  1034. color: $base-color;
  1035. }
  1036. &.red {
  1037. color: $base-color;
  1038. }
  1039. }
  1040. &.desc-cell {
  1041. .cell-tit {
  1042. max-width: 90upx;
  1043. }
  1044. }
  1045. .desc {
  1046. flex: 1;
  1047. font-size: $font-base;
  1048. color: $font-color-dark;
  1049. }
  1050. .yt-list-title {
  1051. font-size: 16px;
  1052. font-family: PingFangSC-Medium, PingFang SC;
  1053. font-weight: 500;
  1054. color: rgba(51, 51, 51, 1);
  1055. }
  1056. }
  1057. /* 支付列表 */
  1058. .pay-list {
  1059. padding-left: 40upx;
  1060. margin-top: 16upx;
  1061. background: #fff;
  1062. .pay-item {
  1063. display: flex;
  1064. align-items: center;
  1065. padding-right: 20upx;
  1066. line-height: 1;
  1067. height: 110upx;
  1068. position: relative;
  1069. }
  1070. .icon-weixinzhifu {
  1071. width: 80upx;
  1072. font-size: 40upx;
  1073. color: #6BCC03;
  1074. }
  1075. .icon-alipay {
  1076. width: 80upx;
  1077. font-size: 40upx;
  1078. color: #06B4FD;
  1079. }
  1080. .icon-xuanzhong2 {
  1081. display: flex;
  1082. align-items: center;
  1083. justify-content: center;
  1084. width: 60upx;
  1085. height: 60upx;
  1086. font-size: 40upx;
  1087. color: $base-color;
  1088. }
  1089. .tit {
  1090. font-size: 32upx;
  1091. color: $font-color-dark;
  1092. flex: 1;
  1093. }
  1094. }
  1095. .footer {
  1096. position: fixed;
  1097. left: 0;
  1098. bottom: 0;
  1099. z-index: 995;
  1100. display: flex;
  1101. align-items: center;
  1102. width: 100%;
  1103. height: 90upx;
  1104. justify-content: space-between;
  1105. font-size: 30upx;
  1106. background-color: #fff;
  1107. z-index: 998;
  1108. color: $font-color-base;
  1109. box-shadow: 0 -1px 5px rgba(0, 0, 0, .1);
  1110. .price-content {
  1111. padding-left: 30upx;
  1112. }
  1113. .price-tip {
  1114. color: $base-color;
  1115. margin-left: 8upx;
  1116. }
  1117. .price {
  1118. font-size: 36upx;
  1119. color: $base-color;
  1120. }
  1121. .submit {
  1122. display: flex;
  1123. align-items: center;
  1124. justify-content: center;
  1125. width: 280upx;
  1126. height: 100%;
  1127. color: #fff;
  1128. font-size: 32upx;
  1129. background-color: $base-color;
  1130. }
  1131. }
  1132. /* 优惠券面板 */
  1133. .mask {
  1134. display: flex;
  1135. align-items: flex-end;
  1136. position: fixed;
  1137. left: 0;
  1138. top: var(--window-top);
  1139. bottom: 0;
  1140. width: 100%;
  1141. background: rgba(0, 0, 0, 0);
  1142. z-index: 9995;
  1143. transition: .3s;
  1144. .mask-content {
  1145. width: 100%;
  1146. min-height: 30vh;
  1147. max-height: 70vh;
  1148. background: #f3f3f3;
  1149. transform: translateY(100%);
  1150. transition: .3s;
  1151. overflow-y: scroll;
  1152. }
  1153. &.none {
  1154. display: none;
  1155. }
  1156. &.show {
  1157. background: rgba(0, 0, 0, .4);
  1158. .mask-content {
  1159. transform: translateY(0);
  1160. }
  1161. }
  1162. }
  1163. /* 优惠券列表 */
  1164. .coupon-item {
  1165. display: flex;
  1166. flex-direction: column;
  1167. margin: 20upx 24upx;
  1168. background: #fff;
  1169. .con {
  1170. display: flex;
  1171. align-items: center;
  1172. position: relative;
  1173. height: 120upx;
  1174. padding: 0 30upx;
  1175. &:after {
  1176. position: absolute;
  1177. left: 0;
  1178. bottom: 0;
  1179. content: '';
  1180. width: 100%;
  1181. height: 0;
  1182. border-bottom: 1px dashed #f3f3f3;
  1183. transform: scaleY(50%);
  1184. }
  1185. }
  1186. .left {
  1187. display: flex;
  1188. flex-direction: column;
  1189. justify-content: center;
  1190. flex: 1;
  1191. overflow: hidden;
  1192. height: 100upx;
  1193. }
  1194. .title {
  1195. font-size: 32upx;
  1196. color: $font-color-dark;
  1197. margin-bottom: 10upx;
  1198. }
  1199. .time {
  1200. font-size: 24upx;
  1201. color: $font-color-light;
  1202. }
  1203. .right {
  1204. display: flex;
  1205. flex-direction: column;
  1206. justify-content: center;
  1207. align-items: center;
  1208. font-size: 26upx;
  1209. color: $font-color-base;
  1210. height: 100upx;
  1211. }
  1212. .price {
  1213. font-size: 44upx;
  1214. color: $base-color;
  1215. &:before {
  1216. content: '¥';
  1217. font-size: 34upx;
  1218. }
  1219. }
  1220. .tips {
  1221. font-size: 24upx;
  1222. color: $font-color-light;
  1223. line-height: 60upx;
  1224. padding-left: 30upx;
  1225. }
  1226. .circle {
  1227. position: absolute;
  1228. left: -6upx;
  1229. bottom: -10upx;
  1230. z-index: 10;
  1231. width: 20upx;
  1232. height: 20upx;
  1233. background: #f3f3f3;
  1234. border-radius: 100px;
  1235. &.r {
  1236. left: auto;
  1237. right: -6upx;
  1238. }
  1239. }
  1240. }
  1241. </style>