Display Alipay cashier QR directly
This commit is contained in:
1 parent
91abad4066
commit
804e539932
6 files changed
+66
-15
No files matched your search
+2
-2
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow"><title>MultiPay 管理后台</title>
|
||||
<link rel="stylesheet" href="/assets/app.css?v=20261102-refund">
|
||||
<link rel="stylesheet" href="/assets/app.css?v=20261102-scanqr">
|
||||
</head>
|
||||
<body class="admin-body">
|
||||
<section id="loginPage" class="login-page">
|
||||
@@ -20,6 +20,6 @@
|
||||
</section>
|
||||
<div id="toast" class="toast"></div>
|
||||
<div id="modal" class="modal hidden"><div class="modal-backdrop" data-close></div><div class="modal-card"><button class="modal-close" data-close>×</button><div id="modalContent"></div></div></div>
|
||||
<script src="/assets/admin.js?v=20261102-refund" defer></script>
|
||||
<script src="/assets/admin.js?v=20261102-scanqr" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title>安全收银台</title>
|
||||
<link rel="stylesheet" href="/assets/app.css?v=20261102-refund">
|
||||
<link rel="stylesheet" href="/assets/app.css?v=20261102-cashierqr">
|
||||
</head>
|
||||
<body class="checkout-body">
|
||||
<header class="checkout-header">
|
||||
@@ -48,6 +48,6 @@
|
||||
<div class="history-table-wrap"><table><thead><tr><th>充值时间</th><th>订单号</th><th>支付渠道</th><th>充值金额</th><th>获得积分</th></tr></thead><tbody id="historyBody"></tbody></table></div>
|
||||
</section>
|
||||
<footer class="checkout-footer"><span>支付过程受签名验证与金额校验保护</span><span>如有疑问请联系商户</span></footer>
|
||||
<script src="/assets/checkout.js?v=20261102-refund" defer></script>
|
||||
<script src="/assets/checkout.js?v=20261102-cashierqr" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
+5
-2
@@ -2,6 +2,7 @@ const $ = (selector) => document.querySelector(selector);
|
||||
const query = new URLSearchParams(location.search);
|
||||
const state = { user: null, packages: [], selectedPackage: null, selectedGateway: null, currentOrder: null };
|
||||
let pollTimer = null;
|
||||
let qrRefreshTimer = null;
|
||||
const userId = query.get('user_id') || '';
|
||||
const amountParam = query.get('amount') || '';
|
||||
const orderNo = query.get('merchant_order_no') || `PAY${Date.now().toString().slice(-10)}`;
|
||||
@@ -80,15 +81,17 @@ function renderQr() {
|
||||
$('#chooseView').classList.add('hidden'); $('#qrView').classList.remove('hidden'); $('#qrImage').src = `/api/checkout/orders/${encodeURIComponent(state.currentOrder.id)}/qrcode?t=${Date.now()}`;
|
||||
const badge = $('#channelBadge'); badge.className = `channel-badge channel-${state.currentOrder.channel}`; badge.textContent = channelName(state.currentOrder.channel);
|
||||
const link = $('#paymentLink');
|
||||
if (state.currentOrder.paymentUrl) { link.href = state.currentOrder.paymentUrl; link.textContent = '打开支付宝官方收银台 →'; link.classList.remove('hidden'); $('.qr-copy h3').textContent = '打开官方收银台扫码'; $('.qr-copy p').textContent = '请在电脑上打开支付宝官方收银台,页面会展示付款二维码;支付完成后此页面会自动更新。'; }
|
||||
link.classList.add('hidden');
|
||||
if (state.currentOrder.channel === 'alipay') { $('.qr-copy h3').textContent = '请使用支付宝扫码'; $('.qr-copy p').textContent = '当前显示支付宝官方收银台的真实付款码;支付完成后本页面会自动更新。'; }
|
||||
else if (state.currentOrder.channel === 'mock') { link.href = `/mock-pay/${encodeURIComponent(state.currentOrder.id)}`; link.textContent = '打开模拟支付页 →'; link.classList.remove('hidden'); }
|
||||
const expires = new Date(state.currentOrder.expiresAt).getTime();
|
||||
const tick = () => { const left = Math.max(0, Math.floor((expires - Date.now()) / 1000)); $('#countdown').textContent = `${String(Math.floor(left / 60)).padStart(2, '0')}:${String(left % 60).padStart(2, '0')}`; if (left <= 0) { clearInterval(pollTimer); $('#statusLine').textContent = '二维码已过期,请重新发起充值'; } };
|
||||
if (state.currentOrder.channel === 'alipay') qrRefreshTimer = setInterval(() => { $('#qrImage').src = `/api/checkout/orders/${encodeURIComponent(state.currentOrder.id)}/qrcode?t=${Date.now()}`; }, 60_000);
|
||||
tick(); setInterval(tick, 1000); pollTimer = setInterval(checkStatus, 2000);
|
||||
}
|
||||
|
||||
async function checkStatus() {
|
||||
try { const data = await fetch(`/api/checkout/orders/${encodeURIComponent(state.currentOrder.id)}`).then((response) => response.json()); if (data.order?.status === 'paid') { clearInterval(pollTimer); showSuccess(data.order); } else if (['failed', 'closed'].includes(data.order?.status)) { clearInterval(pollTimer); showError('订单已关闭或支付失败'); } } catch { /* keep polling */ }
|
||||
try { const data = await fetch(`/api/checkout/orders/${encodeURIComponent(state.currentOrder.id)}`).then((response) => response.json()); if (data.order?.status === 'paid') { clearInterval(pollTimer); clearInterval(qrRefreshTimer); showSuccess(data.order); } else if (['failed', 'closed'].includes(data.order?.status)) { clearInterval(pollTimer); clearInterval(qrRefreshTimer); showError('订单已关闭或支付失败'); } } catch { /* keep polling */ }
|
||||
}
|
||||
|
||||
async function refreshUserBalance() {
|
||||
|
||||
Reference in new issue
Block a user