更新 front/templates/payPage.html
This commit is contained in:
parent
26d1caa42c
commit
e62a311c0e
|
@ -59,7 +59,7 @@
|
|||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
|
@ -139,7 +139,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Loading状态 -->
|
||||
<div id="loading" class="loading-container" style="display: flex;">
|
||||
<div id="loading" class="loading-container" style="display: block;">
|
||||
<div class="loading-spinner"></div>
|
||||
<p class="loading-text">支付处理中,请稍等...</p>
|
||||
</div>
|
||||
|
@ -202,8 +202,8 @@
|
|||
}
|
||||
break;
|
||||
default: // 其他状态(待支付/失败/关闭)
|
||||
alert('其他状态(待支付/失败/关闭)');
|
||||
// fetchPaymentMethods();
|
||||
fetchPaymentMethods();
|
||||
// window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -214,7 +214,9 @@
|
|||
|
||||
// 获取支付方式列表
|
||||
function fetchPaymentMethods() {
|
||||
|
||||
const id = getQueryParam('no');
|
||||
alert(id, 'zgp')
|
||||
if (id) {
|
||||
fetch(`/pay/front/api/v1/payPage/list?id=${id}`, {
|
||||
method: 'POST',
|
||||
|
@ -233,26 +235,20 @@
|
|||
}
|
||||
})
|
||||
.then(data => {
|
||||
closeLoading();
|
||||
// 处理返回的数据,例如渲染支付方式列表
|
||||
if (data === null || data.data.length === 0) {
|
||||
closeLoading();
|
||||
const pay = document.getElementById('pay');
|
||||
pay.innerHTML = '<h3>支付环境异常,请检查</h3>';
|
||||
} else if (data.data.length === 1) {
|
||||
// 只有一种支付方式
|
||||
alert(`只有一种支付方式`);
|
||||
renderPaymentMethods(data.data);
|
||||
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);
|
||||
}
|
||||
})
|
||||
|
@ -347,7 +343,6 @@
|
|||
|
||||
// 页面加载时执行
|
||||
window.onload = function() {
|
||||
alert(`auto-redirect:${localStorage.getItem('auto-redirect')}`);
|
||||
if (localStorage.getItem('auto-redirect') && localStorage.getItem('auto-redirect') == 2) {
|
||||
handlePaymentCallback(); // 如果是支付回调且不是自动跳转,处理支付结果
|
||||
} else {
|
||||
|
@ -356,13 +351,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
window.addEventListener('pageshow', function(event) {
|
||||
if (event.persisted) { // 如果是从缓存加载(如返回操作)
|
||||
alert('返回操作')
|
||||
fetchPaymentMethods();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{{ else}}
|
||||
|
|
Loading…
Reference in New Issue