order-detail.vue 21 KB

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