更新 front/templates/payPage.html
This commit is contained in:
parent
8457574a8e
commit
ac48291008
|
@ -59,7 +59,7 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 100%;
|
height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-spinner {
|
.loading-spinner {
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Loading状态 -->
|
<!-- Loading状态 -->
|
||||||
<div id="loading" class="loading-container" style="display: flex;">
|
<div id="loading" class="loading-container" style="display: block;">
|
||||||
<div class="loading-spinner"></div>
|
<div class="loading-spinner"></div>
|
||||||
<p class="loading-text">支付处理中,请稍等...</p>
|
<p class="loading-text">支付处理中,请稍等...</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -214,6 +214,7 @@
|
||||||
|
|
||||||
// 获取支付方式列表
|
// 获取支付方式列表
|
||||||
function fetchPaymentMethods() {
|
function fetchPaymentMethods() {
|
||||||
|
|
||||||
const id = getQueryParam('no');
|
const id = getQueryParam('no');
|
||||||
if (id) {
|
if (id) {
|
||||||
fetch(`/pay/front/api/v1/payPage/list?id=${id}`, {
|
fetch(`/pay/front/api/v1/payPage/list?id=${id}`, {
|
||||||
|
@ -233,9 +234,9 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
closeLoading();
|
||||||
// 处理返回的数据,例如渲染支付方式列表
|
// 处理返回的数据,例如渲染支付方式列表
|
||||||
if (data === null || data.data.length === 0) {
|
if (data === null || data.data.length === 0) {
|
||||||
closeLoading();
|
|
||||||
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) {
|
||||||
|
@ -247,7 +248,6 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 多种支付方式,展示支付界面
|
// 多种支付方式,展示支付界面
|
||||||
closeLoading();
|
|
||||||
renderPaymentMethods(data.data);
|
renderPaymentMethods(data.data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -341,6 +341,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载时执行
|
// 页面加载时执行
|
||||||
|
// 监听页面可见性变化
|
||||||
|
document.addEventListener('visibilitychange', function() {
|
||||||
|
if (!document.hidden && localStorage.getItem('auto-redirect') == 1) {
|
||||||
|
// 页面从后台返回且处于支付状态
|
||||||
|
handlePaymentCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
if (localStorage.getItem('auto-redirect') && localStorage.getItem('auto-redirect') == 2) {
|
if (localStorage.getItem('auto-redirect') && localStorage.getItem('auto-redirect') == 2) {
|
||||||
handlePaymentCallback(); // 如果是支付回调且不是自动跳转,处理支付结果
|
handlePaymentCallback(); // 如果是支付回调且不是自动跳转,处理支付结果
|
||||||
|
@ -350,7 +358,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{ else}}
|
{{ else}}
|
||||||
|
@ -359,6 +366,7 @@
|
||||||
<div class="payment-info" style="text-align: center;">
|
<div class="payment-info" style="text-align: center;">
|
||||||
<h2 style="color: #ff0000;">支付异常</h2>
|
<h2 style="color: #ff0000;">支付异常</h2>
|
||||||
<p>{{.message}}</p>
|
<p>{{.message}}</p>
|
||||||
|
<button onclick="window.location.href='/'">返回</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue