变更内容: - 删除 uni-app x 项目 (app/ 目录) - 新增 Flutter 项目 (flutter_monisuo/ 目录) - 新增部署脚本 (deploy/ 目录) Flutter 项目功能: - 用户登录/注册 - 首页资产概览 - 行情币种列表 - 交易买卖操作 - 资产账户管理 - 充值/提现/划转 - 深色主题 - JWT Token 认证 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.3 KiB
Dart
57 lines
1.3 KiB
Dart
import '../../core/constants/api_endpoints.dart';
|
|
import '../../core/network/dio_client.dart';
|
|
import '../models/user.dart';
|
|
|
|
/// 用户服务
|
|
class UserService {
|
|
final DioClient _client;
|
|
|
|
UserService(this._client);
|
|
|
|
/// 用户登录
|
|
Future<ApiResponse<Map<String, dynamic>>> login(
|
|
String username,
|
|
String password,
|
|
) async {
|
|
return _client.post<Map<String, dynamic>>(
|
|
ApiEndpoints.login,
|
|
data: {'username': username, 'password': password},
|
|
);
|
|
}
|
|
|
|
/// 用户注册
|
|
Future<ApiResponse<Map<String, dynamic>>> register(
|
|
String username,
|
|
String password,
|
|
) async {
|
|
return _client.post<Map<String, dynamic>>(
|
|
ApiEndpoints.register,
|
|
data: {'username': username, 'password': password},
|
|
);
|
|
}
|
|
|
|
/// 获取用户信息
|
|
Future<ApiResponse<User>> getUserInfo() async {
|
|
return _client.get<User>(
|
|
ApiEndpoints.userInfo,
|
|
fromJson: (data) => User.fromJson(data as Map<String, dynamic>),
|
|
);
|
|
}
|
|
|
|
/// 上传 KYC 资料
|
|
Future<ApiResponse<void>> uploadKyc(
|
|
String idCardFront,
|
|
String idCardBack,
|
|
) async {
|
|
return _client.post<void>(
|
|
ApiEndpoints.kyc,
|
|
data: {'idCardFront': idCardFront, 'idCardBack': idCardBack},
|
|
);
|
|
}
|
|
|
|
/// 退出登录
|
|
Future<ApiResponse<void>> logout() async {
|
|
return _client.post<void>(ApiEndpoints.logout);
|
|
}
|
|
}
|