From f83b34d1ba19403d403bdd17f83e631467c015fb Mon Sep 17 00:00:00 2001 From: zhangguoping Date: Mon, 21 Jul 2025 20:01:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20front/templates/payPage.ht?= =?UTF-8?q?ml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/templates/payPage.html | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/front/templates/payPage.html b/front/templates/payPage.html index a286d5b..0da2246 100644 --- a/front/templates/payPage.html +++ b/front/templates/payPage.html @@ -202,8 +202,8 @@ } break; default: // 其他状态(待支付/失败/关闭) - fetchPaymentMethods(); - // window.location.reload(); + alert('其他状态(待支付/失败/关闭)'); + // fetchPaymentMethods(); } }) .catch(error => { @@ -233,20 +233,26 @@ } }) .then(data => { - closeLoading(); // 处理返回的数据,例如渲染支付方式列表 if (data === null || data.data.length === 0) { + closeLoading(); const pay = document.getElementById('pay'); pay.innerHTML = '

支付环境异常,请检查

'; } else if (data.data.length === 1) { - renderPaymentMethods(data.data); + // 只有一种支付方式 + alert(`只有一种支付方式`); if(localStorage.getItem('auto-redirect') != 2){ - // 否则设置自动跳转标记,并跳转 + // 否则设置自动跳转标记 + alert(`auto-redirect:${auto-redirect},直接跳转`); localStorage.setItem('auto-redirect', 2); window.location.href = `/pay/front/api/v1/payPage/submit?pay_channel_id=${data.data[0].pay_channel_id}&no=${id}`; + }else{ + alert(`auto-redirect:${auto-redirect},展示支付页面`); + renderPaymentMethods(data.data); } } else { // 多种支付方式,展示支付界面 + closeLoading(); renderPaymentMethods(data.data); } }) @@ -341,6 +347,7 @@ // 页面加载时执行 window.onload = function() { + alert(`auto-redirect:${auto-redirect}`); if (localStorage.getItem('auto-redirect') && localStorage.getItem('auto-redirect') == 2) { handlePaymentCallback(); // 如果是支付回调且不是自动跳转,处理支付结果 } else { @@ -349,6 +356,12 @@ } }; + window.addEventListener('pageshow', function(event) { + if (event.persisted) { // 如果是从缓存加载(如返回操作) + fetchPaymentMethods(); + } + }); + {{ else}}