fix: goPay 加载状态、轮询 5min 超时;成功页已有小程序引导
This commit is contained in:
@@ -382,6 +382,8 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
|
|||||||
const API_BASE = ''; // 同源
|
const API_BASE = ''; // 同源
|
||||||
let currentShortCode = '';
|
let currentShortCode = '';
|
||||||
let pollTimer = null;
|
let pollTimer = null;
|
||||||
|
let pollRetryCount = 0;
|
||||||
|
const POLL_MAX_RETRIES = 150; // 2s * 150 = 5min 超时
|
||||||
let jwt = '';
|
let jwt = '';
|
||||||
let isPaidActive = false;
|
let isPaidActive = false;
|
||||||
let paidExpiresAt = null;
|
let paidExpiresAt = null;
|
||||||
@@ -426,6 +428,15 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
|
|||||||
|
|
||||||
async function pollLoginStatus() {
|
async function pollLoginStatus() {
|
||||||
if (!currentShortCode) return;
|
if (!currentShortCode) return;
|
||||||
|
|
||||||
|
pollRetryCount++;
|
||||||
|
if (pollRetryCount > POLL_MAX_RETRIES) {
|
||||||
|
clearInterval(pollTimer);
|
||||||
|
document.getElementById('scanStatus').textContent = '登录码已过期,请重新获取';
|
||||||
|
document.getElementById('scanStatus').className = 'scan-status waiting';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(API_BASE + '/payment/login-status?code=' + encodeURIComponent(currentShortCode));
|
const resp = await fetch(API_BASE + '/payment/login-status?code=' + encodeURIComponent(currentShortCode));
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
@@ -503,7 +514,12 @@ pub async fn payment_index() -> Result<HttpResponse, AppError> {
|
|||||||
showError('请先登录');
|
showError('请先登录');
|
||||||
return;
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user