order-detail.vue 24 KB

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