fix(order): 解决支付取消后加载状态未正确重置问题

- 在支付流程中添加 skipFinallyResetPayLoading 标志来控制加载状态
- 检测用户取消支付情况并跳转到待付款订单列表页面
- 优化支付取消后的页面导航逻辑,支持 redirectTo 和 navigateTo 两种方式
- 修改订单列表中的按钮文案"取消订单"为"取消"
- 修改订单列表中的按钮文案"立即支付"为"继续支付"
This commit is contained in:
2026-03-08 10:41:00 +08:00
parent fae144549e
commit 86f7506422
2 changed files with 29 additions and 3 deletions

View File

@@ -430,6 +430,7 @@ const OrderConfirm = () => {
* 统一支付入口 * 统一支付入口
*/ */
const onPay = async (goods: ShopGoods) => { const onPay = async (goods: ShopGoods) => {
let skipFinallyResetPayLoading = false
try { try {
setPayLoading(true) setPayLoading(true)
@@ -603,6 +604,29 @@ const OrderConfirm = () => {
// }) // })
} catch (error: any) { } catch (error: any) {
const message = String(error?.message || '') const message = String(error?.message || '')
const isUserCancelPay =
message.includes('用户取消支付') ||
message.includes('取消支付') ||
message.toLowerCase().includes('requestpayment:fail cancel') ||
message.toLowerCase().includes('cancel')
// 用户取消支付:跳转到待付款列表,方便继续支付
if (isUserCancelPay) {
skipFinallyResetPayLoading = true
setPayLoading(false)
const url = '/user/order/order?statusFilter=0'
try {
await Taro.redirectTo({ url })
} catch (_e) {
try {
await Taro.navigateTo({ url })
} catch (_e2) {
// ignore
}
}
return
}
const isOutOfDeliveryRange = const isOutOfDeliveryRange =
message.includes('不在配送范围') || message.includes('不在配送范围') ||
message.includes('配送范围') || message.includes('配送范围') ||
@@ -632,8 +656,10 @@ const OrderConfirm = () => {
Taro.showToast({ title: message || '支付失败,请重试', icon: 'none' }) Taro.showToast({ title: message || '支付失败,请重试', icon: 'none' })
} }
} finally { } finally {
if (!skipFinallyResetPayLoading) {
setPayLoading(false) setPayLoading(false)
} }
}
}; };
// 统一的数据加载函数 // 统一的数据加载函数

View File

@@ -820,12 +820,12 @@ function OrderList(props: OrderListProps) {
<Button size={'small'} onClick={(e) => { <Button size={'small'} onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
void cancelOrder(item); void cancelOrder(item);
}}></Button> }}></Button>
{(!item.createTime || !isPaymentExpired(item.createTime, 24)) && ( {(!item.createTime || !isPaymentExpired(item.createTime, 24)) && (
<Button size={'small'} type="primary" onClick={(e) => { <Button size={'small'} type="primary" onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
void payOrder(item); void payOrder(item);
}}></Button> }}></Button>
)} )}
</Space> </Space>
)} )}