import { useEffect, useState } from 'react'; import { WalletCards } from 'lucide-react'; import { Pagination, Tag } from '@/components/ui'; import { clientApi, type RechargeOrder } from '@/api/adminApi'; import { formatCents } from '@/utils/currency'; import { formatDateTime } from '@/utils/dateTime'; export function ClientBillingPage() { const [balanceCents, setBalanceCents] = useState(0); const [orders, setOrders] = useState([]); const [page, setPage] = useState(1); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); const pageSize = 10; const totalPages = Math.max(1, Math.ceil(orders.length / pageSize)); const currentPage = Math.min(page, totalPages); const visibleOrders = orders.slice((currentPage - 1) * pageSize, currentPage * pageSize); useEffect(() => { setLoading(true); Promise.all([clientApi.getDashboard(), clientApi.listOrders()]) .then(([dashboard, nextOrders]) => { setBalanceCents(dashboard.accounts[0]?.balanceCents ?? 0); setOrders(nextOrders); setError(''); }) .catch((reason: Error) => setError(reason.message || '账户信息加载失败')) .finally(() => setLoading(false)); }, []); return (

账户

账户余额

当前可用余额¥{formatCents(balanceCents)}短信发送仅按现金余额校验。

充值记录

如需充值,请联系平台运营人员。

{orders.length} 条
{loading ?

正在加载账户信息...

: null} {error ?

{error}

: null} {!loading && !error ? (
{visibleOrders.length === 0 ? : visibleOrders.map((order) => ( ))}
订单号充值时间充值金额状态备注
暂无充值记录
{order.orderNo} {formatDateTime(order.paidAt ?? order.createdAt)} ¥{formatCents(order.amountCents)} {order.status === 'paid' ? '已入账' : order.status} {order.remark || '-'}
) : null} = totalPages} onNext={() => setPage((value) => Math.min(totalPages, value + 1))} onPrevious={() => setPage((value) => Math.max(1, value - 1))} page={currentPage} totalPages={totalPages} onPageChange={setPage} previousDisabled={currentPage <= 1} total={orders.length} />
); }