feat: 页面优化3

This commit is contained in:
wolter 2025-07-21 14:21:23 +08:00
parent 8293761701
commit 85c585ee02
1 changed files with 16 additions and 19 deletions

View File

@ -179,38 +179,35 @@
const id = getQueryParam('no');
if (!id) return;
showLoading();
showLoading(); // 显示加载状态
// 查订单状态
// 查订单状态
fetch(`/pay/front/api/v1/payPage/query?no=${id}`, {
method: 'POST',
})
.then(async response => {
if (response.ok) {
const data = await response.json();
return data;
}
throw new Error('请求失败');
if (!response.ok) throw new Error('请求失败');
return await response.json();
})
.then(data => {
const url = new URL(window.location.href);
switch(data.status) {
case 2:
// 订单处理中1秒后再次检查
setTimeout(handlePaymentCallback, 1000);
case 2: // 处理中
setTimeout(handlePaymentCallback, 1000); // 1秒后重查
break;
case 1: // 待支付
case 3: // 支付成功
case 4: // 支付失败
case 5: // 订单关闭
default:
// window.location.reload();
if (data.return_url) {
window.location.href = data.return_url; // 自动跳转
} else {
window.location.reload(); // 无链接则刷新
}
break;
default: // 其他状态(待支付/失败/关闭)
window.location.reload();
}
})
.catch(error => {
console.error('检查订单状态失败:', error);
// window.location.reload();
console.error('订单状态查询失败:', error);
window.location.reload();
});
}