detail.vue 16 KB

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