feat: 添加mock数据,给导航添加选中标识
This commit is contained in:
107
src/mocks/data/users.js
Normal file
107
src/mocks/data/users.js
Normal file
@@ -0,0 +1,107 @@
|
||||
// Mock 用户数据
|
||||
export const mockUsers = {
|
||||
// 免费用户 - 手机号登录
|
||||
'13800138000': {
|
||||
id: 1,
|
||||
phone: '13800138000',
|
||||
nickname: '测试用户',
|
||||
email: 'test@example.com',
|
||||
avatar_url: 'https://i.pravatar.cc/150?img=1',
|
||||
has_wechat: false,
|
||||
created_at: '2024-01-01T00:00:00Z',
|
||||
// 会员信息 - 免费用户
|
||||
subscription_type: 'free',
|
||||
subscription_status: 'active',
|
||||
subscription_end_date: null,
|
||||
is_subscription_active: true,
|
||||
subscription_days_left: 0
|
||||
},
|
||||
|
||||
// Pro 会员 - 手机号登录
|
||||
'13900139000': {
|
||||
id: 2,
|
||||
phone: '13900139000',
|
||||
nickname: 'Pro会员',
|
||||
email: 'pro@example.com',
|
||||
avatar_url: 'https://i.pravatar.cc/150?img=2',
|
||||
has_wechat: true,
|
||||
created_at: '2024-01-15T00:00:00Z',
|
||||
// 会员信息 - Pro 会员
|
||||
subscription_type: 'pro',
|
||||
subscription_status: 'active',
|
||||
subscription_end_date: '2025-12-31T23:59:59Z',
|
||||
is_subscription_active: true,
|
||||
subscription_days_left: 90
|
||||
},
|
||||
|
||||
// Max 会员 - 手机号登录
|
||||
'13700137000': {
|
||||
id: 3,
|
||||
phone: '13700137000',
|
||||
nickname: 'Max会员',
|
||||
email: 'max@example.com',
|
||||
avatar_url: 'https://i.pravatar.cc/150?img=3',
|
||||
has_wechat: false,
|
||||
created_at: '2024-02-01T00:00:00Z',
|
||||
// 会员信息 - Max 会员
|
||||
subscription_type: 'max',
|
||||
subscription_status: 'active',
|
||||
subscription_end_date: '2026-12-31T23:59:59Z',
|
||||
is_subscription_active: true,
|
||||
subscription_days_left: 365
|
||||
},
|
||||
|
||||
// 过期会员 - 测试过期状态
|
||||
'13600136000': {
|
||||
id: 4,
|
||||
phone: '13600136000',
|
||||
nickname: '过期会员',
|
||||
email: 'expired@example.com',
|
||||
avatar_url: 'https://i.pravatar.cc/150?img=4',
|
||||
has_wechat: false,
|
||||
created_at: '2023-01-01T00:00:00Z',
|
||||
// 会员信息 - 已过期
|
||||
subscription_type: 'pro',
|
||||
subscription_status: 'expired',
|
||||
subscription_end_date: '2024-01-01T00:00:00Z',
|
||||
is_subscription_active: false,
|
||||
subscription_days_left: -300
|
||||
}
|
||||
};
|
||||
|
||||
// Mock 验证码存储(实际项目中应该在后端验证)
|
||||
export const mockVerificationCodes = new Map();
|
||||
|
||||
// 生成随机6位验证码
|
||||
export function generateVerificationCode() {
|
||||
return Math.floor(100000 + Math.random() * 900000).toString();
|
||||
}
|
||||
|
||||
// 微信 session 存储
|
||||
export const mockWechatSessions = new Map();
|
||||
|
||||
// 生成微信 session ID
|
||||
export function generateWechatSessionId() {
|
||||
return 'wx_' + Math.random().toString(36).substring(2, 15);
|
||||
}
|
||||
|
||||
// ==================== 当前登录用户状态管理 ====================
|
||||
// 用于跟踪当前登录的用户(Mock 模式下的全局状态)
|
||||
let currentLoggedInUser = null;
|
||||
|
||||
// 设置当前登录用户
|
||||
export function setCurrentUser(user) {
|
||||
currentLoggedInUser = user;
|
||||
console.log('[Mock State] 设置当前登录用户:', user);
|
||||
}
|
||||
|
||||
// 获取当前登录用户
|
||||
export function getCurrentUser() {
|
||||
return currentLoggedInUser;
|
||||
}
|
||||
|
||||
// 清除当前登录用户
|
||||
export function clearCurrentUser() {
|
||||
currentLoggedInUser = null;
|
||||
console.log('[Mock State] 清除当前登录用户');
|
||||
}
|
||||
Reference in New Issue
Block a user