order-detail.vue 21 KB

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