diff --git a/pwuniapp/pages/order/list.vue b/pwuniapp/pages/order/list.vue index 256025b..a9fc36c 100644 --- a/pwuniapp/pages/order/list.vue +++ b/pwuniapp/pages/order/list.vue @@ -545,6 +545,15 @@ const getStatusText = (status, order) => { return map[status] || status; }; +// 服务端分页后,状态变化需要同步当前 tab:不在本 tab 的订单立即移除 +const applyOrderStatus = (order, status) => { + if (!order) return; + order.status = status; + if (currentTab.value !== 'ALL' && currentTab.value !== status) { + orders.value = orders.value.filter(o => o.id !== order.id); + } +}; + const cancelOrder = (id) => { uni.showModal({ title: '提示', @@ -559,9 +568,7 @@ const cancelOrder = (id) => { loadLiveOrders(); return; } - const o = orders.value.find(item => item.id === id); - if (o) o.status = 'CANCELLED'; - else orders.value = orders.value.filter(o => o.id !== id); + applyOrderStatus(orders.value.find(item => item.id === id), 'CANCELLED'); uni.showToast({ title: '订单已取消', icon: 'none' }); } } @@ -589,10 +596,8 @@ const payOrder = async (id) => { buyerId: uid }); uni.hideLoading(); - if (o) { - o.status = 'IN_SERVICE'; - o.rawStatus = '履约中'; - } + applyOrderStatus(o, 'IN_SERVICE'); + if (o) o.rawStatus = '履约中'; uni.showToast({ title: '支付成功,服务已开始', icon: 'success' }); } catch (err) { uni.hideLoading(); @@ -711,8 +716,7 @@ const submitRefundTicket = async () => { description: refundForm.value.description.trim(), evidence: refundForm.value.evidence }); - const o = orders.value.find(item => item.id === oId); - if (o) o.status = 'REFUNDING'; + applyOrderStatus(orders.value.find(item => item.id === oId), 'REFUNDING'); uni.hideLoading(); closeRefundModal(); uni.showToast({ title: '退款申诉已受理,进入争议仲裁流程', icon: 'success' }); @@ -839,8 +843,7 @@ const confirmComplete = (id) => { loadLiveOrders(); return; } - const o = orders.value.find(item => item.id === id); - if (o) o.status = 'COMPLETED'; + applyOrderStatus(orders.value.find(item => item.id === id), 'COMPLETED'); uni.showToast({ title: '已确认验收,感谢您的支持!', icon: 'success' }); } }