2023-10-07 16:21:47 +08:00
|
|
|
|
//
|
|
|
|
|
// PILoginManager.m
|
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by duoban on 2023/10/7.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "PILoginManager.h"
|
|
|
|
|
///api
|
|
|
|
|
#import "Api+Main.h"
|
|
|
|
|
///vc
|
|
|
|
|
#import "LoginFullInfoViewController.h"
|
|
|
|
|
#import "TabbarViewController.h"
|
|
|
|
|
#import "BaseNavigationController.h"
|
|
|
|
|
#import "LoginVerifCodeViewController.h"
|
|
|
|
|
///Model
|
|
|
|
|
#import "ThirdUserInfo.h"
|
|
|
|
|
#import "AccountModel.h"
|
|
|
|
|
#import "UserInfoModel.h"
|
2023-10-08 11:51:16 +08:00
|
|
|
|
#import "XPLoginAuthCodeVC.h"
|
2025-06-26 11:08:21 +08:00
|
|
|
|
#import "FirstRechargeManager.h"
|
2025-08-14 18:04:38 +08:00
|
|
|
|
#import "PublicRoomManager.h"
|
2025-08-08 17:01:59 +08:00
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
@implementation PILoginManager
|
|
|
|
|
+(void)loginWithVC:(MvpViewController *)VC isLoginPhone:(BOOL)isLoginPhone{
|
2025-03-21 16:19:07 +08:00
|
|
|
|
[XNDJTDDLoadingTool showLoading];
|
2023-10-07 16:21:47 +08:00
|
|
|
|
AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo];
|
|
|
|
|
HomeUserModel *homeUserModel = [HomeUserModel new];
|
|
|
|
|
if (accountModel == nil || accountModel.uid == nil || accountModel.access_token == nil) {
|
|
|
|
|
[XNDJTDDLoadingTool hideOnlyView:VC.view];
|
|
|
|
|
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"LoginPresenter1")];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
__block UserInfoModel *userInfo;
|
|
|
|
|
dispatch_group_t group = dispatch_group_create();
|
|
|
|
|
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
|
|
|
|
|
dispatch_group_enter(group);
|
|
|
|
|
dispatch_async(queue, ^{
|
|
|
|
|
[Api requestTicket:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if(code == 200){
|
|
|
|
|
NSArray *tickets = [data.data valueForKey:@"tickets"];
|
|
|
|
|
NSString *ticket = [tickets[0] valueForKey:@"ticket"];
|
|
|
|
|
homeUserModel.ticket = ticket;
|
|
|
|
|
[[AccountInfoStorage instance] saveTicket:ticket];
|
2024-04-03 17:18:44 +08:00
|
|
|
|
|
|
|
|
|
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if(code == 200){
|
|
|
|
|
userInfo = [UserInfoModel modelWithDictionary:data.data];
|
|
|
|
|
[AccountInfoStorage instance].name = userInfo.nick;
|
|
|
|
|
homeUserModel.nick = userInfo.nick;
|
|
|
|
|
homeUserModel.avatar = userInfo.avatar;
|
|
|
|
|
homeUserModel.isBindPhone = userInfo.isBindPhone;
|
|
|
|
|
}
|
|
|
|
|
dispatch_group_leave(group);
|
|
|
|
|
} uid:accountModel.uid];
|
|
|
|
|
return;
|
2023-10-07 16:21:47 +08:00
|
|
|
|
}
|
|
|
|
|
dispatch_group_leave(group);
|
|
|
|
|
} access_token:accountModel.access_token issue_type:@"multi"];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
|
|
|
|
[XNDJTDDLoadingTool hideOnlyView:VC.view];
|
2023-11-23 10:56:01 +08:00
|
|
|
|
if ([[AccountInfoStorage instance] getTicket].length <= 0 || userInfo == nil) {
|
2023-10-07 16:21:47 +08:00
|
|
|
|
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"LoginPresenter1")];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[[AccountInfoStorage instance]saveHomeUserInfo:homeUserModel];
|
|
|
|
|
if (userInfo.nick == nil || userInfo.avatar == nil) {
|
|
|
|
|
LoginFullInfoViewController * FullVC = [[LoginFullInfoViewController alloc] init];
|
|
|
|
|
[VC.navigationController pushViewController:FullVC animated:YES];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"PKIDLoginViewController0")];
|
2025-08-08 17:01:59 +08:00
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
[PILoginManager jumpToHomeVCWithInviteCode:@""];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
+(void)jumpToHomeVCWithInviteCode:(NSString *)inviteCode{
|
|
|
|
|
TabbarViewController *vc = [[TabbarViewController alloc] init];
|
|
|
|
|
vc.isFormLogin = YES;
|
|
|
|
|
vc.inviteCode = inviteCode;
|
|
|
|
|
BaseNavigationController *bnc = [[BaseNavigationController alloc] initWithRootViewController:vc];
|
|
|
|
|
kWindow.rootViewController = bnc;
|
2025-06-26 11:08:21 +08:00
|
|
|
|
|
|
|
|
|
// 登录成功并进入主页后,启动首充监控
|
|
|
|
|
[[FirstRechargeManager sharedManager] startMonitoring];
|
2025-08-14 18:04:38 +08:00
|
|
|
|
|
|
|
|
|
// 初始化公共房间管理器
|
|
|
|
|
[[PublicRoomManager sharedManager] initialize];
|
2023-10-07 16:21:47 +08:00
|
|
|
|
}
|
|
|
|
|
@end
|