detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <!-- 订单详情 -->
  2. <template>
  3. <s-layout title="订单详情" class="index-wrap" navbar="inner">
  4. <!-- 订单状态 -->
  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_code == 'nosend' ||
  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">{{ state.orderInfo.status_text }}</view>
  47. </view>
  48. <view class="ss-font-26 ss-m-x-20 ss-m-b-70">{{ state.orderInfo.status_desc }}</view>
  49. </view>
  50. <!-- 收货地址 -->
  51. <view class="order-address-box" v-if="state.orderInfo.address">
  52. <view class="ss-flex ss-col-center">
  53. <text class="address-username">
  54. {{ state.orderInfo.address.consignee }}
  55. </text>
  56. <text class="address-phone">{{ state.orderInfo.address.mobile }}</text>
  57. </view>
  58. <view class="address-detail">{{ addressText }}</view>
  59. </view>
  60. <view class="detail-goods" :style="[{ marginTop: state.orderInfo.address ? '0' : '-40rpx' }]">
  61. <!-- 订单信息 -->
  62. <view class="order-list" v-for="item in state.orderInfo.items" :key="item.goods_id">
  63. <view class="order-card">
  64. <s-goods-item
  65. @tap="onGoodsDetail(item.goods_id)"
  66. :img="item.goods_image"
  67. :title="item.goods_title"
  68. :skuText="item.goods_sku_text"
  69. :price="item.goods_price"
  70. :score="state.orderInfo.score_amount"
  71. :num="item.goods_num"
  72. >
  73. <template #top>
  74. <view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white">
  75. <view class="item-title">配送方式</view>
  76. <view class="ss-flex ss-col-center">
  77. <text class="item-value ss-m-r-20">{{ item.dispatch_type_text }}</text>
  78. <button
  79. class="ss-reset-button copy-btn"
  80. @tap="onDetail(item)"
  81. v-if="
  82. (item.dispatch_type === 'autosend' || item.dispatch_type === 'custom') &&
  83. item.dispatch_status !== 0
  84. "
  85. >详情</button
  86. >
  87. </view>
  88. </view>
  89. </template>
  90. <template #tool>
  91. <view class="ss-flex">
  92. <button
  93. class="ss-reset-button apply-btn"
  94. v-if="item.btns.includes('aftersale')"
  95. @tap.stop="
  96. sheep.$router.go('/pages/order/aftersale/apply', {
  97. item: JSON.stringify(item),
  98. })
  99. "
  100. >
  101. 申请售后
  102. </button>
  103. <button
  104. class="ss-reset-button apply-btn"
  105. v-if="item.btns.includes('re_aftersale')"
  106. @tap.stop="
  107. sheep.$router.go('/pages/order/aftersale/apply', {
  108. item: JSON.stringify(item),
  109. })
  110. "
  111. >
  112. 重新售后
  113. </button>
  114. <button
  115. class="ss-reset-button apply-btn"
  116. v-if="item.btns.includes('aftersale_info')"
  117. @tap.stop="
  118. sheep.$router.go('/pages/order/aftersale/detail', {
  119. id: item.ext.aftersale_id,
  120. })
  121. "
  122. >
  123. 售后详情
  124. </button>
  125. <button
  126. class="ss-reset-button apply-btn"
  127. v-if="item.btns.includes('buy_again')"
  128. @tap.stop="
  129. sheep.$router.go('/pages/goods/index', {
  130. id: item.goods_id,
  131. })
  132. "
  133. >
  134. 再次购买
  135. </button>
  136. </view>
  137. </template>
  138. <template #priceSuffix>
  139. <button class="ss-reset-button tag-btn" v-if="item.status_text">
  140. {{ item.status_text }}
  141. </button>
  142. </template>
  143. </s-goods-item>
  144. </view>
  145. </view>
  146. </view>
  147. <!-- 订单信息 -->
  148. <view class="notice-box">
  149. <view class="notice-box__content">
  150. <view class="notice-item--center">
  151. <view class="ss-flex ss-flex-1">
  152. <text class="title">订单编号:</text>
  153. <text class="detail">{{ state.orderInfo.order_sn }}</text>
  154. </view>
  155. <button class="ss-reset-button copy-btn" @tap="onCopy">复制</button>
  156. </view>
  157. <view class="notice-item">
  158. <text class="title">下单时间:</text>
  159. <text class="detail">{{ state.orderInfo.create_time }}</text>
  160. </view>
  161. <view class="notice-item" v-if="state.orderInfo.paid_time">
  162. <text class="title">支付时间:</text>
  163. <text class="detail">{{ state.orderInfo.paid_time || '-' }}</text>
  164. </view>
  165. <view class="notice-item">
  166. <text class="title">支付方式:</text>
  167. <text class="detail">{{ state.orderInfo.pay_types_text?.join(',') || '-' }}</text>
  168. </view>
  169. </view>
  170. </view>
  171. <!-- 价格信息 -->
  172. <view class="order-price-box">
  173. <view class="notice-item ss-flex ss-row-between">
  174. <text class="title">商品总额</text>
  175. <view class="ss-flex">
  176. <text class="detail" v-if="Number(state.orderInfo.goods_amount) > 0"
  177. >¥{{ state.orderInfo.goods_amount }}</text
  178. >
  179. <view
  180. v-if="state.orderInfo.score_amount && Number(state.orderInfo.goods_amount) > 0"
  181. class="detail"
  182. >+</view
  183. >
  184. <view class="price-text ss-flex ss-col-center" v-if="state.orderInfo.score_amount">
  185. <image
  186. :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
  187. class="score-img"
  188. ></image>
  189. <view class="detail">{{ state.orderInfo.score_amount }}</view>
  190. </view>
  191. </view>
  192. </view>
  193. <view class="notice-item ss-flex ss-row-between">
  194. <text class="title">运费</text>
  195. <text class="detail">¥{{ state.orderInfo.dispatch_amount }}</text>
  196. </view>
  197. <view
  198. class="notice-item ss-flex ss-row-between"
  199. v-if="state.orderInfo.total_discount_fee > 0"
  200. >
  201. <text class="title">优惠金额</text>
  202. <text class="detail">¥{{ state.orderInfo.total_discount_fee }}</text>
  203. </view>
  204. <view class="notice-item all-rpice-item ss-flex ss-m-t-20">
  205. <text class="title">{{
  206. ['paid', 'completed'].includes(state.orderInfo.status) ? '已付款' : '需付款'
  207. }}</text>
  208. <text class="detail all-price" v-if="Number(state.orderInfo.pay_fee) > 0"
  209. >¥{{ state.orderInfo.pay_fee }}</text
  210. >
  211. <view
  212. v-if="
  213. state.orderInfo.score_amount &&
  214. Number(state.orderInfo.pay_fee) > 0 &&
  215. ['paid', 'completed'].includes(state.orderInfo.status)
  216. "
  217. class="detail all-price"
  218. >+</view
  219. >
  220. <view
  221. class="price-text ss-flex ss-col-center"
  222. v-if="
  223. state.orderInfo.score_amount && ['paid', 'completed'].includes(state.orderInfo.status)
  224. "
  225. >
  226. <image
  227. :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
  228. class="score-img"
  229. ></image>
  230. <view class="detail all-price">{{ state.orderInfo.score_amount }}</view>
  231. </view>
  232. </view>
  233. <view class="notice-item all-rpice-item ss-flex ss-m-t-20" v-if="refundFee > 0">
  234. <text class="title">已退款</text>
  235. <text class="detail all-price">¥{{ refundFee.toFixed(2) }}</text>
  236. </view>
  237. </view>
  238. <!-- 底部按钮 -->
  239. <!-- TODO: 查看物流、等待成团、评价完后返回页面没刷新页面 -->
  240. <su-fixed bottom placeholder bg="bg-white" v-if="state.orderInfo.btns?.length">
  241. <view class="footer-box ss-flex ss-col-center ss-row-right">
  242. <button
  243. class="ss-reset-button cancel-btn"
  244. v-if="state.orderInfo.btns?.includes('cancel')"
  245. @tap="onCancel(state.orderInfo.id)"
  246. >取消订单</button
  247. >
  248. <button
  249. class="ss-reset-button pay-btn ui-BG-Main-Gradient"
  250. v-if="state.orderInfo.btns?.includes('pay')"
  251. @tap="onPay(state.orderInfo.order_sn)"
  252. >继续支付</button
  253. >
  254. <button
  255. class="ss-reset-button cancel-btn"
  256. v-if="state.orderInfo.btns?.includes('apply_refund')"
  257. @tap="onRefund(state.orderInfo.id)"
  258. >申请退款</button
  259. >
  260. <button
  261. class="ss-reset-button cancel-btn"
  262. v-if="state.orderInfo.btns?.includes('groupon')"
  263. @tap="
  264. sheep.$router.go('/pages/activity/groupon/detail', {
  265. id: state.orderInfo.ext.groupon_id,
  266. })
  267. "
  268. >
  269. {{ state.orderInfo.status_code === 'groupon_ing' ? '邀请拼团' : '拼团详情' }}
  270. </button>
  271. <button
  272. class="ss-reset-button cancel-btn"
  273. v-if="state.orderInfo.btns?.includes('express')"
  274. @tap="onExpress(state.orderInfo.id)"
  275. >查看物流</button
  276. >
  277. <button
  278. class="ss-reset-button cancel-btn"
  279. v-if="state.orderInfo.btns?.includes('confirm')"
  280. @tap="onConfirm(state.orderInfo.id)"
  281. >确认收货</button
  282. >
  283. <button
  284. class="ss-reset-button cancel-btn"
  285. v-if="state.orderInfo.btns?.includes('comment')"
  286. @tap="onComment(state.orderInfo.order_sn)"
  287. >评价晒单</button
  288. >
  289. <button
  290. v-if="state.orderInfo.btns?.includes('invoice')"
  291. class="ss-reset-button cancel-btn"
  292. @tap.stop="onOrderInvoice(state.orderInfo.invoice?.id)"
  293. >
  294. 查看发票
  295. </button>
  296. <button
  297. v-if="state.orderInfo.btns?.includes('re_apply_refund')"
  298. class="ss-reset-button cancel-btn"
  299. @tap.stop="onRefund(state.orderInfo.id)"
  300. >
  301. 重新退款
  302. </button>
  303. </view>
  304. </su-fixed>
  305. </s-layout>
  306. </template>
  307. <script setup>
  308. import sheep from '@/sheep';
  309. import { onLoad } from '@dcloudio/uni-app';
  310. import { computed, reactive } from 'vue';
  311. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  312. const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
  313. const state = reactive({
  314. orderInfo: {},
  315. });
  316. const addressText = computed(() => {
  317. let data = state.orderInfo.address;
  318. if (data) {
  319. return `${data.province_name} ${data.city_name} ${data.district_name} ${data.address}`;
  320. }
  321. return '';
  322. });
  323. // 复制
  324. const onCopy = () => {
  325. sheep.$helper.copyText(state.orderInfo.order_sn);
  326. };
  327. //退款总额
  328. const refundFee = computed(() => {
  329. let refundFee = 0;
  330. state.orderInfo.items?.forEach((i) => {
  331. refundFee += Number(i.refund_fee);
  332. });
  333. return refundFee;
  334. });
  335. // 去支付
  336. function onPay(orderSN) {
  337. sheep.$router.go('/pages/pay/index', {
  338. orderSN,
  339. });
  340. }
  341. function onGoodsDetail(id) {
  342. sheep.$router.go('/pages/goods/index', { id });
  343. }
  344. // 取消订单
  345. async function onCancel(orderId) {
  346. uni.showModal({
  347. title: '提示',
  348. content: '确定要取消订单吗?',
  349. success: async function (res) {
  350. if (res.confirm) {
  351. const { error, data } = await sheep.$api.order.cancel(orderId);
  352. if (error === 0) {
  353. getOrderDetail(data.order_sn);
  354. }
  355. }
  356. },
  357. });
  358. }
  359. // 申请退款
  360. async function onRefund(orderId) {
  361. uni.showModal({
  362. title: '提示',
  363. content: '确定要申请退款吗?',
  364. success: async function (res) {
  365. if (res.confirm) {
  366. const { error, data } = await sheep.$api.order.applyRefund(orderId);
  367. if (error === 0) {
  368. getOrderDetail(data.order_sn);
  369. }
  370. }
  371. },
  372. });
  373. }
  374. // 查看物流
  375. async function onExpress(orderId) {
  376. sheep.$router.go('/pages/order/express/list', {
  377. orderId,
  378. });
  379. }
  380. // 确认收货
  381. async function onConfirm(orderId) {
  382. const { error, data } = await sheep.$api.order.confirm(orderId);
  383. if (error === 0) {
  384. getOrderDetail(data.order_sn);
  385. }
  386. }
  387. // 查看发票
  388. function onOrderInvoice(invoiceId) {
  389. sheep.$router.go('/pages/order/invoice', {
  390. invoiceId,
  391. });
  392. }
  393. // 配送方式详情
  394. function onDetail(item) {
  395. sheep.$router.go('/pages/order/dispatch/content', {
  396. id: item.order_id,
  397. item_id: item.id,
  398. });
  399. }
  400. // 评价
  401. function onComment(orderSN) {
  402. uni.$once('SELECT_INVOICE', (e) => {
  403. state.invoiceInfo = e.invoiceInfo;
  404. });
  405. sheep.$router.go('/pages/goods/comment/add', {
  406. orderSN,
  407. });
  408. }
  409. async function getOrderDetail(id) {
  410. const { data, error } = await sheep.$api.order.detail(id);
  411. if (error === 0) {
  412. state.orderInfo = data;
  413. } else {
  414. sheep.$router.back();
  415. }
  416. }
  417. onLoad(async (options) => {
  418. let id = '';
  419. if (options.orderSN) {
  420. id = options.orderSN;
  421. }
  422. if (options.id) {
  423. id = options.id;
  424. }
  425. getOrderDetail(id);
  426. });
  427. </script>
  428. <style lang="scss" scoped>
  429. .score-img {
  430. width: 36rpx;
  431. height: 36rpx;
  432. margin: 0 4rpx;
  433. }
  434. .apply-btn {
  435. width: 140rpx;
  436. height: 50rpx;
  437. border-radius: 25rpx;
  438. font-size: 24rpx;
  439. border: 2rpx solid #dcdcdc;
  440. line-height: normal;
  441. margin-left: 16rpx;
  442. }
  443. .state-box {
  444. color: rgba(#fff, 0.9);
  445. width: 100%;
  446. background: v-bind(headerBg) no-repeat,
  447. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  448. background-size: 750rpx 100%;
  449. box-sizing: border-box;
  450. .state-img {
  451. width: 60rpx;
  452. height: 60rpx;
  453. margin-right: 20rpx;
  454. }
  455. }
  456. .order-address-box {
  457. background-color: #fff;
  458. border-radius: 10rpx;
  459. margin: -50rpx 20rpx 16rpx 20rpx;
  460. padding: 44rpx 34rpx 42rpx 20rpx;
  461. font-size: 30rpx;
  462. box-sizing: border-box;
  463. font-weight: 500;
  464. color: rgba(51, 51, 51, 1);
  465. .address-username {
  466. margin-right: 20rpx;
  467. }
  468. .address-detail {
  469. font-size: 26rpx;
  470. font-weight: 500;
  471. color: rgba(153, 153, 153, 1);
  472. margin-top: 20rpx;
  473. }
  474. }
  475. .detail-goods {
  476. border-radius: 10rpx;
  477. margin: 0 20rpx 20rpx 20rpx;
  478. .order-list {
  479. margin-bottom: 20rpx;
  480. background-color: #fff;
  481. .order-card {
  482. padding: 20rpx 0;
  483. .order-sku {
  484. font-size: 24rpx;
  485. font-weight: 400;
  486. color: rgba(153, 153, 153, 1);
  487. width: 450rpx;
  488. margin-bottom: 20rpx;
  489. .order-num {
  490. margin-right: 10rpx;
  491. }
  492. }
  493. .tag-btn {
  494. margin-left: 16rpx;
  495. font-size: 24rpx;
  496. height: 36rpx;
  497. color: var(--ui-BG-Main);
  498. border: 2rpx solid var(--ui-BG-Main);
  499. border-radius: 14rpx;
  500. padding: 0 4rpx;
  501. }
  502. }
  503. }
  504. }
  505. // 订单信息。
  506. .notice-box {
  507. background: #fff;
  508. border-radius: 10rpx;
  509. margin: 0 20rpx 20rpx 20rpx;
  510. .notice-box__head {
  511. font-size: 30rpx;
  512. font-weight: 500;
  513. color: rgba(51, 51, 51, 1);
  514. line-height: 80rpx;
  515. border-bottom: 1rpx solid #dfdfdf;
  516. padding: 0 25rpx;
  517. }
  518. .notice-box__content {
  519. padding: 20rpx;
  520. .self-pickup-box {
  521. width: 100%;
  522. .self-pickup--img {
  523. width: 200rpx;
  524. height: 200rpx;
  525. margin: 40rpx 0;
  526. }
  527. }
  528. }
  529. .notice-item,
  530. .notice-item--center {
  531. display: flex;
  532. align-items: center;
  533. line-height: normal;
  534. margin-bottom: 24rpx;
  535. .title {
  536. font-size: 28rpx;
  537. color: #999;
  538. }
  539. .detail {
  540. font-size: 28rpx;
  541. color: #333;
  542. flex: 1;
  543. }
  544. }
  545. }
  546. .copy-btn {
  547. width: 100rpx;
  548. line-height: 50rpx;
  549. border-radius: 25rpx;
  550. padding: 0;
  551. background: rgba(238, 238, 238, 1);
  552. font-size: 22rpx;
  553. font-weight: 400;
  554. color: rgba(51, 51, 51, 1);
  555. }
  556. // 订单价格信息
  557. .order-price-box {
  558. background-color: #fff;
  559. border-radius: 10rpx;
  560. padding: 20rpx;
  561. margin: 0 20rpx 20rpx 20rpx;
  562. .notice-item {
  563. line-height: 70rpx;
  564. .title {
  565. font-size: 28rpx;
  566. color: #999;
  567. }
  568. .detail {
  569. font-size: 28rpx;
  570. color: #333;
  571. font-family: OPPOSANS;
  572. }
  573. }
  574. .all-rpice-item {
  575. justify-content: flex-end;
  576. align-items: center;
  577. .title {
  578. font-size: 26rpx;
  579. font-weight: 500;
  580. color: #333333;
  581. line-height: normal;
  582. }
  583. .all-price {
  584. font-size: 26rpx;
  585. font-family: OPPOSANS;
  586. line-height: normal;
  587. color: $red;
  588. }
  589. }
  590. }
  591. // 底部
  592. .footer-box {
  593. height: 100rpx;
  594. width: 100%;
  595. box-sizing: border-box;
  596. border-radius: 10rpx;
  597. padding-right: 20rpx;
  598. .cancel-btn {
  599. width: 160rpx;
  600. height: 60rpx;
  601. background: #eeeeee;
  602. border-radius: 30rpx;
  603. margin-right: 20rpx;
  604. font-size: 26rpx;
  605. font-weight: 400;
  606. color: #333333;
  607. }
  608. .pay-btn {
  609. width: 160rpx;
  610. height: 60rpx;
  611. font-size: 26rpx;
  612. border-radius: 30rpx;
  613. font-weight: 500;
  614. color: #fff;
  615. }
  616. }
  617. </style>