detail.vue 37 KB

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