fix: goPay 加载状态、轮询 5min 超时;成功页已有小程序引导

This commit is contained in:
2026-05-07 17:33:30 +08:00
parent df64877a5d
commit 2c66528205

View File

@@ -382,6 +382,8 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
const API_BASE = ''; // 同源
let currentShortCode = '';
let pollTimer = null;
let pollRetryCount = 0;
const POLL_MAX_RETRIES = 150; // 2s * 150 = 5min 超时
let jwt = '';
let isPaidActive = false;
let paidExpiresAt = null;
@@ -426,6 +428,15 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
async function pollLoginStatus() {
if (!currentShortCode) return;
pollRetryCount++;
if (pollRetryCount > POLL_MAX_RETRIES) {
clearInterval(pollTimer);
document.getElementById('scanStatus').textContent = '登录码已过期,请重新获取';
document.getElementById('scanStatus').className = 'scan-status waiting';
return;
}
try {
const resp = await fetch(API_BASE + '/payment/login-status?code=' + encodeURIComponent(currentShortCode));
const data = await resp.json();
@@ -503,7 +514,12 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
showError('请先登录');
return;
}
window.location.href = '/payment/page?package=' + selected + '&jwt=' + encodeURIComponent(jwt);
var btn = document.getElementById('payBtn');
btn.disabled = true;
btn.textContent = '正在跳转...';
setTimeout(function() {
window.location.href = '/payment/page?package=' + selected + '&jwt=' + encodeURIComponent(jwt);
}, 300);
}
</script>
</body>