detail.vue 15 KB

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