This commit is contained in:
2026-06-30 10:33:56 +08:00
commit 6e047dc0a5
607 changed files with 65966 additions and 0 deletions
@@ -0,0 +1,99 @@
import { useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
function formatAmount(n: number) {
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
export default function RedeemSuccessPage() {
const navigate = useNavigate();
const location = useLocation();
const result = useMemo(() => {
const stateResult = (location.state as { result?: Record<string, unknown> })?.result;
if (stateResult) return stateResult;
try {
const cached = sessionStorage.getItem('lastRedeemResult');
return cached ? (JSON.parse(cached) as Record<string, unknown>) : null;
} catch {
return null;
}
}, [location.state]);
const storeName = (location.state as { storeName?: string })?.storeName || '当前门店';
const amount = Number(result?.amount || 100);
const redeemNo = String(result?.redeemNo || '—');
const createdAt = result?.createdAt
? new Date(String(result.createdAt)).toLocaleString('zh-CN')
: new Date().toLocaleString('zh-CN');
return (
<div className="shop-success-page">
<header className="shop-success-header">
<button type="button" className="shop-redeem-back" onClick={() => navigate('/')} aria-label="返回">
<span className="material-symbols-outlined">arrow_back</span>
</button>
<h1 className="app-page-title"></h1>
</header>
<section className="shop-success-hero">
<div className="shop-success-icon-wrap">
<span className="material-symbols-outlined">check_circle</span>
</div>
<h2 className="shop-success-title"></h2>
<p className="shop-success-amount">¥ {formatAmount(amount)}</p>
<p className="shop-success-sub"></p>
<p className="shop-success-note"></p>
</section>
<div className="shop-success-details">
<div className="shop-success-detail-row">
<span className="shop-success-detail-label"></span>
<span className="shop-success-detail-value">{storeName}</span>
</div>
<div className="shop-success-detail-row">
<span className="shop-success-detail-label"></span>
<div className="shop-success-user">
<div className="shop-success-user-avatar">
<span className="material-symbols-outlined">person</span>
</div>
<div style={{ textAlign: 'right' }}>
<div className="shop-success-detail-value"></div>
<div className="shop-success-detail-label"></div>
</div>
</div>
</div>
<div className="shop-success-detail-row">
<span className="shop-success-detail-label"></span>
<span className="shop-success-detail-value" style={{ fontWeight: 400, color: 'var(--color-on-surface-variant)' }}>
{createdAt}
</span>
</div>
<div className="shop-success-detail-row">
<span className="shop-success-detail-label"></span>
<span className="shop-success-detail-value" style={{ fontFamily: 'monospace', fontWeight: 400 }}>
{redeemNo}
</span>
</div>
</div>
<div className="shop-success-actions">
<button type="button" className="shop-success-primary-btn" onClick={() => navigate('/redeem')}>
<span></span>
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>qr_code_scanner</span>
</button>
<button type="button" className="shop-success-outline-btn" onClick={() => navigate('/')}>
<span></span>
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>home</span>
</button>
</div>
<div className="shop-success-brand">
<div className="shop-success-brand-icon">
<span className="material-symbols-outlined shop-fill-icon" style={{ fontSize: 12 }}>verified</span>
</div>
<p className="shop-success-brand-text">西</p>
</div>
</div>
);
}