"use client" import { ArrowDownLeft, ArrowUpRight, CreditCard, DollarSign, RefreshCw, Wallet, } from "lucide-react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Separator } from "@/components/ui/separator" import { mockTransactions, walletBalance } from "@/lib/mock" import { useAuthStore } from "@/store/auth" const typeLabels: Record = { topup: "充值", payment: "支付", income: "收入", withdrawal: "提现", refund: "退款", } const typeIcons: Record = { topup: ArrowDownLeft, payment: ArrowUpRight, income: ArrowDownLeft, withdrawal: ArrowUpRight, refund: ArrowDownLeft, } export default function WalletPage() { const { currentRole } = useAuthStore() const isConsumer = currentRole === "consumer" const filteredTransactions = mockTransactions.filter((tx) => { if (isConsumer) { return ["topup", "payment", "refund"].includes(tx.type) } return ["income", "withdrawal"].includes(tx.type) }) const incomeBalance = mockTransactions .filter((tx) => tx.type === "income") .reduce((acc, tx) => acc + tx.amount, 0) return (

钱包

{isConsumer ? "账户余额" : "收入余额"}

¥{isConsumer ? walletBalance.toFixed(2) : incomeBalance.toFixed(2)}

{isConsumer ? ( ) : ( )}
{isConsumer ? ( 快捷充值
{[50, 100, 200, 500, 1000, 2000].map((amount) => ( ))}
) : ( 收入概览

本月收入

¥1,280.00

待结算

¥320.00

已提现

¥5,400.00

)} 交易记录 {filteredTransactions.length > 0 ? ( filteredTransactions.map((tx) => { const Icon = typeIcons[tx.type] const isIncome = tx.amount > 0 return (

{tx.description}

{new Date(tx.createdAt).toLocaleString("zh-CN")}

{isIncome ? "+" : ""}¥{Math.abs(tx.amount).toFixed(2)}

{typeLabels[tx.type]}
) }) ) : (
暂无交易记录
)}
) }