order-detail.vue 21 KB

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