order-detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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="../static/adderss.png" style="width: 40rpx; height: 40rpx"></image>
  30. </view>
  31. <view class="address-content">
  32. <view class="express-row"
  33. v-if="['3', '4', '8', '12', '10'].includes(String(orderInfo.status)) && orderInfo.waybillCode"
  34. @click.stop="viewLogistics">
  35. <view class="express-name">{{ orderInfo.expressName || '快递' }}({{ orderInfo.waybillCode }})</view>
  36. </view>
  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 goods-card">
  47. <view class="goods-item" v-for="(goods, index) in orderInfo.detailVoList" :key="index">
  48. <image :src="goods.cover" mode="aspectFill" class="goods-cover"></image>
  49. <view class="goods-info">
  50. <view class="goods-title">{{ goods.bookName }}</view>
  51. <view class="goods-quality" v-if="goods.conditionType || goods.bookConditionType">品相:{{ (goods.conditionType || goods.bookConditionType) | conditionText }}</view>
  52. <view class="price-box">
  53. <text class="price">¥{{ goods.price }}</text>
  54. <text class="num">x{{ goods.num }}</text>
  55. </view>
  56. </view>
  57. <!-- 商品级按钮 -->
  58. <view class="goods-action">
  59. <u-button v-if="goods.refundOrderId" size="mini" shape="circle" plain
  60. @click="goToRefundDetail(goods.refundOrderId)"
  61. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; color: #333; border-color: #ccc;">查看详情</u-button>
  62. <u-button v-show="!goods.refundOrderId" size="mini" shape="circle" plain @click="applyRefund(goods)"
  63. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; color: #333; border-color: #ccc;">申请售后</u-button>
  64. </view>
  65. </view>
  66. <!-- 价格明细 -->
  67. <view class="price-detail">
  68. <view class="row">
  69. <text>邮费</text>
  70. <text>¥ {{ orderInfo.expressMoney || '0.00' }}</text>
  71. </view>
  72. <view class="row">
  73. <text>商品金额</text>
  74. <text class="goods-total">¥{{ (orderInfo.totalMoney - (orderInfo.expressMoney || 0)).toFixed(2) }}</text>
  75. </view>
  76. <view class="row">
  77. <text>优惠金额</text>
  78. <text class="discount">-¥{{ orderInfo.discountMoney || '0.00' }}</text>
  79. </view>
  80. <view class="divider"></view>
  81. <view class="real-pay-row">
  82. <text>实付款 ({{ orderInfo.payType == 1 ? '余额支付' : '微信支付' }})</text>
  83. <text class="real-price">¥ {{ orderInfo.payMoney }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 订单时间及其他信息 -->
  88. <view class="info-card time-card">
  89. <view class="row" v-if="orderInfo.outOfStock">
  90. <text class="label">如遇缺货</text>
  91. <text class="value" style="color: #ff4500; font-weight: 500;">{{ outOfStockText }}</text>
  92. </view>
  93. <view class="row">
  94. <text class="label">下单时间</text>
  95. <text class="value">{{ orderInfo.createTime }}</text>
  96. </view>
  97. <view class="row" v-if="orderInfo.payTime">
  98. <text class="label">付款时间</text>
  99. <text class="value">{{ orderInfo.payTime }}</text>
  100. </view>
  101. <view class="row" v-if="orderInfo.deliveryTime">
  102. <text class="label">发货时间</text>
  103. <text class="value">{{ orderInfo.deliveryTime }}</text>
  104. </view>
  105. <view class="row" v-if="orderInfo.finishTime">
  106. <text class="label">完成时间</text>
  107. <text class="value">{{ orderInfo.finishTime }}</text>
  108. </view>
  109. </view>
  110. <!-- 底部操作栏 -->
  111. <order-bottom-bar :orderInfo="orderInfo" @action="handleAction"></order-bottom-bar>
  112. <!-- 取消订单弹窗 -->
  113. <cancel-order-popup ref="cancelDialog" @success="loadOrderDetail(orderInfo.orderId)"></cancel-order-popup>
  114. <!-- 催发货弹窗 -->
  115. <urge-delivery-dialog ref="urgeDialog" @success="loadOrderDetail(orderInfo.orderId)"></urge-delivery-dialog>
  116. <!-- 极速退款弹窗 -->
  117. <fast-refund-dialog ref="refundDialog" @refresh="loadOrderDetail(orderInfo.orderId)"></fast-refund-dialog>
  118. <!-- 占位符,防止底部按钮遮挡内容 -->
  119. <view style="height: 120rpx;"></view>
  120. </view>
  121. </template>
  122. <script>
  123. import OrderBottomBar from '../components/order-bottom-bar.vue';
  124. import CancelOrderPopup from '../components/cancel-order-popup.vue';
  125. import UrgeDeliveryDialog from '../components/urge-delivery-dialog.vue';
  126. import FastRefundDialog from '../components/fast-refund-dialog.vue';
  127. export default {
  128. components: {
  129. OrderBottomBar,
  130. CancelOrderPopup,
  131. UrgeDeliveryDialog,
  132. FastRefundDialog
  133. },
  134. data() {
  135. return {
  136. orderId: '',
  137. orderInfo: {
  138. status: '2',
  139. orderId: '',
  140. detailVoList: [],
  141. receiverName: '',
  142. receiverMobile: '',
  143. receiverAddress: '',
  144. expressMoney: 0,
  145. totalMoney: 0,
  146. discountMoney: 0,
  147. payMoney: 0,
  148. createTime: ''
  149. },
  150. isModifyingAddress: false,
  151. };
  152. },
  153. computed: {
  154. statusText() {
  155. //订单状态:1-待付款 2-待发货 3-待收货 4-已完成 5-已取消 6-退款中 7-已退款
  156. const map = {
  157. '1': '等待买家付款',
  158. '2': '等待卖家发货',
  159. '3': '已发货',
  160. '4': '交易完成',
  161. '5': '已取消',
  162. '6': '退款中',
  163. '7': '交易关闭'
  164. };
  165. return map[String(this.orderInfo.status)] || '未知状态';
  166. },
  167. outOfStockText() {
  168. const map = {
  169. '1': '缺货时电话与我沟通',
  170. '2': '其他商品继续发货(缺货商品退款)',
  171. '3': '有缺货直接取消订单'
  172. };
  173. return map[String(this.orderInfo.outOfStock)] || '其他商品继续发货(缺货商品退款)';
  174. }
  175. },
  176. onLoad(options) {
  177. if (options.orderId) {
  178. this.orderId = options.orderId;
  179. }
  180. // 监听地址选择
  181. uni.$on('selectAddr', this.onAddressSelected);
  182. },
  183. onShow() {
  184. if (this.orderId) {
  185. this.loadOrderDetail(this.orderId);
  186. }
  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: #EBF8EE;
  379. padding: 40rpx 30rpx 60rpx;
  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. .copy-icon {
  392. width: 32rpx;
  393. height: 32rpx;
  394. margin-left: 10rpx;
  395. }
  396. }
  397. .status-desc-block {
  398. .status-tip {
  399. font-size: 26rpx;
  400. color: #e02020;
  401. margin-bottom: 10rpx;
  402. }
  403. .status-desc-row {
  404. font-size: 26rpx;
  405. color: #666;
  406. display: flex;
  407. align-items: center;
  408. .copy-icon {
  409. width: 32rpx;
  410. height: 32rpx;
  411. margin-left: 10rpx;
  412. }
  413. }
  414. }
  415. }
  416. .info-card {
  417. background-color: #fff;
  418. margin: 20rpx;
  419. border-radius: 16rpx;
  420. padding: 30rpx;
  421. display: flex;
  422. &.address-card {
  423. align-items: center;
  424. .icon-box {
  425. margin-right: 20rpx;
  426. }
  427. .address-content {
  428. flex: 1;
  429. margin-right: 20rpx;
  430. .express-row {
  431. display: flex;
  432. align-items: center;
  433. padding-bottom: 15rpx;
  434. .express-name {
  435. font-size: 28rpx;
  436. color: #38C148;
  437. font-weight: 500;
  438. }
  439. }
  440. .user-info {
  441. font-size: 30rpx;
  442. font-weight: 500;
  443. margin-bottom: 10rpx;
  444. .mobile {
  445. margin-left: 20rpx;
  446. }
  447. }
  448. .address-detail {
  449. font-size: 26rpx;
  450. color: #666;
  451. line-height: 1.4;
  452. }
  453. }
  454. }
  455. &.goods-card {
  456. display: block;
  457. .goods-item {
  458. display: flex;
  459. margin-bottom: 30rpx;
  460. .goods-cover {
  461. width: 120rpx;
  462. height: 120rpx;
  463. border-radius: 8rpx;
  464. margin-right: 20rpx;
  465. background-color: #eee;
  466. }
  467. .goods-info {
  468. flex: 1;
  469. .goods-title {
  470. font-size: 28rpx;
  471. color: #333;
  472. margin-bottom: 10rpx;
  473. }
  474. .goods-quality {
  475. font-size: 24rpx;
  476. color: #999;
  477. }
  478. .price-box {
  479. margin-top: 10rpx;
  480. display: flex;
  481. justify-content: space-between;
  482. .price {
  483. font-weight: 500;
  484. }
  485. .num {
  486. color: #999;
  487. }
  488. }
  489. }
  490. .goods-action {
  491. display: flex;
  492. align-items: center;
  493. }
  494. }
  495. .price-detail {
  496. margin-top: 30rpx;
  497. .row {
  498. display: flex;
  499. justify-content: space-between;
  500. font-size: 26rpx;
  501. color: #666;
  502. margin-bottom: 20rpx;
  503. .goods-total {
  504. color: #38C148;
  505. }
  506. .discount {
  507. color: #38C148;
  508. }
  509. }
  510. .divider {
  511. height: 1rpx;
  512. background-color: #eee;
  513. margin: 20rpx 0;
  514. }
  515. .real-pay-row {
  516. display: flex;
  517. justify-content: space-between;
  518. align-items: center;
  519. font-size: 28rpx;
  520. color: #333;
  521. font-weight: bold;
  522. margin-top: 10rpx;
  523. .real-price {
  524. color: #38C148;
  525. font-size: 32rpx;
  526. }
  527. }
  528. }
  529. }
  530. &.time-card {
  531. display: block;
  532. .row {
  533. display: flex;
  534. justify-content: space-between;
  535. font-size: 24rpx;
  536. color: #999;
  537. margin-bottom: 10rpx;
  538. &:last-child {
  539. margin-bottom: 0;
  540. }
  541. }
  542. }
  543. }
  544. }
  545. </style>