From 1f1aa896d17070c1ca51fd473d0c2f3560efead3 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Sun, 23 Nov 2025 21:42:48 +0800 Subject: [PATCH] update pay function --- app.py | 3 + src/routes/lazy-components.js | 2 +- src/views/Profile/index.js | 383 ++++++++++++++++++++++++++++++++++ 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 src/views/Profile/index.js diff --git a/app.py b/app.py index f137ec7a..6f44817c 100755 --- a/app.py +++ b/app.py @@ -13639,6 +13639,9 @@ def get_prediction_topics(): }) except Exception as e: + import traceback + print(f"[ERROR] 获取话题列表失败: {str(e)}") + print(traceback.format_exc()) return jsonify({'success': False, 'error': str(e)}), 500 diff --git a/src/routes/lazy-components.js b/src/routes/lazy-components.js index 8e124a1a..b9c31e9e 100644 --- a/src/routes/lazy-components.js +++ b/src/routes/lazy-components.js @@ -11,7 +11,7 @@ export const lazyComponents = { // Home 模块 HomePage: React.lazy(() => import('../views/Home/HomePage')), CenterDashboard: React.lazy(() => import('../views/Dashboard/Center')), - ProfilePage: React.lazy(() => import('../views/Profile/ProfilePage')), + ProfilePage: React.lazy(() => import('../views/Profile')), SettingsPage: React.lazy(() => import('../views/Settings/SettingsPage')), Subscription: React.lazy(() => import('../views/Pages/Account/Subscription')), PrivacyPolicy: React.lazy(() => import('../views/Pages/PrivacyPolicy')), diff --git a/src/views/Profile/index.js b/src/views/Profile/index.js new file mode 100644 index 00000000..336fcbf3 --- /dev/null +++ b/src/views/Profile/index.js @@ -0,0 +1,383 @@ +/** + * 个人中心页面 + * 包含用户信息、积分系统、交易记录等 + */ + +import React, { useState, useEffect } from 'react'; +import { + Box, + Container, + Grid, + GridItem, + Heading, + Text, + VStack, + HStack, + Avatar, + Button, + Card, + CardBody, + CardHeader, + Stat, + StatLabel, + StatNumber, + StatHelpText, + StatArrow, + Badge, + Tabs, + TabList, + TabPanels, + Tab, + TabPanel, + Table, + Thead, + Tbody, + Tr, + Th, + Td, + Icon, + useToast, + Spinner, + Divider, +} from '@chakra-ui/react'; +import { + Wallet, + TrendingUp, + Gift, + History, + Award, + Calendar, + DollarSign, + Activity, +} from 'lucide-react'; +import { useAuth } from '@contexts/AuthContext'; +import { getUserAccount, claimDailyBonus } from '@services/predictionMarketService.api'; +import { forumColors } from '@theme/forumTheme'; + +const ProfilePage = () => { + const toast = useToast(); + const { user } = useAuth(); + + // 状态管理 + const [account, setAccount] = useState(null); + const [loading, setLoading] = useState(true); + const [claiming, setClaiming] = useState(false); + + // 加载用户积分账户 + useEffect(() => { + const fetchAccount = async () => { + if (!user) return; + + try { + setLoading(true); + const response = await getUserAccount(); + if (response.success) { + setAccount(response.data); + } + } catch (error) { + console.error('获取账户失败:', error); + toast({ + title: '加载失败', + description: '无法加载账户信息', + status: 'error', + duration: 3000, + }); + } finally { + setLoading(false); + } + }; + + fetchAccount(); + }, [user, toast]); + + // 领取每日奖励 + const handleClaimDailyBonus = async () => { + try { + setClaiming(true); + const response = await claimDailyBonus(); + + if (response.success) { + toast({ + title: '领取成功!', + description: `获得 ${response.data.bonus_amount} 积分`, + status: 'success', + duration: 3000, + }); + + // 刷新账户数据 + const accountResponse = await getUserAccount(); + if (accountResponse.success) { + setAccount(accountResponse.data); + } + } + } catch (error) { + toast({ + title: '领取失败', + description: error.response?.data?.error || '今日奖励已领取或系统错误', + status: 'error', + duration: 3000, + }); + } finally { + setClaiming(false); + } + }; + + if (loading) { + return ( + + + + 加载中... + + + ); + } + + return ( + + + {/* 用户信息头部 */} + + + + + + + + {user?.nickname || user?.username} + + + + + 会员 + + + {user?.email} + + + + + + + + {/* 积分概览 */} + + {/* 总余额 */} + + + + + + + 总余额 + + + {account?.balance?.toFixed(0) || 0} + + 积分 + + + + + + {/* 可用余额 */} + + + + + + + 可用余额 + + + {account?.available_balance?.toFixed(0) || 0} + + 积分 + + + + + + {/* 累计收益 */} + + + + + + + 累计收益 + + + +{account?.total_earned?.toFixed(0) || 0} + + + + 积分 + + + + + + + {/* 累计消费 */} + + + + + + + 累计消费 + + + {account?.total_spent?.toFixed(0) || 0} + + 积分 + + + + + + + {/* 每日签到 */} + + + + + + + 每日签到 + + + + + + + + + + + 每日登录可领取 100 积分奖励 + + + {account?.last_daily_bonus_at && ( + + 上次领取时间:{new Date(account.last_daily_bonus_at).toLocaleString('zh-CN')} + + )} + + + + + {/* 详细信息标签页 */} + + + + + + + 交易记录 + + + + 积分明细 + + + + + {/* 交易记录 */} + + + + 暂无交易记录 + + + + + {/* 积分明细 */} + + + + 暂无积分明细 + + + + + + + + + + ); +}; + +export default ProfilePage;