From 86ece33c001cb3eedd5feb57c17ed5d617f23df5 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Fri, 20 Feb 2026 22:46:28 +0800 Subject: [PATCH] feat: add role-based wallet view for consumer vs player/owner --- app/(account)/wallet/page.tsx | 156 ++++++++++++++++++++++------------ 1 file changed, 104 insertions(+), 52 deletions(-) diff --git a/app/(account)/wallet/page.tsx b/app/(account)/wallet/page.tsx index 6a44867..00dec7e 100644 --- a/app/(account)/wallet/page.tsx +++ b/app/(account)/wallet/page.tsx @@ -1,3 +1,5 @@ +"use client" + import { ArrowDownLeft, ArrowUpRight, @@ -12,6 +14,7 @@ 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-data" +import { useAuthStore } from "@/store/auth" const typeLabels: Record = { topup: "充值", @@ -30,6 +33,20 @@ const typeIcons: Record = { } 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 (

钱包

@@ -38,43 +55,74 @@ export default function WalletPage() {
-

账户余额

-

¥{walletBalance.toFixed(2)}

+

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

+

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

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

本月收入

+

¥1,280.00

+
+
+

待结算

+

¥320.00

+
+
+

已提现

+

¥5,400.00

+
+
+
+
+ )} @@ -85,33 +133,37 @@ export default function WalletPage() { - {mockTransactions.map((tx) => { - const Icon = typeIcons[tx.type] - const isIncome = tx.amount > 0 - return ( -
-
-
- + {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")} +

+
-
-

{tx.description}

-

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

+

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

+ + {typeLabels[tx.type]} +
-
-

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

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