更新 front/templates/payPage.html

This commit is contained in:
zhangguoping 2025-07-21 18:01:11 +08:00
parent 4d45e6a29b
commit 240fda37a8
1 changed files with 8 additions and 4 deletions

View File

@ -177,7 +177,10 @@
// 处理支付回调 // 处理支付回调
function handlePaymentCallback() { function handlePaymentCallback() {
const id = getQueryParam('no'); const id = getQueryParam('no');
if (!id) return; if (!id) {
closeLoading();
return;
};
// 查询订单状态 // 查询订单状态
fetch(`/pay/front/api/v1/payPage/query?no=${id}`, { fetch(`/pay/front/api/v1/payPage/query?no=${id}`, {
@ -188,6 +191,7 @@
return await response.json(); return await response.json();
}) })
.then(data => { .then(data => {
closeLoading();
switch(data.status) { switch(data.status) {
case 2: // 处理中 case 2: // 处理中
handlePaymentCallback(); // 重查状态 handlePaymentCallback(); // 重查状态
@ -198,7 +202,6 @@
} }
break; break;
default: // 其他状态(待支付/失败/关闭) default: // 其他状态(待支付/失败/关闭)
closeLoading()
fetchPaymentMethods(); fetchPaymentMethods();
// window.location.reload(); // window.location.reload();
} }
@ -230,12 +233,12 @@
} }
}) })
.then(data => { .then(data => {
closeLoading();
// 处理返回的数据,例如渲染支付方式列表 // 处理返回的数据,例如渲染支付方式列表
if (data === null || data.data.length === 0) { if (data === null || data.data.length === 0) {
const pay = document.getElementById('pay'); const pay = document.getElementById('pay');
pay.innerHTML = '<h3>支付环境异常,请检查</h3>'; pay.innerHTML = '<h3>支付环境异常,请检查</h3>';
} else if (data.data.length === 1) { } else if (data.data.length === 1) {
if(localStorage.getItem('auto-redirect') == 2){ if(localStorage.getItem('auto-redirect') == 2){
// 如果有自动跳转标记,展示支付界面 // 如果有自动跳转标记,展示支付界面
renderPaymentMethods(data.data); renderPaymentMethods(data.data);
@ -250,12 +253,13 @@
} }
}) })
.catch(error => { .catch(error => {
console.error('获取支付方式失败:', error);
closeLoading(); closeLoading();
console.error('获取支付方式失败:', error);
const pay = document.getElementById('pay'); const pay = document.getElementById('pay');
pay.innerHTML = '<h3 style="color: red;">获取支付方式失败,请刷新重试</h3>'; pay.innerHTML = '<h3 style="color: red;">获取支付方式失败,请刷新重试</h3>';
}); });
} else { } else {
closeLoading();
console.error('Order no not found in URL'); console.error('Order no not found in URL');
} }
} }