order-detail.vue 24 KB

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