From 2c66528205f311ae5e38ac4dcc08c4a8001ea6f6 Mon Sep 17 00:00:00 2001 From: Milky0217 Date: Thu, 7 May 2026 17:33:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20goPay=20=E5=8A=A0=E8=BD=BD=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E3=80=81=E8=BD=AE=E8=AF=A2=205min=20=E8=B6=85?= =?UTF-8?q?=E6=97=B6=EF=BC=9B=E6=88=90=E5=8A=9F=E9=A1=B5=E5=B7=B2=E6=9C=89?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=BC=95=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/payment.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/handlers/payment.rs b/src/handlers/payment.rs index c89e913..62e2e00 100644 --- a/src/handlers/payment.rs +++ b/src/handlers/payment.rs @@ -382,6 +382,8 @@ pub async fn payment_index() -> Result { 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 { 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 { 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); }