v #16

Merged
jacy merged 10 commits from dev_jacy into dev 2026-08-17 23:45:00 +08:00
2 changed files with 34 additions and 24 deletions
Showing only changes of commit 3ac008a217 - Show all commits
+3 -3
View File
@@ -139,7 +139,7 @@ export default function PhoneRedeemPage() {
<main className="shop-redeem-main">
{storeClosed && (
<p className="shop-redeem-error" style={{ marginBottom: 12 }}></p>
<p className="shop-redeem-error" style={{ marginBottom: 12 }}></p>
)}
<section className="shop-redeem-card">
@@ -234,8 +234,8 @@ export default function PhoneRedeemPage() {
{showOpenModal && (
<div className="shop-redeem-modal" role="dialog" aria-modal="true">
<div className="shop-redeem-modal-card">
<h4 className="shop-redeem-modal-title"></h4>
<p className="shop-redeem-modal-desc"></p>
<h4 className="shop-redeem-modal-title"></h4>
<p className="shop-redeem-modal-desc"></p>
<div className="shop-redeem-modal-actions">
<button
type="button"
+31 -21
View File
@@ -50,27 +50,34 @@ export default function RedeemConfirmPage() {
setToken(scanned);
}, [searchParams, navigate]);
useEffect(() => {
async function loadPreview() {
if (!token.trim()) {
setPreview(null);
return;
}
request<Preview>('SHOP_H5', '/shop/redeem/preview', {
method: 'POST',
body: JSON.stringify({ token }),
})
.then(setPreview)
.catch(async (e) => {
setPreview(null);
setMsg(e instanceof Error ? e.message : '无法预览核销码');
const report = await reportRedeemFailure(token, 'preview', e);
if (report?.thresholdReached) {
setFailCount(report.failCount);
setShowWeakNet(true);
} else if (report) {
setFailCount(report.failCount);
}
try {
const p = await request<Preview>('SHOP_H5', '/shop/redeem/preview', {
method: 'POST',
body: JSON.stringify({ token }),
});
setPreview(p);
setMsg('');
} catch (e) {
setPreview(null);
setMsg(e instanceof Error ? e.message : '无法预览核销码');
const report = await reportRedeemFailure(token, 'preview', e);
if (report?.thresholdReached) {
setFailCount(report.failCount);
setShowWeakNet(true);
} else if (report) {
setFailCount(report.failCount);
}
}
}
useEffect(() => {
void loadPreview();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [token]);
async function doConfirm() {
@@ -119,6 +126,9 @@ export default function RedeemConfirmPage() {
});
setStoreClosed(false);
setShowOpenModal(false);
setMsg('');
// 开张后重新拉取预览(门店已 OPEN,后端不再拦截),再继续核销
await loadPreview();
await doConfirm();
} catch (e) {
setShowOpenModal(false);
@@ -142,7 +152,7 @@ export default function RedeemConfirmPage() {
<main className="shop-redeem-main">
{storeClosed && (
<p className="shop-redeem-error" style={{ marginBottom: 12 }}></p>
<p className="shop-redeem-error" style={{ marginBottom: 12 }}></p>
)}
<section className="shop-redeem-card">
<div className="shop-redeem-banner">
@@ -214,13 +224,13 @@ export default function RedeemConfirmPage() {
<button
type="button"
className={`shop-redeem-confirm-btn${loading ? ' success' : ''}`}
disabled={loading || !preview}
disabled={loading || (!preview && !storeClosed)}
onClick={() => void confirm()}
>
<span className="material-symbols-outlined shop-fill-icon">
{loading ? 'sync' : 'check_circle'}
</span>
<span>{loading ? '正在核销...' : preview ? `确认核销 ¥${formatAmount(previewAmount)}` : '加载中…'}</span>
<span>{loading ? '正在核销...' : preview ? `确认核销 ¥${formatAmount(previewAmount)}` : storeClosed ? '确认核销' : '加载中…'}</span>
</button>
<p className="shop-redeem-hint"></p>
</>
@@ -242,8 +252,8 @@ export default function RedeemConfirmPage() {
{showOpenModal && (
<div className="shop-redeem-modal" role="dialog" aria-modal="true">
<div className="shop-redeem-modal-card">
<h4 className="shop-redeem-modal-title"></h4>
<p className="shop-redeem-modal-desc"></p>
<h4 className="shop-redeem-modal-title"></h4>
<p className="shop-redeem-modal-desc"></p>
<div className="shop-redeem-modal-actions">
<button
type="button"