fix: 固定充值支付金额快照
This commit is contained in:
@@ -20,6 +20,7 @@ const RANGE_META: Record<TrendRange, { chip: string; sub: string; totalLabel: st
|
||||
};
|
||||
|
||||
type Tab = "overview" | "by-project" | "by-member" | "bills";
|
||||
type TopupQuote = { amount: number; bonus: number; channel: "wechat" | "alipay" };
|
||||
|
||||
// 项目状态 → 三态(对齐 V1 进行中 / 已完成 / 失败 · 待重跑)
|
||||
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);
|
||||
// 弹窗退场动画期间仍会保留在 DOM 中;打开时冻结本次支付快照,避免清空自定义金额后回显为预选套餐。
|
||||
const [topupQuote, setTopupQuote] = useState<TopupQuote | null>(null);
|
||||
|
||||
// 趋势(day,首屏)+ 团队成员(成员/限额 tab)本页懒加载
|
||||
const [trend, setTrend] = useState<BillingTrend | null>(null);
|
||||
@@ -192,16 +195,17 @@ export function AccountPage({ billing, projects, team, onRecharge, onNotify }: {
|
||||
|
||||
function openTopup(channel: "wechat" | "alipay") {
|
||||
if (!validateCustomAmount()) return;
|
||||
setTopupQuote({ amount: effectiveAmount, bonus: effectiveBonus, channel });
|
||||
setTopupChannel(channel);
|
||||
}
|
||||
|
||||
async function submitRecharge() {
|
||||
if (!validateCustomAmount()) {
|
||||
if (!topupQuote || topupQuote.amount < MIN_RECHARGE_AMOUNT) {
|
||||
onNotify("error", `最小充值金额为 ${MIN_RECHARGE_AMOUNT} 元`);
|
||||
setTopupChannel(null);
|
||||
return;
|
||||
}
|
||||
if (effectiveAmount <= 0) return;
|
||||
await onRecharge(effectiveAmount, effectiveBonus); // 父级 action 成功后弹全局「充值成功」toast
|
||||
await onRecharge(topupQuote.amount, topupQuote.bonus); // 父级 action 成功后弹全局「充值成功」toast
|
||||
setTopupChannel(null);
|
||||
setCustomAmt("");
|
||||
setBillPage(1);
|
||||
@@ -610,9 +614,9 @@ export function AccountPage({ billing, projects, team, onRecharge, onNotify }: {
|
||||
|
||||
<TopupModal
|
||||
open={topupChannel !== null}
|
||||
channel={topupChannel ?? "wechat"}
|
||||
amount={effectiveAmount}
|
||||
bonus={effectiveBonus} rate={pointsRate}
|
||||
channel={topupQuote?.channel ?? topupChannel ?? "wechat"}
|
||||
amount={topupQuote?.amount ?? effectiveAmount}
|
||||
bonus={topupQuote?.bonus ?? effectiveBonus} rate={pointsRate}
|
||||
close={() => setTopupChannel(null)}
|
||||
onDone={submitRecharge}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user