order-detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <view class="order-detail-page">
  3. <!-- 顶部状态栏 -->
  4. <view class="status-header">
  5. <view class="status-text">{{ statusText }}</view>
  6. <view class="status-desc" v-if="orderInfo.status == '2'">
  7. 订单编号:{{ orderInfo.orderId }}
  8. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  9. </view>
  10. <view class="status-desc" v-else-if="orderInfo.status == '3'">
  11. 订单编号:{{ orderInfo.orderId }}
  12. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  13. </view>
  14. <view class="status-desc-block" v-else-if="orderInfo.status == '8'">
  15. <view class="status-tip">还剩9天22时18分自动确认收货</view>
  16. <view class="status-desc-row">
  17. 订单编号:{{ orderInfo.orderId }}
  18. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  19. </view>
  20. </view>
  21. <view class="status-desc" v-else>
  22. 订单编号:{{ orderInfo.orderId }}
  23. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  24. </view>
  25. </view>
  26. <!-- 地址信息 -->
  27. <view class="info-card address-card" @click="handleAddressClick">
  28. <view class="icon-box">
  29. <image src="/pages-mine/static/adderss.png" style="width: 40rpx; height: 40rpx"></image>
  30. </view>
  31. <view class="address-content">
  32. <view class="user-info">
  33. <text class="name">{{ orderInfo.receiverName }}</text>
  34. <text class="mobile">{{ orderInfo.receiverMobile }}</text>
  35. </view>
  36. <view class="address-detail">{{ orderInfo.receiverAddress }}</view>
  37. </view>
  38. <u-icon v-if="orderInfo.showModifyAddress == 1" name="arrow-right" color="#999" size="28"></u-icon>
  39. </view>
  40. <!-- 物流信息 (已发货/已完成/退款) -->
  41. <view class="info-card logistics-card"
  42. v-if="['8', '12', '10'].includes(String(orderInfo.status)) && orderInfo.waybillCode">
  43. <view class="icon-box">
  44. <u-icon name="car-fill" color="#38C148" size="40"></u-icon>
  45. </view>
  46. <view class="logistics-content" @click="viewLogistics">
  47. <view class="company-name">物流单号: {{ orderInfo.waybillCode }}</view>
  48. <view class="latest-trace">点击查看物流详情</view>
  49. </view>
  50. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  51. </view>
  52. <!-- 商品列表 -->
  53. <view class="info-card goods-card">
  54. <view class="goods-item" v-for="(goods, index) in orderInfo.detailVoList" :key="index">
  55. <image :src="goods.cover" mode="aspectFill" class="goods-cover"></image>
  56. <view class="goods-info">
  57. <view class="goods-title">{{ goods.bookName }}</view>
  58. <view class="goods-quality" v-if="goods.isbn">ISBN:{{ goods.isbn }}</view>
  59. <view class="price-box">
  60. <text class="price">¥{{ goods.price }}</text>
  61. <text class="num">x{{ goods.num }}</text>
  62. </view>
  63. </view>
  64. <!-- 商品级按钮 -->
  65. <view class="goods-action">
  66. <u-button v-if="goods.refundOrderId" size="mini" shape="circle" plain
  67. @click="goToRefundDetail(goods.refundOrderId)"
  68. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; color: #333; border-color: #ccc;">查看详情</u-button>
  69. <u-button v-show="!goods.refundOrderId" size="mini" shape="circle" plain @click="applyRefund(goods)"
  70. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; color: #333; border-color: #ccc;">申请售后</u-button>
  71. </view>
  72. </view>
  73. <!-- 价格明细 -->
  74. <view class="price-detail">
  75. <view class="row">
  76. <text>邮费</text>
  77. <text>¥ {{ orderInfo.expressMoney || '0.00' }}</text>
  78. </view>
  79. <view class="row">
  80. <text>商品金额</text>
  81. <text class="goods-total">¥{{ orderInfo.totalMoney }}</text>
  82. </view>
  83. <view class="row">
  84. <text>优惠金额</text>
  85. <text class="discount">-¥{{ orderInfo.discountMoney || '0.00' }}</text>
  86. </view>
  87. <view class="real-pay-row">
  88. <text>实付款 ({{ orderInfo.payType == 1 ? '余额支付' : '微信支付' }})</text>
  89. <text class="real-price">¥ {{ orderInfo.payMoney }}</text>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 订单时间信息 -->
  94. <view class="info-card time-card">
  95. <view class="row">
  96. <text class="label">下单时间</text>
  97. <text class="value">{{ orderInfo.createTime }}</text>
  98. </view>
  99. <view class="row" v-if="orderInfo.payTime">
  100. <text class="label">付款时间</text>
  101. <text class="value">{{ orderInfo.payTime }}</text>
  102. </view>
  103. <view class="row" v-if="orderInfo.deliveryTime">
  104. <text class="label">发货时间</text>
  105. <text class="value">{{ orderInfo.deliveryTime }}</text>
  106. </view>
  107. <view class="row" v-if="orderInfo.finishTime">
  108. <text class="label">完成时间</text>
  109. <text class="value">{{ orderInfo.finishTime }}</text>
  110. </view>
  111. </view>
  112. <!-- 底部操作栏 -->
  113. <order-bottom-bar :orderInfo="orderInfo" @action="handleAction"></order-bottom-bar>
  114. <!-- 取消订单弹窗 -->
  115. <cancel-order-popup ref="cancelDialog" @success="loadOrderDetail(orderInfo.orderId)"></cancel-order-popup>
  116. <!-- 催发货弹窗 -->
  117. <urge-delivery-dialog ref="urgeDialog" @success="loadOrderDetail(orderInfo.orderId)"></urge-delivery-dialog>
  118. <!-- 极速退款弹窗 -->
  119. <fast-refund-dialog ref="refundDialog" @refresh="loadOrderDetail(orderInfo.orderId)"></fast-refund-dialog>
  120. <!-- 占位符,防止底部按钮遮挡内容 -->
  121. <view style="height: 120rpx;"></view>
  122. </view>
  123. </template>
  124. <script>
  125. import OrderBottomBar from '../components/order-bottom-bar.vue';
  126. import CancelOrderPopup from '../components/cancel-order-popup.vue';
  127. import UrgeDeliveryDialog from '../components/urge-delivery-dialog.vue';
  128. import FastRefundDialog from '../components/fast-refund-dialog.vue';
  129. export default {
  130. components: {
  131. OrderBottomBar,
  132. CancelOrderPopup,
  133. UrgeDeliveryDialog,
  134. FastRefundDialog
  135. },
  136. data() {
  137. return {
  138. orderInfo: {
  139. status: '2',
  140. orderId: '',
  141. detailVoList: [],
  142. receiverName: '',
  143. receiverMobile: '',
  144. receiverAddress: '',
  145. expressMoney: 0,
  146. totalMoney: 0,
  147. discountMoney: 0,
  148. payMoney: 0,
  149. createTime: ''
  150. },
  151. isModifyingAddress: false
  152. };
  153. },
  154. computed: {
  155. statusText() {
  156. //订单状态:1-待付款 2-待发货 3-待收货 4-已完成 5-已取消 6-退款中 7-已退款
  157. const map = {
  158. '1': '等待买家付款',
  159. '2': '等待卖家发货',
  160. '3': '已发货',
  161. '4': '交易完成',
  162. '5': '已取消',
  163. '6': '退款中',
  164. '7': '交易关闭'
  165. };
  166. return map[String(this.orderInfo.status)] || '未知状态';
  167. }
  168. },
  169. onLoad(options) {
  170. if (options.orderId) {
  171. this.loadOrderDetail(options.orderId);
  172. }
  173. // 监听地址选择
  174. uni.$on('selectAddr', this.onAddressSelected);
  175. },
  176. onUnload() {
  177. uni.$off('selectAddr', this.onAddressSelected);
  178. },
  179. methods: {
  180. onAddressSelected(addr) {
  181. if (this.isModifyingAddress && addr && addr.id) {
  182. this.$u.api.modifyOrderAddressAjax({
  183. orderId: this.orderInfo.orderId,
  184. addressId: addr.id
  185. }).then(res => {
  186. uni.hideLoading();
  187. if (res.code == 200) {
  188. uni.showToast({ title: '修改成功', icon: 'success' });
  189. setTimeout(() => {
  190. this.loadOrderDetail(this.orderInfo.orderId);
  191. }, 1000);
  192. }
  193. }).finally(() => {
  194. this.isModifyingAddress = false;
  195. });
  196. }
  197. },
  198. loadOrderDetail(orderId) {
  199. uni.$u.http.get('/token/shop/order/getOrderDetail', {
  200. orderId: orderId
  201. }).then((res) => {
  202. if (res.code === 200) {
  203. this.orderInfo = res.data;
  204. }
  205. });
  206. },
  207. copyOrderNo() {
  208. uni.setClipboardData({
  209. data: String(this.orderInfo.orderId),
  210. success: () => {
  211. uni.showToast({ title: '复制成功', icon: 'none' });
  212. }
  213. });
  214. },
  215. viewLogistics() {
  216. uni.navigateTo({
  217. url: `/pages-car/pages/logistics-detail?orderId=${this.orderInfo.orderId}`
  218. });
  219. },
  220. goToRefundDetail(refundOrderId) {
  221. uni.navigateTo({
  222. url: `/pages-car/pages/refund-detail?refundOrderId=${refundOrderId}`
  223. });
  224. },
  225. applyRefund(goods) {
  226. if (this.orderInfo.status == '2') {
  227. // 待发货状态,使用极速退款弹窗
  228. this.$refs.refundDialog.open(this.orderInfo);
  229. return;
  230. }
  231. // 跳转到申请售后页面,并传递 orderId 和对应的 detailOrderId
  232. uni.navigateTo({
  233. url: `/pages-car/pages/apply-refund?orderId=${this.orderInfo.orderId}&detailOrderId=${goods.detailOrderId}`
  234. });
  235. },
  236. handleAddressClick() {
  237. if (this.orderInfo.showModifyAddress == 1) {
  238. this.handleAction('address');
  239. }
  240. },
  241. handleAction(type) {
  242. if (type === 'complaint') {
  243. uni.setStorageSync('tempComplaintOrder', this.orderInfo);
  244. uni.navigateTo({
  245. url: `/pages-car/pages/complaint?orderId=${this.orderInfo.orderId}`
  246. });
  247. return;
  248. }
  249. if (type === 'cancel') {
  250. this.$refs.cancelDialog.open(this.orderInfo.orderId);
  251. return;
  252. }
  253. if (type === 'remind') {
  254. this.$refs.urgeDialog.open(this.orderInfo);
  255. return;
  256. }
  257. if (type === 'overtime') {
  258. // 超时发货补偿
  259. uni.showModal({
  260. title: '提示',
  261. content: '确认申请超时发货补偿?',
  262. success: (res) => {
  263. if (res.confirm) {
  264. this.$u.api.sendTimeoutCompensationAjax(this.orderInfo.orderId).then(res => {
  265. if (res.code == 200) {
  266. uni.showToast({
  267. title: '申请成功',
  268. icon: 'success'
  269. });
  270. // 刷新订单详情
  271. this.loadOrderDetail(this.orderInfo.orderId);
  272. }
  273. });
  274. }
  275. }
  276. });
  277. return;
  278. }
  279. if (type === 'priceMatch') {
  280. // 降价补差
  281. uni.showModal({
  282. title: '提示',
  283. content: '确认申请降价补差?',
  284. success: (res) => {
  285. if (res.confirm) {
  286. this.$u.api.priceReductionCompensationAjax(this.orderInfo.orderId).then(res => {
  287. if (res.code == 200) {
  288. uni.showToast({
  289. title: '申请成功',
  290. icon: 'success'
  291. });
  292. // 刷新订单详情
  293. this.loadOrderDetail(this.orderInfo.orderId);
  294. }
  295. });
  296. }
  297. }
  298. });
  299. return;
  300. }
  301. if (type === 'address') {
  302. this.isModifyingAddress = true;
  303. // 兼容可能的字段差异
  304. const addressId = this.orderInfo.addressId || this.orderInfo.receiverAddressId || '';
  305. uni.navigateTo({
  306. url: `/pages-mine/pages/address/list?isSelect=1&id=${addressId}`
  307. });
  308. return;
  309. }
  310. if (type === 'logistics') {
  311. this.viewLogistics();
  312. return;
  313. }
  314. if (type === 'confirm') {
  315. uni.showModal({
  316. title: '提示',
  317. content: '是否确认收货?',
  318. success: (res) => {
  319. if (res.confirm) {
  320. uni.showLoading({ title: '处理中' });
  321. this.$u.api.confirmReceiveAjax({ orderId: this.orderInfo.orderId }).then(res => {
  322. uni.hideLoading();
  323. if (res.code == 200) {
  324. uni.showToast({ title: '收货成功', icon: 'success' });
  325. this.loadOrderDetail(this.orderInfo.orderId);
  326. }
  327. });
  328. }
  329. }
  330. });
  331. return;
  332. }
  333. if (type === 'addToCart') {
  334. uni.showLoading({ title: '加载中' });
  335. this.$u.api.orderAddToCartAjax({
  336. orderId: this.orderInfo.orderId
  337. }).then(res => {
  338. uni.hideLoading();
  339. if (res.code == 200) {
  340. uni.showToast({
  341. title: '已加入购物车',
  342. icon: 'success',
  343. duration: 3000
  344. });
  345. this.$updateCartBadge();
  346. }
  347. });
  348. return;
  349. }
  350. if (type === 'pay') {
  351. uni.navigateTo({
  352. url: `/pages-car/pages/cashier-desk?id=${this.orderInfo.orderId}`
  353. });
  354. return;
  355. }
  356. }
  357. }
  358. };
  359. </script>
  360. <style lang="scss" scoped>
  361. .order-detail-page {
  362. min-height: 100vh;
  363. background-color: #F5F5F5;
  364. padding-bottom: 20rpx;
  365. .status-header {
  366. background-color: #d1f2d8; // Light green bg
  367. padding: 40rpx 30rpx;
  368. color: #333;
  369. .status-text {
  370. font-size: 36rpx;
  371. font-weight: bold;
  372. margin-bottom: 10rpx;
  373. }
  374. .status-desc {
  375. font-size: 26rpx;
  376. color: #666;
  377. display: flex;
  378. align-items: center;
  379. }
  380. .status-desc-block {
  381. font-size: 26rpx;
  382. color: #666;
  383. .status-tip {
  384. margin-bottom: 10rpx;
  385. }
  386. .status-desc-row {
  387. display: flex;
  388. align-items: center;
  389. }
  390. }
  391. }
  392. .info-card {
  393. background-color: #fff;
  394. margin: 20rpx;
  395. border-radius: 16rpx;
  396. padding: 30rpx;
  397. display: flex;
  398. &.address-card {
  399. align-items: center;
  400. .icon-box {
  401. margin-right: 20rpx;
  402. }
  403. .address-content {
  404. flex: 1;
  405. margin-right: 20rpx;
  406. .user-info {
  407. font-size: 30rpx;
  408. font-weight: 500;
  409. margin-bottom: 10rpx;
  410. .mobile {
  411. margin-left: 20rpx;
  412. }
  413. }
  414. .address-detail {
  415. font-size: 26rpx;
  416. color: #666;
  417. line-height: 1.4;
  418. }
  419. }
  420. }
  421. &.logistics-card {
  422. align-items: center;
  423. .icon-box {
  424. margin-right: 20rpx;
  425. }
  426. .logistics-content {
  427. flex: 1;
  428. margin-right: 20rpx;
  429. .company-name {
  430. font-size: 28rpx;
  431. color: #38C148;
  432. margin-bottom: 6rpx;
  433. }
  434. .latest-trace {
  435. font-size: 26rpx;
  436. color: #333;
  437. margin-bottom: 6rpx;
  438. display: -webkit-box;
  439. -webkit-box-orient: vertical;
  440. -webkit-line-clamp: 2;
  441. overflow: hidden;
  442. }
  443. .update-time {
  444. font-size: 24rpx;
  445. color: #999;
  446. }
  447. }
  448. }
  449. &.goods-card {
  450. display: block;
  451. .goods-item {
  452. display: flex;
  453. margin-bottom: 30rpx;
  454. .goods-cover {
  455. width: 120rpx;
  456. height: 120rpx;
  457. border-radius: 8rpx;
  458. margin-right: 20rpx;
  459. background-color: #eee;
  460. }
  461. .goods-info {
  462. flex: 1;
  463. .goods-title {
  464. font-size: 28rpx;
  465. color: #333;
  466. margin-bottom: 10rpx;
  467. }
  468. .goods-quality {
  469. font-size: 24rpx;
  470. color: #999;
  471. }
  472. .price-box {
  473. margin-top: 10rpx;
  474. display: flex;
  475. justify-content: space-between;
  476. .price {
  477. font-weight: 500;
  478. }
  479. .num {
  480. color: #999;
  481. }
  482. }
  483. }
  484. .goods-action {
  485. display: flex;
  486. align-items: center;
  487. }
  488. }
  489. .price-detail {
  490. border-top: 1rpx solid #eee;
  491. padding-top: 20rpx;
  492. .row {
  493. display: flex;
  494. justify-content: space-between;
  495. font-size: 26rpx;
  496. color: #666;
  497. margin-bottom: 10rpx;
  498. .goods-total {
  499. color: #38C148;
  500. }
  501. .discount {
  502. color: #38C148;
  503. }
  504. }
  505. .real-pay-row {
  506. display: flex;
  507. justify-content: space-between;
  508. font-size: 30rpx;
  509. font-weight: 500;
  510. margin-top: 20rpx;
  511. .real-price {
  512. color: #38C148;
  513. }
  514. }
  515. }
  516. }
  517. &.time-card {
  518. display: block;
  519. .row {
  520. display: flex;
  521. justify-content: space-between;
  522. font-size: 24rpx;
  523. color: #999;
  524. margin-bottom: 10rpx;
  525. &:last-child {
  526. margin-bottom: 0;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. </style>