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