order-detail.vue 23 KB

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