111
This commit is contained in:
@@ -2,16 +2,16 @@ import '../../core/constants/api_endpoints.dart';
|
||||
import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
|
||||
/// 福利服务
|
||||
/// 福利中心服务
|
||||
class BonusService {
|
||||
final DioClient _client;
|
||||
|
||||
BonusService(this._client);
|
||||
|
||||
/// 查询新人福利状态
|
||||
Future<ApiResponse<Map<String, dynamic>>> getStatus() async {
|
||||
/// 获取福利中心状态
|
||||
Future<ApiResponse<Map<String, dynamic>>> getWelfareStatus() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusStatus,
|
||||
ApiEndpoints.bonusWelfare,
|
||||
);
|
||||
if (response.success && response.data != null) {
|
||||
return ApiResponse.success(response.data!, response.message);
|
||||
@@ -19,10 +19,26 @@ class BonusService {
|
||||
return ApiResponse.fail(response.message ?? '获取福利状态失败');
|
||||
}
|
||||
|
||||
/// 领取新人福利
|
||||
Future<ApiResponse<Map<String, dynamic>>> claim() async {
|
||||
/// 领取首充福利
|
||||
Future<ApiResponse<Map<String, dynamic>>> claimNewUserBonus() async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusClaim,
|
||||
data: {'type': 'new_user'},
|
||||
);
|
||||
}
|
||||
|
||||
/// 领取推广奖励
|
||||
Future<ApiResponse<Map<String, dynamic>>> claimReferralBonus(
|
||||
int referredUserId,
|
||||
int milestone,
|
||||
) async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusClaim,
|
||||
data: {
|
||||
'type': 'referral',
|
||||
'referredUserId': referredUserId,
|
||||
'milestone': milestone,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,24 @@ class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 用户注册
|
||||
/// 用户注册(multipart:含身份证图片和可选推广码)
|
||||
Future<ApiResponse<Map<String, dynamic>>> register(
|
||||
String username,
|
||||
String password,
|
||||
) async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
String password, {
|
||||
String? referralCode,
|
||||
required Uint8List frontBytes,
|
||||
required Uint8List backBytes,
|
||||
}) async {
|
||||
final formData = FormData.fromMap({
|
||||
'username': username,
|
||||
'password': password,
|
||||
if (referralCode != null && referralCode.isNotEmpty) 'referralCode': referralCode,
|
||||
'front': MultipartFile.fromBytes(frontBytes, filename: 'front.jpg'),
|
||||
'back': MultipartFile.fromBytes(backBytes, filename: 'back.jpg'),
|
||||
});
|
||||
return _client.upload<Map<String, dynamic>>(
|
||||
ApiEndpoints.register,
|
||||
data: {'username': username, 'password': password},
|
||||
formData: formData,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user