refactor: 将前端从 uni-app x 重构为 Flutter
变更内容: - 删除 uni-app x 项目 (app/ 目录) - 新增 Flutter 项目 (flutter_monisuo/ 目录) - 新增部署脚本 (deploy/ 目录) Flutter 项目功能: - 用户登录/注册 - 首页资产概览 - 行情币种列表 - 交易买卖操作 - 资产账户管理 - 充值/提现/划转 - 深色主题 - JWT Token 认证 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
78
flutter_monisuo/lib/data/services/trade_service.dart
Normal file
78
flutter_monisuo/lib/data/services/trade_service.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import '../../core/constants/api_endpoints.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/order_models.dart';
|
||||
|
||||
/// 交易服务
|
||||
class TradeService {
|
||||
final DioClient _client;
|
||||
|
||||
TradeService(this._client);
|
||||
|
||||
/// 买入
|
||||
Future<ApiResponse<Map<String, dynamic>>> buy({
|
||||
required String coinCode,
|
||||
required String price,
|
||||
required String quantity,
|
||||
}) async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.buy,
|
||||
data: {
|
||||
'coinCode': coinCode,
|
||||
'price': price,
|
||||
'quantity': quantity,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 卖出
|
||||
Future<ApiResponse<Map<String, dynamic>>> sell({
|
||||
required String coinCode,
|
||||
required String price,
|
||||
required String quantity,
|
||||
}) async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.sell,
|
||||
data: {
|
||||
'coinCode': coinCode,
|
||||
'price': price,
|
||||
'quantity': quantity,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取交易记录
|
||||
Future<ApiResponse<Map<String, dynamic>>> getOrders({
|
||||
String? coinCode,
|
||||
int? direction,
|
||||
int pageNum = 1,
|
||||
int pageSize = 20,
|
||||
}) async {
|
||||
final params = <String, dynamic>{
|
||||
'pageNum': pageNum,
|
||||
'pageSize': pageSize,
|
||||
};
|
||||
if (coinCode != null) params['coinCode'] = coinCode;
|
||||
if (direction != null) params['direction'] = direction;
|
||||
|
||||
return _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.tradeOrders,
|
||||
queryParameters: params,
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取订单详情
|
||||
Future<ApiResponse<OrderTrade>> getOrderDetail(String orderNo) async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.tradeOrderDetail,
|
||||
queryParameters: {'orderNo': orderNo},
|
||||
);
|
||||
|
||||
if (response.success && response.data != null) {
|
||||
return ApiResponse.success(
|
||||
OrderTrade.fromJson(response.data!),
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取订单详情失败');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user