Procházet zdrojové kódy

fix: 将订单数据加载从onLoad移到onShow以解决页面返回时数据不刷新问题

修复多个页面中订单数据加载逻辑,将数据加载从onLoad生命周期移到onShow,确保页面返回时能正确刷新数据。同时修正退款详情页的状态显示和文案,并优化退款流程。
ylong před 2 týdny
rodič
revize
1236673c94

+ 4 - 3
pages-car/pages/my-order.vue

@@ -73,12 +73,13 @@ export default {
                 this.params = this.tabList[index].params;
             }
         }
-
-        this.loadOrders(true, this.params);
-
+        
         // 监听地址选择
         uni.$on('selectAddr', this.onAddressSelected);
     },
+    onShow() {
+        this.loadOrders(true, this.params);
+    },
     onUnload() {
         uni.$off('selectAddr', this.onAddressSelected);
     },

+ 7 - 1
pages-car/pages/order-detail.vue

@@ -151,6 +151,7 @@ export default {
     },
     data() {
         return {
+            orderId: '',
             orderInfo: {
                 status: '2',
                 orderId: '',
@@ -192,11 +193,16 @@ export default {
     },
     onLoad(options) {
         if (options.orderId) {
-            this.loadOrderDetail(options.orderId);
+            this.orderId = options.orderId;
         }
         // 监听地址选择
         uni.$on('selectAddr', this.onAddressSelected);
     },
+    onShow() {
+        if (this.orderId) {
+            this.loadOrderDetail(this.orderId);
+        }
+    },
     onUnload() {
         uni.$off('selectAddr', this.onAddressSelected);
     },

+ 20 - 14
pages-car/pages/refund-detail.vue

@@ -29,7 +29,9 @@
 						<view class="negotiation-text">
 							<view class="negotiation-title">协商修改退款金额为{{ orderInfo.disposeMoney || orderInfo.refundMoney
 							}}元</view>
-							<view class="negotiation-desc">我们愿意支持退款,若您接受修改金额,我们将立刻退款给您</view>
+							<view class="negotiation-desc" v-if="orderInfo.disposeType == 3">我们愿意支持退货退款,若您接受修改退货退款,请将退货商品寄回平台</view>
+
+							<view class="negotiation-desc" v-else>我们愿意支持退款,若您接受修改金额,我们将立刻退款给您</view>
 						</view>
 					</view>
 					<view class="negotiation-actions">
@@ -40,7 +42,7 @@
 					</view>
 				</view>
 				<!-- 退款成功金额展示 -->
-				<view class="refund-amount-box" v-if="orderInfo.status == '8'">
+				<view class="refund-amount-box" v-if="orderInfo.status == '9'">
 					<view class="amount-row">
 						<text class="label">退回余额</text>
 						<text class="value">¥{{ orderInfo.refundMoney }}</text>
@@ -105,7 +107,7 @@
 					<view class="refund-status-tag red-tag" v-if="orderInfo.status == '1'">
 						<text>退款中</text>
 					</view>
-					<view class="refund-status-tag" v-if="orderInfo.status == '6'">退款成功</view>
+					<view class="refund-status-tag" v-if="orderInfo.status == '9'">退款成功</view>
 				</view>
 			</view>
 		</view>
@@ -197,6 +199,7 @@
 <script>
 	import FloatingDrag from "@/components/floating-drag.vue";
 	import RefundHistoryPopup from "../components/refund-history-popup.vue";
+import navbarVue from '../../components/navbar/navbar.vue';
 	export default {
 		components: {
 			FloatingDrag,
@@ -289,12 +292,12 @@
 		onLoad(options) {
 			if (options.refundOrderId) {
 				this.refundOrderId = options.refundOrderId;
-				this.getDetail();
 			} else if (options.orderId) {
-				// 兼容处理:如果传入的是 orderId,尝试通过 orderId 获取退款单(如果后端支持)
-				// 或者提示错误
-				// 假设暂时用 refundOrderId
-				this.refundOrderId = options.orderId; // 尝试用这个ID
+				this.refundOrderId = options.orderId;
+			}
+		},
+		onShow() {
+			if (this.refundOrderId) {
 				this.getDetail();
 			}
 		},
@@ -309,22 +312,22 @@
 				});
 			},
 			getStatusText(status) {
-				// 状态 1-申请退款 2-审核通过 3-审核驳回 4-超时关闭 5-卖家已发货 6-已完成
-				// 状态 1-申请退款 2-协商中待用户确认 3-协商中待商家确认 4-审核通过 5-审核驳回 6-超时关闭 7-卖家已发货 8-已完成
+				// 状态 1-申请退款 2-协商中待用户确认 3-协商中待商家确认 4-审核通过 5-审核驳回 6-超时关闭 7-买家已发货 8-确认收货 9-退款成功
 				const map = {
 					'1': '请等待平台处理',
 					'2': '协商中待用户确认',
 					'3': '协商中待商家确认',
 					'4': '审核已通过,请您把书籍自行寄回',
 					'5': '审核已驳回',
-					'6': '退款关闭', // 超时关闭
-					'7': '卖家已发货', // 可能是换货场景
-					'8': '退款成功'
+					'6': '超时关闭', 
+					'7': '待平台确认收货', 
+					'8': '平台已确认收货',
+					'9': '退款成功'
 				};
 				return map[status] || '处理中';
 			},
 			copyAddress() {
-				const address = (this.orderInfo.receiverName || '张三') + ' ' + (this.orderInfo.receiverMobile || '') + ' ' + (this.orderInfo.receiverAddress || '河南省鹤壁市浚县即可获得发货单收到单方事故师范号到');
+				const address = (this.orderInfo.receiverName || '') + ' ' + (this.orderInfo.receiverMobile || '') + ' ' + (this.orderInfo.receiverAddress || '');
 				uni.setClipboardData({
 					data: address,
 					success: () => {
@@ -439,6 +442,9 @@
 											});
 											// 刷新页面
 											this.getDetail();
+											setTimeout(() => {
+												uni.navigateBack();
+											}, 1000);
 										}
 									});
 								}

+ 5 - 1
pages-mine/pages/order-detail.vue

@@ -155,7 +155,11 @@ export default {
 	onLoad(options) {
 		if (options.orderId) {
 			this.orderId = options.orderId;
-			this.getOrderInfo(options.orderId);
+		}
+	},
+	onShow() {
+		if (this.orderId) {
+			this.getOrderInfo(this.orderId);
 		}
 	},
 	methods: {

+ 4 - 1
pages-mine/pages/order-page.vue

@@ -86,13 +86,16 @@ export default {
         } else {
             this.currentTab = 0
         }
-        this.loadOrders(true, this.params)
 
         uni.$on('btnActionSuccess', () => {
             this.loadOrders(true, this.params)
         })
     },
 
+    onShow() {
+        this.loadOrders(true, this.params)
+    },
+
     onUnload() {
         uni.$off('btnActionSuccess')
     },

+ 2 - 0
pages-mine/pages/partner/order-detail.vue

@@ -80,6 +80,8 @@ export default {
             this.currentTab = this.tabList.findIndex(item => item.status === options.status)
             this.params.status = options.status
         }
+    },
+    onShow() {
         this.loadOrders(true, this.params)
     },
     methods: {