detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <!-- 订单详情 -->
  2. <template>
  3. <s-layout :title="$t('order.detail.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('/assets/addons/shopro/uniapp/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('/assets/addons/shopro/uniapp/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('/assets/addons/shopro/uniapp/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('/assets/addons/shopro/uniapp/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 ss-r-10" 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">{{$t('order.confirm.delivery')}}</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. >{{$t('common.detail')}}</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. {{$t('order.detail.applyService')}}
  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. {{$t('order.detail.reapplyService')}}
  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. {{$t('order.detail.saleDetail')}}
  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. {{$t('order.detail.rebuy')}}
  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">{{$t('order.detail.order_no')}}:</text>
  153. <text class="detail">{{ state.orderInfo.order_sn }}</text>
  154. </view>
  155. <button class="ss-reset-button copy-btn" @tap="onCopy">{{$t('order.detail.copy')}}</button>
  156. </view>
  157. <view class="notice-item">
  158. <text class="title">{{$t('order.detail.order_time')}}:</text>
  159. <text class="detail">{{ state.orderInfo.createtime }}</text>
  160. </view>
  161. <view class="notice-item" v-if="state.orderInfo.paid_time">
  162. <text class="title">{{$t('order.detail.pay_time')}}:</text>
  163. <text class="detail">{{ state.orderInfo.paid_time || '-' }}</text>
  164. </view>
  165. <view class="notice-item">
  166. <text class="title">{{$t('order.detail.pay_way')}}:</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">{{$t('order.detail.goodsAmount')}}</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('/assets/addons/shopro/uniapp/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">{{$t('order.detail.freight')}}</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="Number(state.orderInfo.total_discount_fee) > 0"
  200. >
  201. <text class="title">{{$t('order.detail.discount')}}</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. ? $t('order.detail.paid')
  208. : $t('order.detail.needPay')
  209. }}</text>
  210. <text class="detail all-price" v-if="Number(state.orderInfo.pay_fee) > 0"
  211. >¥{{ state.orderInfo.pay_fee }}</text
  212. >
  213. <view
  214. v-if="
  215. state.orderInfo.score_amount &&
  216. Number(state.orderInfo.pay_fee) > 0 &&
  217. ['paid', 'completed'].includes(state.orderInfo.status)
  218. "
  219. class="detail all-price"
  220. >+</view
  221. >
  222. <view
  223. class="price-text ss-flex ss-col-center"
  224. v-if="
  225. state.orderInfo.score_amount &&
  226. ['paid', 'completed'].includes(state.orderInfo.status)
  227. "
  228. >
  229. <image
  230. :src="sheep.$url.static('/assets/addons/shopro/uniapp/goods/score1.svg')"
  231. class="score-img"
  232. ></image>
  233. <view class="detail all-price">{{ state.orderInfo.score_amount }}</view>
  234. </view>
  235. </view>
  236. <view class="notice-item all-rpice-item ss-flex ss-m-t-20" v-if="refundFee > 0">
  237. <text class="title">{{$t('order.detail.refund')}}</text>
  238. <text class="detail all-price">¥{{ refundFee.toFixed(2) }}</text>
  239. </view>
  240. </view>
  241. <!-- 底部按钮 -->
  242. <!-- TODO: 查看物流、等待成团、评价完后返回页面没刷新页面 -->
  243. <su-fixed bottom placeholder bg="bg-white" v-if="state.orderInfo.btns?.length">
  244. <view class="footer-box ss-flex ss-col-center ss-row-right">
  245. <button
  246. class="ss-reset-button cancel-btn"
  247. v-if="state.orderInfo.btns?.includes('cancel')"
  248. @tap="onCancel(state.orderInfo.id)"
  249. >{{$t('order.detail.cancleOrder')}}</button
  250. >
  251. <button
  252. class="ss-reset-button pay-btn ui-BG-Main-Gradient"
  253. v-if="state.orderInfo.btns?.includes('pay')"
  254. @tap="onPay(state.orderInfo.order_sn)"
  255. >{{$t('order.detail.continuePay')}}</button
  256. >
  257. <button
  258. class="ss-reset-button cancel-btn"
  259. v-if="state.orderInfo.btns?.includes('apply_refund')"
  260. @tap="onRefund(state.orderInfo.id)"
  261. >{{$t('order.detail.applyRefund')}}</button
  262. >
  263. <button
  264. class="ss-reset-button cancel-btn"
  265. v-if="state.orderInfo.btns?.includes('groupon')"
  266. @tap="
  267. sheep.$router.go('/pages/activity/groupon/detail', {
  268. id: state.orderInfo.ext.groupon_id,
  269. })
  270. "
  271. >
  272. {{ state.orderInfo.status_code === 'groupon_ing' ? $t('order.detail.inviteGroup') : $t('order.detail.groupDetail') }}
  273. </button>
  274. <button
  275. class="ss-reset-button cancel-btn"
  276. v-if="state.orderInfo.btns?.includes('express')"
  277. @tap="onExpress(state.orderInfo.id)"
  278. >{{$t('order.detail.viewExpress')}}</button
  279. >
  280. <button
  281. class="ss-reset-button cancel-btn"
  282. v-if="state.orderInfo.btns?.includes('confirm')"
  283. @tap="onConfirm(state.orderInfo.id)"
  284. >{{$t('order.detail.confirmReceived')}}</button
  285. >
  286. <button
  287. class="ss-reset-button cancel-btn"
  288. v-if="state.orderInfo.btns?.includes('comment')"
  289. @tap="onComment(state.orderInfo.order_sn)"
  290. >{{$t('order.detail.comment')}}</button
  291. >
  292. <button
  293. v-if="state.orderInfo.btns?.includes('invoice')"
  294. class="ss-reset-button cancel-btn"
  295. @tap.stop="onOrderInvoice(state.orderInfo.invoice?.id)"
  296. >
  297. {{$t('order.detail.viewInvoice')}}
  298. </button>
  299. <button
  300. v-if="state.orderInfo.btns?.includes('re_apply_refund')"
  301. class="ss-reset-button cancel-btn"
  302. @tap.stop="onRefund(state.orderInfo.id)"
  303. >
  304. {{$t('order.detail.refundAgain')}}
  305. </button>
  306. </view>
  307. </su-fixed>
  308. </s-layout>
  309. </template>
  310. <script setup>
  311. import sheep from '@/sheep';
  312. import { onLoad } from '@dcloudio/uni-app';
  313. import { computed, reactive } from 'vue';
  314. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  315. const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/order/order_bg.png');
  316. const state = reactive({
  317. orderInfo: {},
  318. });
  319. const addressText = computed(() => {
  320. let data = state.orderInfo.address;
  321. if (data) {
  322. return `${data.province_name} ${data.city_name} ${data.district_name} ${data.address}`;
  323. }
  324. return '';
  325. });
  326. // 复制
  327. const onCopy = () => {
  328. sheep.$helper.copyText(state.orderInfo.order_sn);
  329. };
  330. //退款总额
  331. const refundFee = computed(() => {
  332. let refundFee = 0;
  333. state.orderInfo.items?.forEach((i) => {
  334. refundFee += Number(i.refund_fee);
  335. });
  336. return refundFee;
  337. });
  338. // 去支付
  339. function onPay(orderSN) {
  340. sheep.$router.go('/pages/pay/index', {
  341. orderSN,
  342. });
  343. }
  344. function onGoodsDetail(id) {
  345. sheep.$router.go('/pages/goods/index', { id });
  346. }
  347. // 取消订单
  348. async function onCancel(orderId) {
  349. uni.showModal({
  350. title: $t('order.detail.tips'),
  351. content: $t('order.detail.tipsCancleOrder'),
  352. success: async function (res) {
  353. if (res.confirm) {
  354. const { code, data } = await sheep.$api.order.cancel(orderId);
  355. if (code === 1) {
  356. getOrderDetail(data.order_sn);
  357. }
  358. }
  359. },
  360. });
  361. }
  362. // 申请退款
  363. async function onRefund(orderId) {
  364. uni.showModal({
  365. title: $t('order.detail.tips'),
  366. content: $t('order.detail.tipsRefund'),
  367. success: async function (res) {
  368. if (res.confirm) {
  369. const { code, data } = await sheep.$api.order.applyRefund(orderId);
  370. if (code === 1) {
  371. getOrderDetail(data.order_sn);
  372. }
  373. }
  374. },
  375. });
  376. }
  377. // 查看物流
  378. async function onExpress(orderId) {
  379. sheep.$router.go('/pages/order/express/list', {
  380. orderId,
  381. });
  382. }
  383. // 确认收货
  384. async function onConfirm(orderId) {
  385. const { code, data } = await sheep.$api.order.confirm(orderId);
  386. if (code === 1) {
  387. getOrderDetail(data.order_sn);
  388. }
  389. }
  390. // 查看发票
  391. function onOrderInvoice(invoiceId) {
  392. sheep.$router.go('/pages/order/invoice', {
  393. invoiceId,
  394. });
  395. }
  396. // 配送方式详情
  397. function onDetail(item) {
  398. sheep.$router.go('/pages/order/dispatch/content', {
  399. id: item.order_id,
  400. item_id: item.id,
  401. });
  402. }
  403. // 评价
  404. function onComment(orderSN) {
  405. uni.$once('SELECT_INVOICE', (e) => {
  406. state.invoiceInfo = e.invoiceInfo;
  407. });
  408. sheep.$router.go('/pages/goods/comment/add', {
  409. orderSN,
  410. });
  411. }
  412. async function getOrderDetail(id) {
  413. const { data, code } = await sheep.$api.order.detail(id);
  414. if (code === 1) {
  415. state.orderInfo = data;
  416. } else {
  417. sheep.$router.back();
  418. }
  419. }
  420. onLoad(async (options) => {
  421. let id = '';
  422. if (options.orderSN) {
  423. id = options.orderSN;
  424. }
  425. if (options.id) {
  426. id = options.id;
  427. }
  428. getOrderDetail(id);
  429. });
  430. </script>
  431. <style lang="scss" scoped>
  432. .score-img {
  433. width: 36rpx;
  434. height: 36rpx;
  435. margin: 0 4rpx;
  436. }
  437. .apply-btn {
  438. width: 140rpx;
  439. height: 50rpx;
  440. border-radius: 25rpx;
  441. font-size: 24rpx;
  442. border: 2rpx solid #dcdcdc;
  443. line-height: normal;
  444. margin-left: 16rpx;
  445. }
  446. .state-box {
  447. color: rgba(#fff, 0.9);
  448. width: 100%;
  449. background: v-bind(headerBg) no-repeat,
  450. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  451. background-size: 750rpx 100%;
  452. box-sizing: border-box;
  453. .state-img {
  454. width: 60rpx;
  455. height: 60rpx;
  456. margin-right: 20rpx;
  457. }
  458. }
  459. .order-address-box {
  460. background-color: #fff;
  461. border-radius: 10rpx;
  462. margin: -50rpx 20rpx 16rpx 20rpx;
  463. padding: 44rpx 34rpx 42rpx 20rpx;
  464. font-size: 30rpx;
  465. box-sizing: border-box;
  466. font-weight: 500;
  467. color: rgba(51, 51, 51, 1);
  468. .address-username {
  469. margin-right: 20rpx;
  470. }
  471. .address-detail {
  472. font-size: 26rpx;
  473. font-weight: 500;
  474. color: rgba(153, 153, 153, 1);
  475. margin-top: 20rpx;
  476. }
  477. }
  478. .detail-goods {
  479. border-radius: 10rpx;
  480. margin: 0 20rpx 20rpx 20rpx;
  481. .order-list {
  482. margin-bottom: 20rpx;
  483. background-color: #fff;
  484. .order-card {
  485. padding: 20rpx 0;
  486. .order-sku {
  487. font-size: 24rpx;
  488. font-weight: 400;
  489. color: rgba(153, 153, 153, 1);
  490. width: 450rpx;
  491. margin-bottom: 20rpx;
  492. .order-num {
  493. margin-right: 10rpx;
  494. }
  495. }
  496. .tag-btn {
  497. margin-left: 16rpx;
  498. font-size: 24rpx;
  499. height: 36rpx;
  500. color: var(--ui-BG-Main);
  501. border: 2rpx solid var(--ui-BG-Main);
  502. border-radius: 14rpx;
  503. padding: 0 4rpx;
  504. }
  505. }
  506. }
  507. }
  508. // 订单信息。
  509. .notice-box {
  510. background: #fff;
  511. border-radius: 10rpx;
  512. margin: 0 20rpx 20rpx 20rpx;
  513. .notice-box__head {
  514. font-size: 30rpx;
  515. font-weight: 500;
  516. color: rgba(51, 51, 51, 1);
  517. line-height: 80rpx;
  518. border-bottom: 1rpx solid #dfdfdf;
  519. padding: 0 25rpx;
  520. }
  521. .notice-box__content {
  522. padding: 20rpx;
  523. .self-pickup-box {
  524. width: 100%;
  525. .self-pickup--img {
  526. width: 200rpx;
  527. height: 200rpx;
  528. margin: 40rpx 0;
  529. }
  530. }
  531. }
  532. .notice-item,
  533. .notice-item--center {
  534. display: flex;
  535. align-items: center;
  536. line-height: normal;
  537. margin-bottom: 24rpx;
  538. .title {
  539. font-size: 28rpx;
  540. color: #999;
  541. }
  542. .detail {
  543. font-size: 28rpx;
  544. color: #333;
  545. flex: 1;
  546. }
  547. }
  548. }
  549. .copy-btn {
  550. width: 100rpx;
  551. line-height: 50rpx;
  552. border-radius: 25rpx;
  553. padding: 0;
  554. background: rgba(238, 238, 238, 1);
  555. font-size: 22rpx;
  556. font-weight: 400;
  557. color: rgba(51, 51, 51, 1);
  558. }
  559. // 订单价格信息
  560. .order-price-box {
  561. background-color: #fff;
  562. border-radius: 10rpx;
  563. padding: 20rpx;
  564. margin: 0 20rpx 20rpx 20rpx;
  565. .notice-item {
  566. line-height: 70rpx;
  567. .title {
  568. font-size: 28rpx;
  569. color: #999;
  570. }
  571. .detail {
  572. font-size: 28rpx;
  573. color: #333;
  574. font-family: OPPOSANS;
  575. }
  576. }
  577. .all-rpice-item {
  578. justify-content: flex-end;
  579. align-items: center;
  580. .title {
  581. font-size: 26rpx;
  582. font-weight: 500;
  583. color: #333333;
  584. line-height: normal;
  585. }
  586. .all-price {
  587. font-size: 26rpx;
  588. font-family: OPPOSANS;
  589. line-height: normal;
  590. color: $red;
  591. }
  592. }
  593. }
  594. // 底部
  595. .footer-box {
  596. height: 100rpx;
  597. width: 100%;
  598. box-sizing: border-box;
  599. border-radius: 10rpx;
  600. padding-right: 20rpx;
  601. .cancel-btn {
  602. width: 160rpx;
  603. height: 60rpx;
  604. background: #eeeeee;
  605. border-radius: 30rpx;
  606. margin-right: 20rpx;
  607. font-size: 26rpx;
  608. font-weight: 400;
  609. color: #333333;
  610. }
  611. .pay-btn {
  612. width: 160rpx;
  613. height: 60rpx;
  614. font-size: 26rpx;
  615. border-radius: 30rpx;
  616. font-weight: 500;
  617. color: #fff;
  618. margin-right: 20rpx;
  619. }
  620. }
  621. </style>