107 lines
3.2 KiB
Objective-C
107 lines
3.2 KiB
Objective-C
//
|
|
// LoginFullInfoPresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/9/14.
|
|
//
|
|
|
|
#import "LoginFullInfoPresenter.h"
|
|
///Api
|
|
#import "Api+Login.h"
|
|
#import "LoginFullInfoProtocol.h"
|
|
#import "NSMutableDictionary+Saft.h"
|
|
///Tool
|
|
#import "AccountInfoStorage.h"
|
|
///Model
|
|
#import "ThirdUserInfo.h"
|
|
#import "RegionListInfo.h"
|
|
|
|
@implementation LoginFullInfoPresenter
|
|
|
|
- (id<LoginFullInfoProtocol>)getView {
|
|
return ((id<LoginFullInfoProtocol>) [super getView]);
|
|
}
|
|
|
|
|
|
/// 获取保存的第三方的数据模型
|
|
- (ThirdUserInfo *)getThirdUserInfo {
|
|
if ([AccountInfoStorage instance].thirdUserInfo) {
|
|
return [AccountInfoStorage instance].thirdUserInfo;
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
/// 随机获取昵称
|
|
- (void)randomRequestNick {
|
|
[Api randomNick:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] requestRandomNickSuccess:data.data];
|
|
}]];
|
|
}
|
|
|
|
|
|
/// 补全资料
|
|
/// @param avatar 头像
|
|
/// @param gender 性别
|
|
/// @param nick 昵称
|
|
/// @param inviteCode 邀请码
|
|
/// @param roomUid 邀请的那个房间的uid
|
|
/// @param shareUid 邀请人的uid
|
|
/// @param shareChannel 邀请的渠道
|
|
- (void)complectionInfoWithAvatar:(NSString *)avatar
|
|
gender:(NSString *)gender
|
|
nick:(NSString *)nick
|
|
inviteCode:(NSString * __nullable)inviteCode
|
|
roomUid:(NSString * __nullable)roomUid
|
|
shareUid:(NSString * __nullable)shareUid
|
|
shareChannel:(NSString * __nullable)shareChannel
|
|
regionId:(NSString *)regionId{
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
|
NSMutableDictionary * params = [NSMutableDictionary dictionary];
|
|
[params safeSetObject:avatar forKey:@"avatar"];
|
|
[params safeSetObject:gender forKey:@"gender"];
|
|
[params safeSetObject:nick forKey:@"nick"];
|
|
[params safeSetObject:uid forKey:@"uid"];
|
|
[params safeSetObject:ticket forKey:@"ticket"];
|
|
if (regionId.length > 0) {
|
|
[params safeSetObject:regionId forKey:@"regionId"];
|
|
}
|
|
if (inviteCode.length > 0) {
|
|
[params safeSetObject:inviteCode forKey:@"inviteCode"];
|
|
}
|
|
|
|
if (roomUid.length > 0) {
|
|
[params safeSetObject:roomUid forKey:@"roomUid"];
|
|
}
|
|
|
|
if (shareUid.length > 0) {
|
|
[params safeSetObject:shareUid forKey:@"shareUid"];
|
|
}
|
|
|
|
if (shareChannel.length > 0) {
|
|
[params safeSetObject:shareChannel forKey:@"shareChannel"];
|
|
}
|
|
[Api completeUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] complementInfoSuccess];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] complementInfoFail];
|
|
} errorToast:YES] userInfo:params];
|
|
}
|
|
|
|
- (void)loadAllRegionInfo:(void(^)(NSArray <RegionListInfo *>*array))success failure:(void(^)(NSError *error))failure {
|
|
[Api requestAllRegionInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
if (data.code == 200) {
|
|
NSArray *array = [RegionListInfo modelsWithArray:data.data];
|
|
if (success) {
|
|
success(array);
|
|
}
|
|
}
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
if (failure) {
|
|
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
|
|
}
|
|
} showLoading:YES errorToast:YES]];
|
|
}
|
|
|
|
@end
|