/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; import { Avatar, Typography, Card, Button, Input, InputNumber, Banner, Skeleton, Divider, Tabs, TabPane, } from '@douyinfe/semi-ui'; import { SiAlipay, SiWechat, SiStripe } from 'react-icons/si'; import { CreditCard, Gift, Link as LinkIcon, Coins } from 'lucide-react'; import { IconGift } from '@douyinfe/semi-icons'; import RightStatsCard from './RightStatsCard'; const { Text } = Typography; const RechargeCard = ({ t, enableOnlineTopUp, enableStripeTopUp, presetAmounts, selectedPreset, selectPresetAmount, formatLargeNumber, priceRatio, topUpCount, minTopUp, renderQuotaWithAmount, getAmount, setTopUpCount, setSelectedPreset, renderAmount, amountLoading, payMethods, preTopUp, paymentLoading, payWay, redemptionCode, setRedemptionCode, topUp, isSubmitting, topUpLink, openTopUpLink, // 新增:用于右侧统计卡片 userState, renderQuota, statusLoading, }) => { return ( {/* 卡片头部 */}
{t('账户充值')}
{t('多种充值方式,安全便捷')}
{/* 在线充值 Tab */} {t('在线充值')} } itemKey="online" >
{statusLoading ? (
) : (enableOnlineTopUp || enableStripeTopUp) ? (
{/* 预设充值额度选择 */} {(enableOnlineTopUp || enableStripeTopUp) && (
{t('选择充值额度')}
{presetAmounts.map((preset, index) => ( selectPresetAmount(preset)} className={`cursor-pointer !rounded-xl transition-all hover:shadow-md ${selectedPreset === preset.value ? 'border-blue-500 shadow-md' : 'border-slate-200 hover:border-slate-300 dark:border-slate-600 dark:hover:border-slate-500' }`} bodyStyle={{ textAlign: 'center', padding: '12px' }} >
{formatLargeNumber(preset.value)}
{t('实付')} ¥{(preset.value * priceRatio).toFixed(2)}
))}
)} {/* 自定义充值金额 */} {(enableOnlineTopUp || enableStripeTopUp) && (
{t('或输入自定义金额')}
{t('充值数量')} {amountLoading ? ( ) : ( {t('实付金额:')}{renderAmount()} )}
{ if (value && value >= 1) { setTopUpCount(value); setSelectedPreset(null); await getAmount(value); } }} onBlur={(e) => { const value = parseInt(e.target.value); if (!value || value < 1) { setTopUpCount(1); getAmount(1); } }} className='w-full !rounded-lg' formatter={(value) => (value ? `${value}` : '')} parser={(value) => value ? parseInt(value.replace(/[^\d]/g, '')) : 0} />
{/* 支付方式选择 */}
{t('选择支付方式')}
{payMethods.map((payMethod) => ( preTopUp(payMethod.type)} className={`cursor-pointer !rounded-xl transition-all hover:shadow-md ${paymentLoading && payWay === payMethod.type ? 'border-blue-500 shadow-md' : 'border-slate-200 hover:border-slate-300 dark:border-slate-600 dark:hover:border-slate-500' } ${(!enableOnlineTopUp && payMethod.type !== 'stripe') || (!enableStripeTopUp && payMethod.type === 'stripe') ? 'opacity-50 cursor-not-allowed' : '' }`} bodyStyle={{ padding: '12px', textAlign: 'center' }} > {paymentLoading && payWay === payMethod.type ? (
{t('处理中')}
) : ( <>
{payMethod.type === 'zfb' ? ( ) : payMethod.type === 'wx' ? ( ) : payMethod.type === 'stripe' ? ( ) : ( )}
{payMethod.name}
)}
))}
)}
) : ( )}
{/* 兑换码充值 Tab */} {t('兑换码充值')} } itemKey="redeem" >
setRedemptionCode(value)} className='!rounded-lg' prefix={} showClear />
{topUpLink && ( )}
); }; export default RechargeCard;