diff --git a/front/templates/payPage.html b/front/templates/payPage.html
index 4704c0e..7d29acb 100644
--- a/front/templates/payPage.html
+++ b/front/templates/payPage.html
@@ -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();
});
}