order-detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="order-detail-page">
  3. <!-- 顶部状态栏 -->
  4. <view class="status-header">
  5. <view class="status-text" v-if="orderInfo.cancelStatus == 1">已取消</view>
  6. <view class="status-text" v-else-if="orderInfo.refundStatus == 3">交易关闭</view>
  7. <view class="status-text" v-else-if="orderInfo.refundStatus == 2">退款中</view>
  8. <view class="status-text" v-else>{{ statusText }}</view>
  9. <view class="status-desc" v-if="orderInfo.status == '2'">
  10. 订单编号:{{ orderInfo.orderId }}
  11. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  12. </view>
  13. <view class="status-desc" v-else-if="orderInfo.status == '3'">
  14. 订单编号:{{ orderInfo.orderId }}
  15. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  16. </view>
  17. <view class="status-desc-block" v-else-if="orderInfo.status == '8'">
  18. <view class="status-tip">还剩9天22时18分自动确认收货</view>
  19. <view class="status-desc-row">
  20. 订单编号:{{ orderInfo.orderId }}
  21. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  22. </view>
  23. </view>
  24. <view class="status-desc" v-else>
  25. 订单编号:{{ orderInfo.orderId }}
  26. <u-icon name="copy" size="28" @click="copyOrderNo" style="margin-left: 10rpx;"></u-icon>
  27. </view>
  28. </view>
  29. <!-- 地址信息 -->
  30. <view class="info-card address-card">
  31. <view class="icon-box">
  32. <image src="/pages-mine/static/adderss.png" style="width: 40rpx; height: 40rpx"></image>
  33. </view>
  34. <view class="address-content">
  35. <view class="user-info">
  36. <text class="name">{{ orderInfo.receiverName }}</text>
  37. <text class="mobile">{{ orderInfo.receiverMobile }}</text>
  38. </view>
  39. <view class="address-detail">{{ orderInfo.receiverAddress }}</view>
  40. </view>
  41. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  42. </view>
  43. <!-- 物流信息 (已发货/已完成/退款) -->
  44. <view class="info-card logistics-card"
  45. v-if="['8', '12', '10'].includes(String(orderInfo.status)) && orderInfo.waybillCode">
  46. <view class="icon-box">
  47. <u-icon name="car-fill" color="#38C148" size="40"></u-icon>
  48. </view>
  49. <view class="logistics-content" @click="viewLogistics">
  50. <view class="company-name">物流单号: {{ orderInfo.waybillCode }}</view>
  51. <view class="latest-trace">点击查看物流详情</view>
  52. </view>
  53. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  54. </view>
  55. <!-- 商品列表 -->
  56. <view class="info-card goods-card">
  57. <view class="goods-item" v-for="(goods, index) in orderInfo.detailVoList" :key="index">
  58. <image :src="goods.cover" mode="aspectFill" class="goods-cover"></image>
  59. <view class="goods-info">
  60. <view class="goods-title">{{ goods.bookName }}</view>
  61. <view class="goods-quality" v-if="goods.isbn">ISBN:{{ goods.isbn }}</view>
  62. <view class="price-box">
  63. <text class="price">¥{{ goods.price }}</text>
  64. <text class="num">x{{ goods.num }}</text>
  65. </view>
  66. </view>
  67. <!-- 商品级按钮,如退款 -->
  68. <view class="goods-action" v-if="['3', '8'].includes(String(orderInfo.status))">
  69. <u-button size="mini" shape="circle" plain
  70. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx;">退款</u-button>
  71. </view>
  72. <view class="goods-action" v-if="['10'].includes(String(orderInfo.status))">
  73. <u-button size="mini" shape="circle" plain disabled
  74. custom-style="margin-left: 20rpx; height: 50rpx; line-height: 50rpx; background: #f5f5f5; color: #999; border: none;">退款成功</u-button>
  75. </view>
  76. </view>
  77. <!-- 价格明细 -->
  78. <view class="price-detail">
  79. <view class="row">
  80. <text>邮费</text>
  81. <text>¥ {{ orderInfo.expressMoney || '0.00' }}</text>
  82. </view>
  83. <view class="row">
  84. <text>商品金额</text>
  85. <text class="goods-total">¥{{ orderInfo.totalMoney }}</text>
  86. </view>
  87. <view class="row">
  88. <text>优惠金额</text>
  89. <text class="discount">-¥{{ orderInfo.discountMoney || '0.00' }}</text>
  90. </view>
  91. <view class="real-pay-row">
  92. <text>实付款 ({{ orderInfo.payType == 1 ? '余额支付' : '微信支付' }})</text>
  93. <text class="real-price">¥ {{ orderInfo.payMoney }}</text>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 订单时间信息 -->
  98. <view class="info-card time-card">
  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"></urge-delivery-dialog>
  122. <!-- 占位符,防止底部按钮遮挡内容 -->
  123. <view style="height: 120rpx;"></view>
  124. </view>
  125. </template>
  126. <script>
  127. import OrderBottomBar from '../components/order-bottom-bar.vue';
  128. import CancelOrderPopup from '../components/cancel-order-popup.vue';
  129. import UrgeDeliveryDialog from '../components/urge-delivery-dialog.vue';
  130. export default {
  131. components: {
  132. OrderBottomBar,
  133. CancelOrderPopup,
  134. UrgeDeliveryDialog
  135. },
  136. data() {
  137. return {
  138. orderInfo: {
  139. status: '2',
  140. orderId: '',
  141. detailVoList: [],
  142. receiverName: '',
  143. receiverMobile: '',
  144. receiverAddress: '',
  145. expressMoney: 0,
  146. totalMoney: 0,
  147. discountMoney: 0,
  148. payMoney: 0,
  149. createTime: ''
  150. },
  151. isModifyingAddress: false
  152. };
  153. },
  154. computed: {
  155. statusText() {
  156. const map = {
  157. '1': '等待买家付款',
  158. '2': '等待卖家发货',
  159. '3': '已发货',
  160. '4': '交易完成',
  161. };
  162. return map[String(this.orderInfo.status)] || '未知状态';
  163. }
  164. },
  165. onLoad(options) {
  166. if (options.orderId) {
  167. this.loadOrderDetail(options.orderId);
  168. }
  169. // 监听地址选择
  170. uni.$on('selectAddr', this.onAddressSelected);
  171. },
  172. onUnload() {
  173. uni.$off('selectAddr', this.onAddressSelected);
  174. },
  175. methods: {
  176. onAddressSelected(addr) {
  177. if (this.isModifyingAddress && addr && addr.id) {
  178. uni.showLoading({ title: '修改中' });
  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. }, 1500);
  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. handleAction(type) {
  218. if (type === 'complaint') {
  219. uni.setStorageSync('tempComplaintOrder', this.orderInfo);
  220. uni.navigateTo({
  221. url: `/pages-car/pages/complaint?orderId=${this.orderInfo.orderId}`
  222. });
  223. return;
  224. }
  225. if (type === 'cancel') {
  226. this.$refs.cancelDialog.open(this.orderInfo.orderId);
  227. return;
  228. }
  229. if (type === 'remind') {
  230. this.$refs.urgeDialog.open(this.orderInfo);
  231. return;
  232. }
  233. if (type === 'address') {
  234. this.isModifyingAddress = true;
  235. // 兼容可能的字段差异
  236. const addressId = this.orderInfo.addressId || this.orderInfo.receiverAddressId || '';
  237. uni.navigateTo({
  238. url: `/pages-mine/pages/address/list?isSelect=1&id=${addressId}`
  239. });
  240. return;
  241. }
  242. uni.showToast({ title: `点击了${type}`, icon: 'none' });
  243. }
  244. }
  245. };
  246. </script>
  247. <style lang="scss" scoped>
  248. .order-detail-page {
  249. min-height: 100vh;
  250. background-color: #F5F5F5;
  251. padding-bottom: 20rpx;
  252. .status-header {
  253. background-color: #d1f2d8; // Light green bg
  254. padding: 40rpx 30rpx;
  255. color: #333;
  256. .status-text {
  257. font-size: 36rpx;
  258. font-weight: bold;
  259. margin-bottom: 10rpx;
  260. }
  261. .status-desc {
  262. font-size: 26rpx;
  263. color: #666;
  264. display: flex;
  265. align-items: center;
  266. }
  267. .status-desc-block {
  268. font-size: 26rpx;
  269. color: #666;
  270. .status-tip {
  271. margin-bottom: 10rpx;
  272. }
  273. .status-desc-row {
  274. display: flex;
  275. align-items: center;
  276. }
  277. }
  278. }
  279. .info-card {
  280. background-color: #fff;
  281. margin: 20rpx;
  282. border-radius: 16rpx;
  283. padding: 30rpx;
  284. display: flex;
  285. &.address-card {
  286. align-items: center;
  287. .icon-box {
  288. margin-right: 20rpx;
  289. }
  290. .address-content {
  291. flex: 1;
  292. margin-right: 20rpx;
  293. .user-info {
  294. font-size: 30rpx;
  295. font-weight: 500;
  296. margin-bottom: 10rpx;
  297. .mobile {
  298. margin-left: 20rpx;
  299. }
  300. }
  301. .address-detail {
  302. font-size: 26rpx;
  303. color: #666;
  304. line-height: 1.4;
  305. }
  306. }
  307. }
  308. &.logistics-card {
  309. align-items: center;
  310. .icon-box {
  311. margin-right: 20rpx;
  312. }
  313. .logistics-content {
  314. flex: 1;
  315. margin-right: 20rpx;
  316. .company-name {
  317. font-size: 28rpx;
  318. color: #38C148;
  319. margin-bottom: 6rpx;
  320. }
  321. .latest-trace {
  322. font-size: 26rpx;
  323. color: #333;
  324. margin-bottom: 6rpx;
  325. display: -webkit-box;
  326. -webkit-box-orient: vertical;
  327. -webkit-line-clamp: 2;
  328. overflow: hidden;
  329. }
  330. .update-time {
  331. font-size: 24rpx;
  332. color: #999;
  333. }
  334. }
  335. }
  336. &.goods-card {
  337. display: block;
  338. .goods-item {
  339. display: flex;
  340. margin-bottom: 30rpx;
  341. .goods-cover {
  342. width: 120rpx;
  343. height: 120rpx;
  344. border-radius: 8rpx;
  345. margin-right: 20rpx;
  346. background-color: #eee;
  347. }
  348. .goods-info {
  349. flex: 1;
  350. .goods-title {
  351. font-size: 28rpx;
  352. color: #333;
  353. margin-bottom: 10rpx;
  354. }
  355. .goods-quality {
  356. font-size: 24rpx;
  357. color: #999;
  358. }
  359. .price-box {
  360. margin-top: 10rpx;
  361. display: flex;
  362. justify-content: space-between;
  363. .price {
  364. font-weight: 500;
  365. }
  366. .num {
  367. color: #999;
  368. }
  369. }
  370. }
  371. .goods-action {
  372. display: flex;
  373. align-items: center;
  374. }
  375. }
  376. .price-detail {
  377. border-top: 1rpx solid #eee;
  378. padding-top: 20rpx;
  379. .row {
  380. display: flex;
  381. justify-content: space-between;
  382. font-size: 26rpx;
  383. color: #666;
  384. margin-bottom: 10rpx;
  385. .goods-total {
  386. color: #38C148;
  387. }
  388. .discount {
  389. color: #38C148;
  390. }
  391. }
  392. .real-pay-row {
  393. display: flex;
  394. justify-content: space-between;
  395. font-size: 30rpx;
  396. font-weight: 500;
  397. margin-top: 20rpx;
  398. .real-price {
  399. color: #38C148;
  400. }
  401. }
  402. }
  403. }
  404. &.time-card {
  405. display: block;
  406. .row {
  407. display: flex;
  408. justify-content: space-between;
  409. font-size: 24rpx;
  410. color: #999;
  411. margin-bottom: 10rpx;
  412. &:last-child {
  413. margin-bottom: 0;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. </style>