order-detail.vue 24 KB

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