变更内容: - 删除 uni-app x 项目 (app/ 目录) - 新增 Flutter 项目 (flutter_monisuo/ 目录) - 新增部署脚本 (deploy/ 目录) Flutter 项目功能: - 用户登录/注册 - 首页资产概览 - 行情币种列表 - 交易买卖操作 - 资产账户管理 - 充值/提现/划转 - 深色主题 - JWT Token 认证 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
1.9 KiB
Dart
81 lines
1.9 KiB
Dart
/// 用户模型
|
|
class User {
|
|
final int id;
|
|
final String username;
|
|
final String? nickname;
|
|
final String? avatar;
|
|
final String? phone;
|
|
final String? email;
|
|
final int kycStatus;
|
|
final int status;
|
|
final DateTime? lastLoginTime;
|
|
final DateTime? createTime;
|
|
|
|
User({
|
|
required this.id,
|
|
required this.username,
|
|
this.nickname,
|
|
this.avatar,
|
|
this.phone,
|
|
this.email,
|
|
required this.kycStatus,
|
|
required this.status,
|
|
this.lastLoginTime,
|
|
this.createTime,
|
|
});
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
return User(
|
|
id: json['id'] as int? ?? 0,
|
|
username: json['username'] as String? ?? '',
|
|
nickname: json['nickname'] as String?,
|
|
avatar: json['avatar'] as String?,
|
|
phone: json['phone'] as String?,
|
|
email: json['email'] as String?,
|
|
kycStatus: json['kycStatus'] as int? ?? 0,
|
|
status: json['status'] as int? ?? 1,
|
|
lastLoginTime: json['lastLoginTime'] != null
|
|
? DateTime.tryParse(json['lastLoginTime'])
|
|
: null,
|
|
createTime: json['createTime'] != null
|
|
? DateTime.tryParse(json['createTime'])
|
|
: null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'username': username,
|
|
'nickname': nickname,
|
|
'avatar': avatar,
|
|
'phone': phone,
|
|
'email': email,
|
|
'kycStatus': kycStatus,
|
|
'status': status,
|
|
'lastLoginTime': lastLoginTime?.toIso8601String(),
|
|
'createTime': createTime?.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
/// 获取头像显示文字(用户名首字母)
|
|
String get avatarText =>
|
|
username.isNotEmpty ? username.substring(0, 1).toUpperCase() : 'U';
|
|
|
|
/// KYC 状态文字
|
|
String get kycStatusText {
|
|
switch (kycStatus) {
|
|
case 0:
|
|
return '未认证';
|
|
case 1:
|
|
return '审核中';
|
|
case 2:
|
|
return '已认证';
|
|
case 3:
|
|
return '认证失败';
|
|
default:
|
|
return '未知';
|
|
}
|
|
}
|
|
}
|