order-detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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">
  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 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" v-if="['3', '8'].includes(String(orderInfo.status))">
  66. <u-button size="mini" shape="circle" plain
  67. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx;">退款</u-button>
  68. </view>
  69. <view class="goods-action" v-if="['10'].includes(String(orderInfo.status))">
  70. <u-button size="mini" shape="circle" plain disabled
  71. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; background: #f5f5f5; color: #999; border: none;">退款成功</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"></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. uni.showLoading({ title: '修改中' });
  180. this.$u.api.modifyOrderAddressAjax({
  181. orderId: this.orderInfo.orderId,
  182. addressId: addr.id
  183. }).then(res => {
  184. uni.hideLoading();
  185. if (res.code == 200) {
  186. uni.showToast({ title: '修改成功', icon: 'success' });
  187. setTimeout(() => {
  188. this.loadOrderDetail(this.orderInfo.orderId);
  189. }, 1500);
  190. }
  191. }).finally(() => {
  192. this.isModifyingAddress = false;
  193. });
  194. }
  195. },
  196. loadOrderDetail(orderId) {
  197. uni.$u.http.get('/token/shop/order/getOrderDetail', {
  198. orderId: orderId
  199. }).then((res) => {
  200. if (res.code === 200) {
  201. this.orderInfo = res.data;
  202. }
  203. });
  204. },
  205. copyOrderNo() {
  206. uni.setClipboardData({
  207. data: String(this.orderInfo.orderId),
  208. success: () => {
  209. uni.showToast({ title: '复制成功', icon: 'none' });
  210. }
  211. });
  212. },
  213. viewLogistics() {
  214. uni.navigateTo({
  215. url: `/pages-car/pages/logistics-detail?orderId=${this.orderInfo.orderId}`
  216. });
  217. },
  218. handleAction(type) {
  219. if (type === 'complaint') {
  220. uni.setStorageSync('tempComplaintOrder', this.orderInfo);
  221. uni.navigateTo({
  222. url: `/pages-car/pages/complaint?orderId=${this.orderInfo.orderId}`
  223. });
  224. return;
  225. }
  226. if (type === 'cancel') {
  227. this.$refs.cancelDialog.open(this.orderInfo.orderId);
  228. return;
  229. }
  230. if (type === 'remind') {
  231. this.$refs.urgeDialog.open(this.orderInfo);
  232. return;
  233. }
  234. if (type === 'overtime') {
  235. // 超时发货补偿
  236. uni.showModal({
  237. title: '提示',
  238. content: '确认申请超时发货补偿?',
  239. success: (res) => {
  240. if (res.confirm) {
  241. this.$u.api.sendTimeoutCompensationAjax(this.orderInfo.orderId).then(res => {
  242. if (res.code == 200) {
  243. uni.showToast({
  244. title: '申请成功',
  245. icon: 'success'
  246. });
  247. // 刷新订单详情
  248. this.loadOrderDetail(this.orderInfo.orderId);
  249. }
  250. });
  251. }
  252. }
  253. });
  254. return;
  255. }
  256. if (type === 'priceMatch') {
  257. // 降价补差
  258. uni.showModal({
  259. title: '提示',
  260. content: '确认申请降价补差?',
  261. success: (res) => {
  262. if (res.confirm) {
  263. this.$u.api.priceReductionCompensationAjax(this.orderInfo.orderId).then(res => {
  264. if (res.code == 200) {
  265. uni.showToast({
  266. title: '申请成功',
  267. icon: 'success'
  268. });
  269. // 刷新订单详情
  270. this.loadOrderDetail(this.orderInfo.orderId);
  271. }
  272. });
  273. }
  274. }
  275. });
  276. return;
  277. }
  278. if (type === 'address') {
  279. this.isModifyingAddress = true;
  280. // 兼容可能的字段差异
  281. const addressId = this.orderInfo.addressId || this.orderInfo.receiverAddressId || '';
  282. uni.navigateTo({
  283. url: `/pages-mine/pages/address/list?isSelect=1&id=${addressId}`
  284. });
  285. return;
  286. }
  287. if (type === 'logistics') {
  288. this.viewLogistics();
  289. return;
  290. }
  291. if (type === 'confirm') {
  292. uni.showModal({
  293. title: '提示',
  294. content: '是否确认收货?',
  295. success: (res) => {
  296. if (res.confirm) {
  297. uni.showLoading({ title: '处理中' });
  298. this.$u.api.confirmReceiveAjax({ orderId: this.orderInfo.orderId }).then(res => {
  299. uni.hideLoading();
  300. if (res.code == 200) {
  301. uni.showToast({ title: '收货成功', icon: 'success' });
  302. this.loadOrderDetail(this.orderInfo.orderId);
  303. }
  304. });
  305. }
  306. }
  307. });
  308. return;
  309. }
  310. if (type === 'addToCart') {
  311. uni.showLoading({ title: '加载中' });
  312. this.$u.api.orderAddToCartAjax({
  313. orderId: this.orderInfo.orderId
  314. }).then(res => {
  315. uni.hideLoading();
  316. if (res.code == 200) {
  317. uni.showToast({
  318. title: '已加入购物车',
  319. icon: 'success'
  320. });
  321. this.$updateCartBadge();
  322. }
  323. });
  324. return;
  325. }
  326. uni.showToast({ title: `点击了${type}`, icon: 'none' });
  327. }
  328. }
  329. };
  330. </script>
  331. <style lang="scss" scoped>
  332. .order-detail-page {
  333. min-height: 100vh;
  334. background-color: #F5F5F5;
  335. padding-bottom: 20rpx;
  336. .status-header {
  337. background-color: #d1f2d8; // Light green bg
  338. padding: 40rpx 30rpx;
  339. color: #333;
  340. .status-text {
  341. font-size: 36rpx;
  342. font-weight: bold;
  343. margin-bottom: 10rpx;
  344. }
  345. .status-desc {
  346. font-size: 26rpx;
  347. color: #666;
  348. display: flex;
  349. align-items: center;
  350. }
  351. .status-desc-block {
  352. font-size: 26rpx;
  353. color: #666;
  354. .status-tip {
  355. margin-bottom: 10rpx;
  356. }
  357. .status-desc-row {
  358. display: flex;
  359. align-items: center;
  360. }
  361. }
  362. }
  363. .info-card {
  364. background-color: #fff;
  365. margin: 20rpx;
  366. border-radius: 16rpx;
  367. padding: 30rpx;
  368. display: flex;
  369. &.address-card {
  370. align-items: center;
  371. .icon-box {
  372. margin-right: 20rpx;
  373. }
  374. .address-content {
  375. flex: 1;
  376. margin-right: 20rpx;
  377. .user-info {
  378. font-size: 30rpx;
  379. font-weight: 500;
  380. margin-bottom: 10rpx;
  381. .mobile {
  382. margin-left: 20rpx;
  383. }
  384. }
  385. .address-detail {
  386. font-size: 26rpx;
  387. color: #666;
  388. line-height: 1.4;
  389. }
  390. }
  391. }
  392. &.logistics-card {
  393. align-items: center;
  394. .icon-box {
  395. margin-right: 20rpx;
  396. }
  397. .logistics-content {
  398. flex: 1;
  399. margin-right: 20rpx;
  400. .company-name {
  401. font-size: 28rpx;
  402. color: #38C148;
  403. margin-bottom: 6rpx;
  404. }
  405. .latest-trace {
  406. font-size: 26rpx;
  407. color: #333;
  408. margin-bottom: 6rpx;
  409. display: -webkit-box;
  410. -webkit-box-orient: vertical;
  411. -webkit-line-clamp: 2;
  412. overflow: hidden;
  413. }
  414. .update-time {
  415. font-size: 24rpx;
  416. color: #999;
  417. }
  418. }
  419. }
  420. &.goods-card {
  421. display: block;
  422. .goods-item {
  423. display: flex;
  424. margin-bottom: 30rpx;
  425. .goods-cover {
  426. width: 120rpx;
  427. height: 120rpx;
  428. border-radius: 8rpx;
  429. margin-right: 20rpx;
  430. background-color: #eee;
  431. }
  432. .goods-info {
  433. flex: 1;
  434. .goods-title {
  435. font-size: 28rpx;
  436. color: #333;
  437. margin-bottom: 10rpx;
  438. }
  439. .goods-quality {
  440. font-size: 24rpx;
  441. color: #999;
  442. }
  443. .price-box {
  444. margin-top: 10rpx;
  445. display: flex;
  446. justify-content: space-between;
  447. .price {
  448. font-weight: 500;
  449. }
  450. .num {
  451. color: #999;
  452. }
  453. }
  454. }
  455. .goods-action {
  456. display: flex;
  457. align-items: center;
  458. }
  459. }
  460. .price-detail {
  461. border-top: 1rpx solid #eee;
  462. padding-top: 20rpx;
  463. .row {
  464. display: flex;
  465. justify-content: space-between;
  466. font-size: 26rpx;
  467. color: #666;
  468. margin-bottom: 10rpx;
  469. .goods-total {
  470. color: #38C148;
  471. }
  472. .discount {
  473. color: #38C148;
  474. }
  475. }
  476. .real-pay-row {
  477. display: flex;
  478. justify-content: space-between;
  479. font-size: 30rpx;
  480. font-weight: 500;
  481. margin-top: 20rpx;
  482. .real-price {
  483. color: #38C148;
  484. }
  485. }
  486. }
  487. }
  488. &.time-card {
  489. display: block;
  490. .row {
  491. display: flex;
  492. justify-content: space-between;
  493. font-size: 24rpx;
  494. color: #999;
  495. margin-bottom: 10rpx;
  496. &:last-child {
  497. margin-bottom: 0;
  498. }
  499. }
  500. }
  501. }
  502. }
  503. </style>