order-detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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 === 'address') {
  235. this.isModifyingAddress = true;
  236. // 兼容可能的字段差异
  237. const addressId = this.orderInfo.addressId || this.orderInfo.receiverAddressId || '';
  238. uni.navigateTo({
  239. url: `/pages-mine/pages/address/list?isSelect=1&id=${addressId}`
  240. });
  241. return;
  242. }
  243. if (type === 'logistics') {
  244. this.viewLogistics();
  245. return;
  246. }
  247. uni.showToast({ title: `点击了${type}`, icon: 'none' });
  248. }
  249. }
  250. };
  251. </script>
  252. <style lang="scss" scoped>
  253. .order-detail-page {
  254. min-height: 100vh;
  255. background-color: #F5F5F5;
  256. padding-bottom: 20rpx;
  257. .status-header {
  258. background-color: #d1f2d8; // Light green bg
  259. padding: 40rpx 30rpx;
  260. color: #333;
  261. .status-text {
  262. font-size: 36rpx;
  263. font-weight: bold;
  264. margin-bottom: 10rpx;
  265. }
  266. .status-desc {
  267. font-size: 26rpx;
  268. color: #666;
  269. display: flex;
  270. align-items: center;
  271. }
  272. .status-desc-block {
  273. font-size: 26rpx;
  274. color: #666;
  275. .status-tip {
  276. margin-bottom: 10rpx;
  277. }
  278. .status-desc-row {
  279. display: flex;
  280. align-items: center;
  281. }
  282. }
  283. }
  284. .info-card {
  285. background-color: #fff;
  286. margin: 20rpx;
  287. border-radius: 16rpx;
  288. padding: 30rpx;
  289. display: flex;
  290. &.address-card {
  291. align-items: center;
  292. .icon-box {
  293. margin-right: 20rpx;
  294. }
  295. .address-content {
  296. flex: 1;
  297. margin-right: 20rpx;
  298. .user-info {
  299. font-size: 30rpx;
  300. font-weight: 500;
  301. margin-bottom: 10rpx;
  302. .mobile {
  303. margin-left: 20rpx;
  304. }
  305. }
  306. .address-detail {
  307. font-size: 26rpx;
  308. color: #666;
  309. line-height: 1.4;
  310. }
  311. }
  312. }
  313. &.logistics-card {
  314. align-items: center;
  315. .icon-box {
  316. margin-right: 20rpx;
  317. }
  318. .logistics-content {
  319. flex: 1;
  320. margin-right: 20rpx;
  321. .company-name {
  322. font-size: 28rpx;
  323. color: #38C148;
  324. margin-bottom: 6rpx;
  325. }
  326. .latest-trace {
  327. font-size: 26rpx;
  328. color: #333;
  329. margin-bottom: 6rpx;
  330. display: -webkit-box;
  331. -webkit-box-orient: vertical;
  332. -webkit-line-clamp: 2;
  333. overflow: hidden;
  334. }
  335. .update-time {
  336. font-size: 24rpx;
  337. color: #999;
  338. }
  339. }
  340. }
  341. &.goods-card {
  342. display: block;
  343. .goods-item {
  344. display: flex;
  345. margin-bottom: 30rpx;
  346. .goods-cover {
  347. width: 120rpx;
  348. height: 120rpx;
  349. border-radius: 8rpx;
  350. margin-right: 20rpx;
  351. background-color: #eee;
  352. }
  353. .goods-info {
  354. flex: 1;
  355. .goods-title {
  356. font-size: 28rpx;
  357. color: #333;
  358. margin-bottom: 10rpx;
  359. }
  360. .goods-quality {
  361. font-size: 24rpx;
  362. color: #999;
  363. }
  364. .price-box {
  365. margin-top: 10rpx;
  366. display: flex;
  367. justify-content: space-between;
  368. .price {
  369. font-weight: 500;
  370. }
  371. .num {
  372. color: #999;
  373. }
  374. }
  375. }
  376. .goods-action {
  377. display: flex;
  378. align-items: center;
  379. }
  380. }
  381. .price-detail {
  382. border-top: 1rpx solid #eee;
  383. padding-top: 20rpx;
  384. .row {
  385. display: flex;
  386. justify-content: space-between;
  387. font-size: 26rpx;
  388. color: #666;
  389. margin-bottom: 10rpx;
  390. .goods-total {
  391. color: #38C148;
  392. }
  393. .discount {
  394. color: #38C148;
  395. }
  396. }
  397. .real-pay-row {
  398. display: flex;
  399. justify-content: space-between;
  400. font-size: 30rpx;
  401. font-weight: 500;
  402. margin-top: 20rpx;
  403. .real-price {
  404. color: #38C148;
  405. }
  406. }
  407. }
  408. }
  409. &.time-card {
  410. display: block;
  411. .row {
  412. display: flex;
  413. justify-content: space-between;
  414. font-size: 24rpx;
  415. color: #999;
  416. margin-bottom: 10rpx;
  417. &:last-child {
  418. margin-bottom: 0;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. </style>