detail.vue 15 KB

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