fix: 固定充值支付金额快照

This commit is contained in:
hh
2026-07-15 14:05:23 +08:00
parent fdd3bbfad2
commit 44148dad0e
+10 -6
View File
@@ -20,6 +20,7 @@ const RANGE_META: Record<TrendRange, { chip: string; sub: string; totalLabel: st
}; };
type Tab = "overview" | "by-project" | "by-member" | "bills"; type Tab = "overview" | "by-project" | "by-member" | "bills";
type TopupQuote = { amount: number; bonus: number; channel: "wechat" | "alipay" };
// 项目状态 → 三态(对齐 V1 进行中 / 已完成 / 失败 · 待重跑) // 项目状态 → 三态(对齐 V1 进行中 / 已完成 / 失败 · 待重跑)
function projBucket(p: Project): "wip" | "ok" | "fail" { function projBucket(p: Project): "wip" | "ok" | "fail" {
@@ -135,6 +136,8 @@ export function AccountPage({ billing, projects, team, onRecharge, onNotify }: {
// 充值扫码弹窗:点支付方式先弹弹窗,弹窗内「已完成支付」才真正提交 // 充值扫码弹窗:点支付方式先弹弹窗,弹窗内「已完成支付」才真正提交
const [topupChannel, setTopupChannel] = useState<"wechat" | "alipay" | null>(null); const [topupChannel, setTopupChannel] = useState<"wechat" | "alipay" | null>(null);
// 弹窗退场动画期间仍会保留在 DOM 中;打开时冻结本次支付快照,避免清空自定义金额后回显为预选套餐。
const [topupQuote, setTopupQuote] = useState<TopupQuote | null>(null);
// 趋势(day,首屏)+ 团队成员(成员/限额 tab)本页懒加载 // 趋势(day,首屏)+ 团队成员(成员/限额 tab)本页懒加载
const [trend, setTrend] = useState<BillingTrend | null>(null); const [trend, setTrend] = useState<BillingTrend | null>(null);
@@ -192,16 +195,17 @@ export function AccountPage({ billing, projects, team, onRecharge, onNotify }: {
function openTopup(channel: "wechat" | "alipay") { function openTopup(channel: "wechat" | "alipay") {
if (!validateCustomAmount()) return; if (!validateCustomAmount()) return;
setTopupQuote({ amount: effectiveAmount, bonus: effectiveBonus, channel });
setTopupChannel(channel); setTopupChannel(channel);
} }
async function submitRecharge() { async function submitRecharge() {
if (!validateCustomAmount()) { if (!topupQuote || topupQuote.amount < MIN_RECHARGE_AMOUNT) {
onNotify("error", `最小充值金额为 ${MIN_RECHARGE_AMOUNT}`);
setTopupChannel(null); setTopupChannel(null);
return; return;
} }
if (effectiveAmount <= 0) return; await onRecharge(topupQuote.amount, topupQuote.bonus); // 父级 action 成功后弹全局「充值成功」toast
await onRecharge(effectiveAmount, effectiveBonus); // 父级 action 成功后弹全局「充值成功」toast
setTopupChannel(null); setTopupChannel(null);
setCustomAmt(""); setCustomAmt("");
setBillPage(1); setBillPage(1);
@@ -610,9 +614,9 @@ export function AccountPage({ billing, projects, team, onRecharge, onNotify }: {
<TopupModal <TopupModal
open={topupChannel !== null} open={topupChannel !== null}
channel={topupChannel ?? "wechat"} channel={topupQuote?.channel ?? topupChannel ?? "wechat"}
amount={effectiveAmount} amount={topupQuote?.amount ?? effectiveAmount}
bonus={effectiveBonus} rate={pointsRate} bonus={topupQuote?.bonus ?? effectiveBonus} rate={pointsRate}
close={() => setTopupChannel(null)} close={() => setTopupChannel(null)}
onDone={submitRecharge} onDone={submitRecharge}
/> />