From 85c585ee0222197cb9ba5673ea20a70a6bf276c0 Mon Sep 17 00:00:00 2001 From: wolter <11@gmail> Date: Mon, 21 Jul 2025 14:21:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/templates/payPage.html | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) 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(); }); }