detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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_invalid' ? '拼团详情' : '邀请拼团' }}
  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. </view>
  214. </su-fixed>
  215. </s-layout>
  216. </template>
  217. <script setup>
  218. import sheep from '@/sheep';
  219. import { onLoad } from '@dcloudio/uni-app';
  220. import { computed, reactive } from 'vue';
  221. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  222. const state = reactive({
  223. orderInfo: {},
  224. });
  225. const addressText = computed(() => {
  226. let data = state.orderInfo.address;
  227. if (data) {
  228. return `${data.province_name} ${data.city_name} ${data.district_name} ${data.address}`;
  229. }
  230. return '';
  231. });
  232. // 复制
  233. const onCopy = () => {
  234. sheep.$helper.copyText(state.orderInfo.order_sn);
  235. };
  236. //退款总额
  237. const refundFee = computed(() => {
  238. let refundFee = 0;
  239. state.orderInfo.items?.forEach((i) => {
  240. refundFee += Number(i.refund_fee);
  241. });
  242. return refundFee;
  243. });
  244. // 去支付
  245. function onPay(orderSN) {
  246. sheep.$router.go('/pages/pay/index', {
  247. orderSN,
  248. });
  249. }
  250. function onGoodsDetail(id) {
  251. sheep.$router.go('/pages/goods/index', { id });
  252. }
  253. // 取消订单
  254. async function onCancel(orderId) {
  255. const { error, data } = await sheep.$api.order.cancel(orderId);
  256. if (error === 0) {
  257. getOrderDetail(data.order_sn);
  258. }
  259. }
  260. // 申请退款
  261. async function onRefund(orderId) {
  262. uni.showModal({
  263. title: '提示',
  264. content: '确定要申请退款吗?',
  265. success: async function (res) {
  266. if (res.confirm) {
  267. const { error, data } = await sheep.$api.order.applyRefund(orderId);
  268. if (error === 0) {
  269. getOrderDetail(data.order_sn);
  270. }
  271. }
  272. },
  273. });
  274. }
  275. // 查看物流
  276. async function onExpress(orderId) {
  277. sheep.$router.go('/pages/order/express/list', {
  278. orderId,
  279. });
  280. }
  281. // 确认收货
  282. async function onConfirm(orderId) {
  283. const { error, data } = await sheep.$api.order.confirm(orderId);
  284. if (error === 0) {
  285. getOrderDetail(data.order_sn);
  286. }
  287. }
  288. // 评价
  289. function onComment(orderSN) {
  290. uni.$once('SELECT_INVOICE', (e) => {
  291. state.invoiceInfo = e.invoiceInfo;
  292. });
  293. sheep.$router.go('/pages/goods/comment/add', {
  294. orderSN,
  295. });
  296. }
  297. async function getOrderDetail(id) {
  298. const { data, error } = await sheep.$api.order.detail(id);
  299. if (error === 0) {
  300. state.orderInfo = data;
  301. } else {
  302. sheep.$router.back();
  303. }
  304. }
  305. onLoad(async (options) => {
  306. let id = '';
  307. if (options.orderSN) {
  308. id = options.orderSN;
  309. }
  310. if (options.id) {
  311. id = options.id;
  312. }
  313. getOrderDetail(id);
  314. });
  315. </script>
  316. <style lang="scss" scoped>
  317. .score-img {
  318. width: 36rpx;
  319. height: 36rpx;
  320. margin: 0 4rpx;
  321. }
  322. .state-box {
  323. color: rgba(#fff, 0.9);
  324. width: 100%;
  325. background: v-bind("sheep.$url.css('/static/img/shop/order/order_bg.png')") no-repeat,
  326. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  327. background-size: 750rpx 100%;
  328. box-sizing: border-box;
  329. .state-img {
  330. width: 60rpx;
  331. height: 60rpx;
  332. margin-right: 20rpx;
  333. }
  334. }
  335. .order-address-box {
  336. background-color: #fff;
  337. border-radius: 10rpx;
  338. margin: -50rpx 20rpx 16rpx 20rpx;
  339. padding: 44rpx 34rpx 42rpx 20rpx;
  340. font-size: 30rpx;
  341. box-sizing: border-box;
  342. font-weight: 500;
  343. color: rgba(51, 51, 51, 1);
  344. .address-username {
  345. margin-right: 20rpx;
  346. }
  347. .address-detail {
  348. font-size: 26rpx;
  349. font-weight: 500;
  350. color: rgba(153, 153, 153, 1);
  351. margin-top: 20rpx;
  352. }
  353. }
  354. .detail-goods {
  355. border-radius: 10rpx;
  356. margin: 0 20rpx 20rpx 20rpx;
  357. .order-list {
  358. margin-bottom: 20rpx;
  359. background-color: #fff;
  360. padding: 0 20rpx;
  361. .order-card {
  362. padding: 20rpx 0;
  363. .order-sku {
  364. font-size: 24rpx;
  365. font-weight: 400;
  366. color: rgba(153, 153, 153, 1);
  367. width: 450rpx;
  368. margin-bottom: 20rpx;
  369. .order-num {
  370. margin-right: 10rpx;
  371. }
  372. }
  373. .tag-btn {
  374. margin-left: 16rpx;
  375. font-size: 24rpx;
  376. height: 36rpx;
  377. color: var(--ui-BG-Main);
  378. border: 2rpx solid var(--ui-BG-Main);
  379. border-radius: 14rpx;
  380. padding: 0 4rpx;
  381. }
  382. }
  383. }
  384. }
  385. // 订单信息。
  386. .notice-box {
  387. background: #fff;
  388. border-radius: 10rpx;
  389. margin: 0 20rpx 20rpx 20rpx;
  390. .notice-box__head {
  391. font-size: 30rpx;
  392. font-weight: 500;
  393. color: rgba(51, 51, 51, 1);
  394. line-height: 80rpx;
  395. border-bottom: 1rpx solid #dfdfdf;
  396. padding: 0 25rpx;
  397. }
  398. .notice-box__content {
  399. padding: 20rpx;
  400. .self-pickup-box {
  401. width: 100%;
  402. .self-pickup--img {
  403. width: 200rpx;
  404. height: 200rpx;
  405. margin: 40rpx 0;
  406. }
  407. }
  408. }
  409. .notice-item,
  410. .notice-item--center {
  411. display: flex;
  412. align-items: center;
  413. line-height: normal;
  414. margin-bottom: 24rpx;
  415. .title {
  416. font-size: 28rpx;
  417. color: #999;
  418. }
  419. .detail {
  420. font-size: 28rpx;
  421. color: #333;
  422. flex: 1;
  423. }
  424. .copy-btn {
  425. width: 100rpx;
  426. line-height: 50rpx;
  427. border-radius: 25rpx;
  428. padding: 0;
  429. background: rgba(238, 238, 238, 1);
  430. font-size: 22rpx;
  431. font-weight: 400;
  432. color: rgba(51, 51, 51, 1);
  433. }
  434. }
  435. }
  436. // 订单价格信息
  437. .order-price-box {
  438. background-color: #fff;
  439. border-radius: 10rpx;
  440. padding: 20rpx;
  441. margin: 0 20rpx 20rpx 20rpx;
  442. .notice-item {
  443. line-height: 70rpx;
  444. .title {
  445. font-size: 28rpx;
  446. color: #999;
  447. }
  448. .detail {
  449. font-size: 28rpx;
  450. color: #333;
  451. font-family: OPPOSANS;
  452. }
  453. }
  454. .all-rpice-item {
  455. justify-content: flex-end;
  456. align-items: center;
  457. .title {
  458. font-size: 26rpx;
  459. font-weight: 500;
  460. color: #333333;
  461. line-height: normal;
  462. }
  463. .all-price {
  464. font-size: 26rpx;
  465. font-family: OPPOSANS;
  466. line-height: normal;
  467. color: $red;
  468. }
  469. }
  470. }
  471. // 底部
  472. .footer-box {
  473. height: 100rpx;
  474. width: 100%;
  475. box-sizing: border-box;
  476. border-radius: 10rpx;
  477. padding-right: 20rpx;
  478. .cancel-btn {
  479. width: 160rpx;
  480. height: 60rpx;
  481. background: #eeeeee;
  482. border-radius: 30rpx;
  483. margin-right: 20rpx;
  484. font-size: 26rpx;
  485. font-weight: 400;
  486. color: #333333;
  487. }
  488. .pay-btn {
  489. width: 160rpx;
  490. height: 60rpx;
  491. font-size: 26rpx;
  492. border-radius: 30rpx;
  493. font-weight: 500;
  494. color: #fff;
  495. }
  496. }
  497. </style>