fix(order): 服务端分页后状态变更同步当前 tab,取消/支付/验收/退款后不在本 tab 的订单立即移除

- 避免分页+服务端筛选后,已取消/已完成订单仍停留在原 tab 的回归
这个提交包含在:
xcbyy
2026-10-22 11:29:31 +08:00
父节点 d876288394
当前提交 ef61a7638a

查看文件

@@ -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' });
}
}