detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <!-- 订单详情 -->
  2. <template>
  3. <s-layout title="订单详情" class="index-wrap" navbar="inner">
  4. <!-- 订单状态 TODO -->
  5. <view
  6. class="state-box ss-flex-col ss-col-center ss-row-right"
  7. :style="[
  8. {
  9. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  10. paddingTop: Number(statusBarHeight + 88) + 'rpx',
  11. },
  12. ]"
  13. >
  14. <view class="ss-flex ss-m-t-32 ss-m-b-20">
  15. <image
  16. v-if="
  17. state.orderInfo.status_code == 'unpaid' ||
  18. state.orderInfo.status === 10 || // 待发货
  19. state.orderInfo.status_code == 'nocomment'
  20. "
  21. class="state-img"
  22. :src="sheep.$url.static('/static/img/shop/order/order_loading.png')"
  23. >
  24. </image>
  25. <image
  26. v-if="
  27. state.orderInfo.status_code == 'completed' ||
  28. state.orderInfo.status_code == 'refund_agree'
  29. "
  30. class="state-img"
  31. :src="sheep.$url.static('/static/img/shop/order/order_success.png')"
  32. >
  33. </image>
  34. <image
  35. v-if="state.orderInfo.status_code == 'cancel' || state.orderInfo.status_code == 'closed'"
  36. class="state-img"
  37. :src="sheep.$url.static('/static/img/shop/order/order_close.png')"
  38. >
  39. </image>
  40. <image
  41. v-if="state.orderInfo.status_code == 'noget'"
  42. class="state-img"
  43. :src="sheep.$url.static('/static/img/shop/order/order_express.png')"
  44. >
  45. </image>
  46. <view class="ss-font-30">{{ formatOrderStatus(state.orderInfo) }}</view>
  47. </view>
  48. <view class="ss-font-26 ss-m-x-20 ss-m-b-70">
  49. {{ formatOrderStatusDescription(state.orderInfo) }}
  50. </view>
  51. </view>
  52. <!-- 收货地址 -->
  53. <view class="order-address-box" v-if="state.orderInfo.receiverAreaId > 0">
  54. <view class="ss-flex ss-col-center">
  55. <text class="address-username">
  56. {{ state.orderInfo.receiverName }}
  57. </text>
  58. <text class="address-phone">{{ state.orderInfo.receiverMobile }}</text>
  59. </view>
  60. <view class="address-detail">
  61. {{ state.orderInfo.receiverAreaName }} {{ state.orderInfo.receiverDetailAddress }}
  62. </view>
  63. </view>
  64. <view
  65. class="detail-goods"
  66. :style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
  67. >
  68. <!-- 订单信 -->
  69. <view class="order-list" v-for="item in state.orderInfo.items" :key="item.goods_id">
  70. <view class="order-card">
  71. <s-goods-item
  72. @tap="onGoodsDetail(item.spuId)"
  73. :img="item.picUrl"
  74. :title="item.spuName"
  75. :skuText="item.properties.map((property) => property.valueName).join(' ')"
  76. :price="item.price"
  77. :num="item.count"
  78. :lottery="state.orderInfo.lottery"
  79. >
  80. <template #tool>
  81. <view class="ss-flex">
  82. <button class="ss-reset-button apply-btn"
  83. v-if="[10, 20, 30].includes(state.orderInfo.status) && item.afterSaleStatus === 0 && item.spuType === '0'"
  84. @tap.stop="sheep.$router.go('/pages/order/aftersale/apply', {orderId: state.orderInfo.id,itemId: item.id,})">申请售后</button>
  85. <button class="ss-reset-button apply-btn" v-if="item.afterSaleStatus === 10"
  86. @tap.stop="sheep.$router.go('/pages/order/aftersale/detail', { id: item.afterSaleId })">退款中</button>
  87. <button class="ss-reset-button apply-btn"
  88. v-if="item.afterSaleStatus === 20"
  89. @tap.stop="sheep.$router.go('/pages/order/aftersale/detail', {id: item.afterSaleId,})">退款成功</button>
  90. <button
  91. class="ss-reset-button apply-btn"
  92. @tap.stop="preview(item.extend?.fileUrls[0])"
  93. v-if="[10, 20, 30].includes(state.orderInfo?.status) && item.spuType === '99' && item.extend?.fileUrls && item.extend?.fileUrls.length"
  94. >预览/下载</button>
  95. </view>
  96. </template>
  97. <template #priceSuffix>
  98. <button class="ss-reset-button tag-btn" v-if="item.status_text">
  99. {{ item.status_text }}
  100. </button>
  101. </template>
  102. </s-goods-item>
  103. </view>
  104. </view>
  105. </view>
  106. <!-- 自提核销 -->
  107. <PickUpVerify
  108. :order-info="state.orderInfo"
  109. :systemStore="systemStore"
  110. ref="pickUpVerifyRef"
  111. ></PickUpVerify>
  112. <!-- 订单信息 -->
  113. <view class="notice-box">
  114. <view class="notice-box__content">
  115. <view class="notice-item--center">
  116. <view class="ss-flex ss-flex-1">
  117. <text class="title">订单编号:</text>
  118. <text class="detail">{{ state.orderInfo.no }}</text>
  119. </view>
  120. <button class="ss-reset-button copy-btn" @tap="onCopy">复制</button>
  121. </view>
  122. <view class="notice-item">
  123. <text class="title">下单时间:</text>
  124. <text class="detail">
  125. {{ sheep.$helper.timeFormat(state.orderInfo.createTime, 'yyyy-mm-dd hh:MM:ss') }}
  126. </text>
  127. </view>
  128. <view class="notice-item" v-if="state.orderInfo.payTime">
  129. <text class="title">支付时间:</text>
  130. <text class="detail">
  131. {{ sheep.$helper.timeFormat(state.orderInfo.payTime, 'yyyy-mm-dd hh:MM:ss') }}
  132. </text>
  133. </view>
  134. <view class="notice-item">
  135. <text class="title">支付方式:</text>
  136. <text class="detail">{{ state.orderInfo.payChannelName || '-' }}</text>
  137. </view>
  138. <view class="notice-item">
  139. <text class="title">订单备注:</text>
  140. <text class="detail" style="color: #666;">{{ state.orderInfo.userRemark || '' }}</text>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 价格信息 -->
  145. <view class="order-price-box">
  146. <view class="notice-item ss-flex ss-row-between">
  147. <text class="title">商品总额</text>
  148. <view class="ss-flex">
  149. <text class="detail">¥{{ fen2yuan(state.orderInfo.totalPrice) }}</text>
  150. </view>
  151. </view>
  152. <view class="notice-item ss-flex ss-row-between">
  153. <text class="title">运费</text>
  154. <text class="detail">¥{{ fen2yuan(state.orderInfo.deliveryPrice) }}</text>
  155. </view>
  156. <view class="notice-item ss-flex ss-row-between" v-if="state.orderInfo.couponPrice > 0">
  157. <text class="title">优惠劵金额</text>
  158. <text class="detail">-¥{{ fen2yuan(state.orderInfo.couponPrice) }}</text>
  159. </view>
  160. <view class="notice-item ss-flex ss-row-between" v-if="state.orderInfo.pointPrice > 0">
  161. <text class="title">积分抵扣</text>
  162. <text class="detail">-¥{{ fen2yuan(state.orderInfo.pointPrice) }}</text>
  163. </view>
  164. <view class="notice-item ss-flex ss-row-between" v-if="state.orderInfo.discountPrice > 0">
  165. <text class="title">活动优惠</text>
  166. <text class="detail">¥{{ fen2yuan(state.orderInfo.discountPrice) }}</text>
  167. </view>
  168. <view class="notice-item ss-flex ss-row-between" v-if="state.orderInfo.vipPrice > 0">
  169. <text class="title">会员优惠</text>
  170. <text class="detail">-¥{{ fen2yuan(state.orderInfo.vipPrice) }}</text>
  171. </view>
  172. <view class="notice-item all-rpice-item ss-flex ss-m-t-20">
  173. <text class="title">{{ state.orderInfo.payStatus ? '已付款' : '需付款' }}</text>
  174. <text class="detail all-price">¥{{ fen2yuan(state.orderInfo.payPrice) }}</text>
  175. </view>
  176. <view
  177. class="notice-item all-rpice-item ss-flex ss-m-t-20"
  178. v-if="state.orderInfo.refundPrice > 0"
  179. >
  180. <text class="title">已退款</text>
  181. <text class="detail all-price">¥{{ fen2yuan(state.orderInfo.refundPrice) }}</text>
  182. </view>
  183. </view>
  184. <!-- 底部按钮 -->
  185. <!-- TODO: 查看物流、等待成团、评价完后返回页面没刷新页面 -->
  186. <su-fixed bottom placeholder bg="bg-white" v-if="state.orderInfo.buttons?.length">
  187. <view class="footer-box ss-flex ss-col-center ss-row-right">
  188. <button
  189. class="ss-reset-button cancel-btn"
  190. v-if="state.orderInfo.buttons?.includes('cancel')"
  191. @tap="onCancel(state.orderInfo.id)"
  192. >
  193. 取消订单
  194. </button>
  195. <button
  196. class="ss-reset-button pay-btn ui-BG-Main-Gradient"
  197. v-if="state.orderInfo.buttons?.includes('pay')"
  198. @tap="onPay(state.orderInfo.payOrderId)"
  199. >
  200. 继续支付
  201. </button>
  202. <!-- <button
  203. class="ss-reset-button cancel-btn"
  204. v-if="state.orderInfo.buttons?.includes('combination')"
  205. @tap="
  206. sheep.$router.go('/pages/activity/groupon/detail', {
  207. id: state.orderInfo.combinationRecordId,
  208. })
  209. "
  210. >
  211. 拼团详情
  212. </button> -->
  213. <button
  214. class="ss-reset-button cancel-btn"
  215. v-if="state.orderInfo.buttons?.includes('express')"
  216. @tap="onExpress(state.orderInfo.id)"
  217. >
  218. 查看物流
  219. </button>
  220. <button
  221. class="ss-reset-button cancel-btn"
  222. v-if="state.orderInfo.buttons?.includes('confirm')"
  223. @tap="onConfirm(state.orderInfo.id)"
  224. >
  225. 确认收货
  226. </button>
  227. <!-- <button
  228. class="ss-reset-button cancel-btn"
  229. v-if="state.orderInfo.buttons?.includes('comment')"
  230. @tap="onComment(state.orderInfo.id)"
  231. >
  232. 评价
  233. </button> -->
  234. </view>
  235. </su-fixed>
  236. </s-layout>
  237. </template>
  238. <script setup>
  239. import sheep from '@/sheep';
  240. import { onLoad, onShow } from '@dcloudio/uni-app';
  241. import { reactive, ref } from 'vue';
  242. import { isEmpty } from 'lodash-es';
  243. import {
  244. fen2yuan,
  245. formatOrderStatus,
  246. formatOrderStatusDescription,
  247. handleOrderButtons,
  248. } from '@/sheep/hooks/useGoods';
  249. import OrderApi from '@/sheep/api/trade/order';
  250. import DeliveryApi from '@/sheep/api/trade/delivery';
  251. import PickUpVerify from '@/pages/order/pickUpVerify.vue';
  252. import { preview } from '@/sheep/util/preview'
  253. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  254. const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
  255. const state = reactive({
  256. orderInfo: {},
  257. merchantTradeNo: '', // 商户订单号
  258. comeinType: '', // 进入订单详情的来源类型
  259. });
  260. // ========== 门店自提(核销) ==========
  261. const systemStore = ref({}); // 门店信息
  262. // 复制
  263. const onCopy = () => {
  264. sheep.$helper.copyText(state.orderInfo.no);
  265. };
  266. // 去支付
  267. function onPay(payOrderId) {
  268. sheep.$router.go('/pages/pay/index', {
  269. id: payOrderId,
  270. });
  271. }
  272. // 查看商品
  273. function onGoodsDetail(id) {
  274. sheep.$router.go('/pages/goods/index', {
  275. id,
  276. });
  277. }
  278. // 取消订单
  279. async function onCancel(orderId) {
  280. uni.showModal({
  281. title: '提示',
  282. content: '确定要取消订单吗?',
  283. success: async function (res) {
  284. if (!res.confirm) {
  285. return;
  286. }
  287. const { code } = await OrderApi.cancelOrder(orderId);
  288. if (code === 0) {
  289. await getOrderDetail(orderId);
  290. }
  291. },
  292. });
  293. }
  294. // 查看物流
  295. async function onExpress(id) {
  296. sheep.$router.go('/pages/order/express/log', {
  297. id,
  298. });
  299. }
  300. // 确认收货
  301. async function onConfirm(orderId, ignore = false) {
  302. // 需开启确认收货组件
  303. // todo: 芋艿:待接入微信
  304. // 1.怎么检测是否开启了发货组件功能?如果没有开启的话就不能在这里return出去
  305. // 2.如果开启了走mpConfirm方法,需要在App.vue的show方法中拿到确认收货结果
  306. let isOpenBusinessView = true;
  307. if (
  308. sheep.$platform.name === 'WechatMiniProgram' &&
  309. !isEmpty(state.orderInfo.wechat_extra_data) &&
  310. isOpenBusinessView &&
  311. !ignore
  312. ) {
  313. mpConfirm(orderId);
  314. return;
  315. }
  316. uni.showModal({
  317. title: '提示',
  318. content: '确认收货吗?',
  319. success: async function (res) {
  320. if (!res.confirm) {
  321. return;
  322. }
  323. // 正常的确认收货流程
  324. const { code } = await OrderApi.receiveOrder(orderId);
  325. if (code === 0) {
  326. await getOrderDetail(orderId);
  327. }
  328. },
  329. });
  330. }
  331. // #ifdef MP-WEIXIN
  332. // 小程序确认收货组件
  333. function mpConfirm(orderId) {
  334. if (!wx.openBusinessView) {
  335. sheep.$helper.toast(`请升级微信版本`);
  336. return;
  337. }
  338. wx.openBusinessView({
  339. businessType: 'weappOrderConfirm',
  340. extraData: {
  341. merchant_trade_no: state.orderInfo.wechat_extra_data.merchant_trade_no,
  342. transaction_id: state.orderInfo.wechat_extra_data.transaction_id,
  343. },
  344. success(response) {
  345. console.log('success:', response);
  346. if (response.errMsg === 'openBusinessView:ok') {
  347. if (response.extraData.status === 'success') {
  348. onConfirm(orderId, true);
  349. }
  350. }
  351. },
  352. fail(error) {
  353. console.log('error:', error);
  354. },
  355. complete(result) {
  356. console.log('result:', result);
  357. },
  358. });
  359. }
  360. // #endif
  361. // 评价
  362. function onComment(id) {
  363. sheep.$router.go('/pages/goods/comment/add', {
  364. id,
  365. });
  366. }
  367. const pickUpVerifyRef = ref();
  368. async function getOrderDetail(id) {
  369. // 对详情数据进行适配
  370. let res;
  371. if (state.comeinType === 'wechat') {
  372. // TODO 芋艿:微信场景下
  373. res = await OrderApi.getOrderDetail(id, {
  374. merchant_trade_no: state.merchantTradeNo,
  375. });
  376. } else {
  377. res = await OrderApi.getOrderDetail(id);
  378. }
  379. // 中奖信息
  380. const result = await OrderApi.getLuckLotteryRecordByOrderId(id)
  381. if (res.code === 0) {
  382. state.orderInfo = res.data;
  383. console.log(state.orderInfo, '订单详情')
  384. state.orderInfo.lottery = result.data
  385. handleOrderButtons(state.orderInfo);
  386. // 配送方式:门店自提
  387. if (res.data.pickUpStoreId) {
  388. const { data } = await DeliveryApi.getDeliveryPickUpStore(res.data.pickUpStoreId);
  389. systemStore.value = data || {};
  390. }
  391. if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
  392. pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
  393. }
  394. } else {
  395. sheep.$router.back();
  396. }
  397. }
  398. onShow(async () => {
  399. //onShow中获取订单列表,保证跳转后页面为最新状态
  400. await getOrderDetail(state.orderInfo.id);
  401. })
  402. onLoad(async (options) => {
  403. let id = 0;
  404. if (options.id) {
  405. id = options.id;
  406. }
  407. // TODO 芋艿:下面两个变量,后续接入
  408. state.comeinType = options.comein_type;
  409. if (state.comeinType === 'wechat') {
  410. state.merchantTradeNo = options.merchant_trade_no;
  411. }
  412. state.orderInfo.id = id
  413. });
  414. </script>
  415. <style lang="scss" scoped>
  416. .score-img {
  417. width: 36rpx;
  418. height: 36rpx;
  419. margin: 0 4rpx;
  420. }
  421. .apply-btn {
  422. width: 140rpx;
  423. height: 50rpx;
  424. border-radius: 25rpx;
  425. font-size: 24rpx;
  426. border: 2rpx solid #dcdcdc;
  427. line-height: normal;
  428. margin-left: 16rpx;
  429. }
  430. .state-box {
  431. color: rgba(#fff, 0.9);
  432. width: 100%;
  433. background: v-bind(headerBg) no-repeat,
  434. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  435. background-size: 750rpx 100%;
  436. box-sizing: border-box;
  437. .state-img {
  438. width: 60rpx;
  439. height: 60rpx;
  440. margin-right: 20rpx;
  441. }
  442. }
  443. .order-address-box {
  444. background-color: #fff;
  445. border-radius: 10rpx;
  446. margin: -50rpx 20rpx 16rpx 20rpx;
  447. padding: 44rpx 34rpx 42rpx 20rpx;
  448. font-size: 30rpx;
  449. box-sizing: border-box;
  450. font-weight: 500;
  451. color: rgba(51, 51, 51, 1);
  452. .address-username {
  453. margin-right: 20rpx;
  454. }
  455. .address-detail {
  456. font-size: 26rpx;
  457. font-weight: 500;
  458. color: rgba(153, 153, 153, 1);
  459. margin-top: 20rpx;
  460. }
  461. }
  462. .detail-goods {
  463. border-radius: 10rpx;
  464. margin: 0 20rpx 20rpx 20rpx;
  465. .order-list {
  466. margin-bottom: 20rpx;
  467. background-color: #fff;
  468. .order-card {
  469. padding: 20rpx 0;
  470. .order-sku {
  471. font-size: 24rpx;
  472. font-weight: 400;
  473. color: rgba(153, 153, 153, 1);
  474. width: 450rpx;
  475. margin-bottom: 20rpx;
  476. .order-num {
  477. margin-right: 10rpx;
  478. }
  479. }
  480. .tag-btn {
  481. margin-left: 16rpx;
  482. font-size: 24rpx;
  483. height: 36rpx;
  484. color: var(--ui-BG-Main);
  485. border: 2rpx solid var(--ui-BG-Main);
  486. border-radius: 14rpx;
  487. padding: 0 4rpx;
  488. }
  489. }
  490. }
  491. }
  492. // 订单信息。
  493. .notice-box {
  494. background: #fff;
  495. border-radius: 10rpx;
  496. margin: 0 20rpx 20rpx 20rpx;
  497. .notice-box__head {
  498. font-size: 30rpx;
  499. font-weight: 500;
  500. color: rgba(51, 51, 51, 1);
  501. line-height: 80rpx;
  502. border-bottom: 1rpx solid #dfdfdf;
  503. padding: 0 25rpx;
  504. }
  505. .notice-box__content {
  506. padding: 20rpx;
  507. .self-pickup-box {
  508. width: 100%;
  509. .self-pickup--img {
  510. width: 200rpx;
  511. height: 200rpx;
  512. margin: 40rpx 0;
  513. }
  514. }
  515. }
  516. .notice-item,
  517. .notice-item--center {
  518. display: flex;
  519. align-items: center;
  520. line-height: normal;
  521. margin-bottom: 24rpx;
  522. .title {
  523. font-size: 28rpx;
  524. color: #999;
  525. }
  526. .detail {
  527. font-size: 28rpx;
  528. color: #333;
  529. flex: 1;
  530. }
  531. }
  532. }
  533. .copy-btn {
  534. width: 100rpx;
  535. line-height: 50rpx;
  536. border-radius: 25rpx;
  537. padding: 0;
  538. background: rgba(238, 238, 238, 1);
  539. font-size: 22rpx;
  540. font-weight: 400;
  541. color: rgba(51, 51, 51, 1);
  542. }
  543. // 订单价格信息
  544. .order-price-box {
  545. background-color: #fff;
  546. border-radius: 10rpx;
  547. padding: 20rpx;
  548. margin: 0 20rpx 20rpx 20rpx;
  549. .notice-item {
  550. line-height: 70rpx;
  551. .title {
  552. font-size: 28rpx;
  553. color: #999;
  554. }
  555. .detail {
  556. font-size: 28rpx;
  557. color: #333;
  558. font-family: OPPOSANS;
  559. }
  560. }
  561. .all-rpice-item {
  562. justify-content: flex-end;
  563. align-items: center;
  564. .title {
  565. font-size: 26rpx;
  566. font-weight: 500;
  567. color: #333333;
  568. line-height: normal;
  569. }
  570. .all-price {
  571. font-size: 26rpx;
  572. font-family: OPPOSANS;
  573. line-height: normal;
  574. color: $red;
  575. }
  576. }
  577. }
  578. // 底部
  579. .footer-box {
  580. height: 100rpx;
  581. width: 100%;
  582. box-sizing: border-box;
  583. border-radius: 10rpx;
  584. padding-right: 20rpx;
  585. .cancel-btn {
  586. width: 160rpx;
  587. height: 60rpx;
  588. background: #eeeeee;
  589. border-radius: 30rpx;
  590. margin-right: 20rpx;
  591. font-size: 26rpx;
  592. font-weight: 400;
  593. color: #333333;
  594. }
  595. .pay-btn {
  596. width: 160rpx;
  597. height: 60rpx;
  598. font-size: 26rpx;
  599. border-radius: 30rpx;
  600. font-weight: 500;
  601. color: #fff;
  602. }
  603. }
  604. </style>