order-detail.vue 23 KB

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