Skip to content

Let's use AI to Earn!

用户信息

daoyian049e7e498b5a
diff --git a/src/views/user/mine/UserProfile.tsx b/src/views/user/mine/UserProfile.tsx
new file mode 100644
index 00000000..e0fab014
--- /dev/null
+++ b/src/views/user/mine/UserProfile.tsx
@@ -0,0 +1,147 @@
+import { useEffect, useState } from 'react';
+import { Card, Descriptions, Spin, Typography, Space, Avatar } from 'antd';
+import { userApi } from '@/api/user';
+import styles from './userProfile.module.scss';
+import { UserOutlined, PhoneOutlined, IdcardOutlined, QrcodeOutlined, ClockCircleOutlined, SafetyOutlined, WechatOutlined } from '@ant-design/icons';
+
+const { Title } = Typography;
+
+interface UserInfo {
+ createTime: string;
+ id: string;
+ inviteCode: string;
+ name: string;
+ phone: string;
+ status: number;
+ updateTime: string;
+ wxOpenid: string;
+ _id: string;
+}
+
+const UserProfile = () => {
+ const [loading, setLoading] = useState(false);
+ const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
+ const [popularizeCode, setPopularizeCode] = useState<string>('');
+
+ const fetchUserInfo = async () => {
+ try {
+ setLoading(true);
+ const res:any = await userApi.getUserInfo();
+ setUserInfo(res);
+ // 如果没有邀请码,则获取
+ if (!res.popularizeCode) {
+ const code = await userApi.getMinePopularizeCode();
+ setPopularizeCode(code);
+ } else {
+ setPopularizeCode(res.popularizeCode);
+ }
+ } catch (error) {
+ console.error('获取用户信息失败:', error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ fetchUserInfo();
+ }, []);
+
+ return (
+ <div className={styles.profileContainer}>
+ <Spin spinning={loading}>
+ <div className={styles.profileHeader}>
+ <div className={styles.profileAvatar}>
+ <Avatar size={120} icon={<UserOutlined />} />
+ <Title level={3} className={styles.profileName}>
+ {userInfo?.name || '未设置用户名'}
+ </Title>
+ </div>
+ </div>
+
+ <div className={styles.profileContent}>
+ <Card className={styles.profileCard}>
+ <Space direction="vertical" size="large" className={styles.infoSection}>
+ <div className={styles.infoGroup}>
+ <div className={styles.infoItem}>
+ <IdcardOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>用户ID</span>
+ <span className={styles.infoValue}>{userInfo?.id || '-'}</span>
+ </div>
+ </div>
+
+ <div className={styles.infoItem}>
+ <PhoneOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>手机号</span>
+ <span className={styles.infoValue}>{userInfo?.phone || '-'}</span>
+ </div>
+ </div>
+
+
+
+ <div className={styles.infoItem}>
+ <QrcodeOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>我的邀请码</span>
+ <span className={styles.infoValue}>{popularizeCode || '-'}</span>
+ </div>
+ </div>
+
+ {userInfo?.inviteCode && (
+ <div className={styles.infoItem}>
+ <QrcodeOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>邀请者邀请码</span>
+ <span className={styles.infoValue}>{userInfo.inviteCode}</span>
+ </div>
+ </div>
+ )}
+
+ <div className={styles.infoItem}>
+ <ClockCircleOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>创建时间</span>
+ <span className={styles.infoValue}>
+ {userInfo?.createTime ? new Date(userInfo.createTime).toLocaleString() : '-'}
+ </span>
+ </div>
+ </div>
+
+ <div className={styles.infoItem}>
+ <ClockCircleOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>更新时间</span>
+ <span className={styles.infoValue}>
+ {userInfo?.updateTime ? new Date(userInfo.updateTime).toLocaleString() : '-'}
+ </span>
+ </div>
+ </div>
+
+ <div className={styles.infoItem}>
+ <WechatOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>微信OpenID</span>
+ <span className={styles.infoValue}>{userInfo?.wxOpenid || '-'}</span>
+ </div>
+ </div>
+
+ <div className={styles.infoItem}>
+ <SafetyOutlined className={styles.infoIcon} />
+ <div className={styles.infoContent}>
+ <span className={styles.infoLabel}>账号状态</span>
+ <span className={`${styles.infoValue} ${userInfo?.status === 1 ? styles.statusNormal : styles.statusAbnormal}`}>
+ {userInfo?.status === 1 ? '正常' : '异常'}
+ </span>
+ </div>
+ </div>
+ </div>
+ </Space>
+ </Card>
+ </div>
+ </Spin>
+ </div>
+ );
+};
+
+export default UserProfile;
\ No newline at end of file
diff --git a/src/views/user/mine/userProfile.module.scss b/src/views/user/mine/userProfile.module.scss
new file mode 100644
index 00000000..0ca97f56
--- /dev/null
+++ b/src/views/user/mine/userProfile.module.scss
@@ -0,0 +1,212 @@
+.profileContainer {
+ padding: 24px;
+ background-color: #f5f5f5;
+ min-height: calc(100vh - 64px);
+ position: relative;
+ overflow: hidden;
+
+ // 科技感背景效果
+ &::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background:
+ linear-gradient(90deg, rgba(166, 106, 228, 0.02) 1px, transparent 1px) 0 0 / 20px 20px,
+ linear-gradient(0deg, rgba(166, 106, 228, 0.02) 1px, transparent 1px) 0 0 / 20px 20px;
+ z-index: 0;
+ }
+
+ .profileHeader {
+ text-align: center;
+ margin: 40px 0 40px;
+ position: relative;
+ z-index: 1;
+
+ .profileAvatar {
+ margin-bottom: 24px;
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ h3{
+ margin-top: 10px;
+ }
+
+ :global(.ant-avatar) {
+ background: linear-gradient(135deg, #a66ae4 0%, #6a4ae4 100%);
+ box-shadow: 0 0 20px rgba(166, 106, 228, 0.2);
+ border: 4px solid #fff;
+ transition: all 0.3s ease;
+ position: relative;
+ z-index: 1;
+
+ &:hover {
+ transform: scale(1.05);
+ box-shadow: 0 0 30px rgba(166, 106, 228, 0.4);
+ }
+ }
+ }
+
+ .profileName {
+ color: #333;
+ margin: 0;
+ font-weight: 500;
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+ position: relative;
+ display: inline-block;
+ }
+ }
+
+ .profileContent {
+ max-width: 800px;
+ margin: 0 auto;
+ position: relative;
+ z-index: 1;
+
+ .profileCard {
+ background: #fff;
+ border-radius: 16px;
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
+ transition: all 0.3s ease;
+ border: 1px solid rgba(166, 106, 228, 0.1);
+
+ &:hover {
+ transform: translateY(-5px);
+ box-shadow: 0 12px 40px rgba(166, 106, 228, 0.15);
+ }
+
+ :global(.ant-card-body) {
+ padding: 24px;
+ }
+ }
+
+ .infoSection {
+ width: 100%;
+ }
+
+ .infoGroup {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
+ gap: 24px;
+ }
+
+ .infoItem {
+ display: flex;
+ align-items: center;
+ padding: 20px;
+ background: #fff;
+ border-radius: 12px;
+ transition: all 0.3s ease;
+ border: 1px solid rgba(166, 106, 228, 0.1);
+ position: relative;
+ overflow: hidden;
+
+ &::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 4px;
+ height: 100%;
+ background: linear-gradient(to bottom, #a66ae4, #6a4ae4);
+ opacity: 0;
+ transition: opacity 0.3s ease;
+ }
+
+ &:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(166, 106, 228, 0.1);
+
+ &::before {
+ opacity: 1;
+ }
+
+ .infoIcon {
+ transform: scale(1.1);
+ background: rgba(166, 106, 228, 0.1);
+ }
+ }
+
+ .infoIcon {
+ font-size: 24px;
+ color: #a66ae4;
+ margin-right: 16px;
+ background: rgba(166, 106, 228, 0.05);
+ padding: 12px;
+ border-radius: 12px;
+ transition: all 0.3s ease;
+ }
+
+ .infoContent {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+
+ .infoLabel {
+ color: #666;
+ font-size: 14px;
+ }
+
+ .infoValue {
+ color: #333;
+ font-size: 16px;
+ font-weight: 500;
+ }
+
+ .statusNormal {
+ color: #52c41a;
+ position: relative;
+ padding-left: 20px;
+
+ &::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 8px;
+ height: 8px;
+ background: #52c41a;
+ border-radius: 50%;
+ }
+ }
+
+ .statusAbnormal {
+ color: #ff4d4f;
+ position: relative;
+ padding-left: 20px;
+
+ &::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 8px;
+ height: 8px;
+ background: #ff4d4f;
+ border-radius: 50%;
+ }
+ }
+ }
+ }
+}
+
+// 添加响应式设计
+@media screen and (max-width: 768px) {
+ .profileContainer {
+ padding: 16px;
+
+ .profileContent {
+ .infoGroup {
+ grid-template-columns: 1fr;
+ }
+ }
+ }
+}
\ No newline at end of file