diff --git a/front/templates/payPage.html b/front/templates/payPage.html index 26d9acc..bf5dd97 100644 --- a/front/templates/payPage.html +++ b/front/templates/payPage.html @@ -177,7 +177,10 @@ // 处理支付回调 function handlePaymentCallback() { const id = getQueryParam('no'); - if (!id) return; + if (!id) { + closeLoading(); + return; + }; // 查询订单状态 fetch(`/pay/front/api/v1/payPage/query?no=${id}`, { @@ -188,6 +191,7 @@ return await response.json(); }) .then(data => { + closeLoading(); switch(data.status) { case 2: // 处理中 handlePaymentCallback(); // 重查状态 @@ -198,7 +202,6 @@ } break; default: // 其他状态(待支付/失败/关闭) - closeLoading() fetchPaymentMethods(); // window.location.reload(); } @@ -230,12 +233,12 @@ } }) .then(data => { + closeLoading(); // 处理返回的数据,例如渲染支付方式列表 if (data === null || data.data.length === 0) { const pay = document.getElementById('pay'); pay.innerHTML = '

支付环境异常,请检查

'; } else if (data.data.length === 1) { - if(localStorage.getItem('auto-redirect') == 2){ // 如果有自动跳转标记,展示支付界面 renderPaymentMethods(data.data); @@ -250,12 +253,13 @@ } }) .catch(error => { - console.error('获取支付方式失败:', error); closeLoading(); + console.error('获取支付方式失败:', error); const pay = document.getElementById('pay'); pay.innerHTML = '

获取支付方式失败,请刷新重试

'; }); } else { + closeLoading(); console.error('Order no not found in URL'); } }