Commit 6241482fb4ba6ed037c87b948cb8b0e1e1107a68
1 parent
6e731e0a
no message
Showing
3 changed files
with
25 additions
and
22 deletions
CNLiveLoginModule/Classes/Model/CNLiveLoginRequest.m
| @@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
| 25 | 25 | ||
| 26 | @implementation CNLiveLoginRequest | 26 | @implementation CNLiveLoginRequest |
| 27 | static const NSInteger timeValue = 1.5; | 27 | static const NSInteger timeValue = 1.5; |
| 28 | - | 28 | +#define XWKeyWindow [UIApplication sharedApplication].keyWindow |
| 29 | #pragma mark - 单例 | 29 | #pragma mark - 单例 |
| 30 | + (instancetype)manager { | 30 | + (instancetype)manager { |
| 31 | static CNLiveLoginRequest *_singleton = nil; | 31 | static CNLiveLoginRequest *_singleton = nil; |
| @@ -96,7 +96,7 @@ static const NSInteger timeValue = 1.5; | @@ -96,7 +96,7 @@ static const NSInteger timeValue = 1.5; | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{ | 98 | - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{ |
| 99 | - [QMUITips showLoading:@"正在连接服务器..." inView:[UIApplication sharedApplication].keyWindow]; | 99 | + [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow]; |
| 100 | 100 | ||
| 101 | // 1.获取token | 101 | // 1.获取token |
| 102 | [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) { | 102 | [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) { |
| @@ -107,7 +107,7 @@ static const NSInteger timeValue = 1.5; | @@ -107,7 +107,7 @@ static const NSInteger timeValue = 1.5; | ||
| 107 | 107 | ||
| 108 | // 2.登录im | 108 | // 2.登录im |
| 109 | [[IMAPlatform sharedInstance] login:self.loginParam succ:^{ | 109 | [[IMAPlatform sharedInstance] login:self.loginParam succ:^{ |
| 110 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | 110 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 111 | 111 | ||
| 112 | [self.loginParam saveToLocal]; | 112 | [self.loginParam saveToLocal]; |
| 113 | 113 | ||
| @@ -126,7 +126,7 @@ static const NSInteger timeValue = 1.5; | @@ -126,7 +126,7 @@ static const NSInteger timeValue = 1.5; | ||
| 126 | [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | 126 | [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; |
| 127 | [[NSUserDefaults standardUserDefaults] synchronize]; | 127 | [[NSUserDefaults standardUserDefaults] synchronize]; |
| 128 | 128 | ||
| 129 | - [QMUITips showSucceed:@"登录成功" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 129 | + [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 130 | success?success():@""; | 130 | success?success():@""; |
| 131 | 131 | ||
| 132 | // 3.im配置信息 | 132 | // 3.im配置信息 |
| @@ -141,21 +141,21 @@ static const NSInteger timeValue = 1.5; | @@ -141,21 +141,21 @@ static const NSInteger timeValue = 1.5; | ||
| 141 | 141 | ||
| 142 | } fail:^(int code, NSString *msg) { | 142 | } fail:^(int code, NSString *msg) { |
| 143 | NSLog(@"login failed : %@", msg); | 143 | NSLog(@"login failed : %@", msg); |
| 144 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | 144 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 145 | if (code == 6208) { | 145 | if (code == 6208) { |
| 146 | //离线被踢下线重新登录 | 146 | //离线被踢下线重新登录 |
| 147 | [self resumeLogin]; | 147 | [self resumeLogin]; |
| 148 | } | 148 | } |
| 149 | else{ | 149 | else{ |
| 150 | - [QMUITips showError:msg inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 150 | + [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 151 | failed?failed(code, msg):@""; | 151 | failed?failed(code, msg):@""; |
| 152 | } | 152 | } |
| 153 | }]; | 153 | }]; |
| 154 | 154 | ||
| 155 | } failed:^(int code, NSString * _Nonnull msg) { | 155 | } failed:^(int code, NSString * _Nonnull msg) { |
| 156 | NSLog(@"token code:%d msg:%@", code, msg); | 156 | NSLog(@"token code:%d msg:%@", code, msg); |
| 157 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | ||
| 158 | - [QMUITips showError:msg inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 157 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 158 | + [QMUITips showError:msg inView:XWKeyWindow hideAfterDelay:timeValue]; | ||
| 159 | failed?failed(code, msg):@""; | 159 | failed?failed(code, msg):@""; |
| 160 | 160 | ||
| 161 | }]; | 161 | }]; |
| @@ -166,8 +166,8 @@ static const NSInteger timeValue = 1.5; | @@ -166,8 +166,8 @@ static const NSInteger timeValue = 1.5; | ||
| 166 | - (void)resumeLogin { | 166 | - (void)resumeLogin { |
| 167 | __weak typeof(self)weakSelf = self; | 167 | __weak typeof(self)weakSelf = self; |
| 168 | [[IMAPlatform sharedInstance] login:self.loginParam succ:^{ | 168 | [[IMAPlatform sharedInstance] login:self.loginParam succ:^{ |
| 169 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | ||
| 170 | - [QMUITips showSucceed:@"登录成功" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 169 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 170 | + [QMUITips showSucceed:@"登录成功" inView:XWKeyWindow hideAfterDelay:timeValue]; | ||
| 171 | [self.loginParam saveToLocal]; | 171 | [self.loginParam saveToLocal]; |
| 172 | 172 | ||
| 173 | [[IMAPlatform sharedInstance] configHost:self.loginParam]; | 173 | [[IMAPlatform sharedInstance] configHost:self.loginParam]; |
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
| @@ -38,6 +38,7 @@ | @@ -38,6 +38,7 @@ | ||
| 38 | 38 | ||
| 39 | @end | 39 | @end |
| 40 | @implementation CNLiveCompleteInfoView | 40 | @implementation CNLiveCompleteInfoView |
| 41 | + | ||
| 41 | static NSInteger const rowHeight = 40; | 42 | static NSInteger const rowHeight = 40; |
| 42 | static NSInteger const space = 40; | 43 | static NSInteger const space = 40; |
| 43 | static const NSInteger timeValue = 1.5; | 44 | static const NSInteger timeValue = 1.5; |
CNLiveLoginModule/Classes/View/CNLiveLoginView.m
| @@ -43,6 +43,8 @@ | @@ -43,6 +43,8 @@ | ||
| 43 | @end | 43 | @end |
| 44 | 44 | ||
| 45 | @implementation CNLiveLoginView | 45 | @implementation CNLiveLoginView |
| 46 | +#define XWKeyWindow [UIApplication sharedApplication].keyWindow | ||
| 47 | + | ||
| 46 | static NSInteger const rowHeight = 40; | 48 | static NSInteger const rowHeight = 40; |
| 47 | static NSInteger const space = 20; | 49 | static NSInteger const space = 20; |
| 48 | static const NSInteger timeValue = 1.5; | 50 | static const NSInteger timeValue = 1.5; |
| @@ -251,20 +253,20 @@ static const NSInteger timeValue = 1.5; | @@ -251,20 +253,20 @@ static const NSInteger timeValue = 1.5; | ||
| 251 | [_code resignFirstResponder]; | 253 | [_code resignFirstResponder]; |
| 252 | //获取验证码 | 254 | //获取验证码 |
| 253 | if ([_account.text isEqualToString:@""]) { | 255 | if ([_account.text isEqualToString:@""]) { |
| 254 | - [QMUITips showError:@"请输入手机号" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 256 | + [QMUITips showError:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 255 | return; | 257 | return; |
| 256 | } | 258 | } |
| 257 | // 按钮点击后将enabled设置为NO | 259 | // 按钮点击后将enabled设置为NO |
| 258 | button.userInteractionEnabled = NO; | 260 | button.userInteractionEnabled = NO; |
| 259 | 261 | ||
| 260 | __weak typeof(self) weakSelf = self; | 262 | __weak typeof(self) weakSelf = self; |
| 261 | - [QMUITips showLoadingInView:[UIApplication sharedApplication].keyWindow]; | 263 | + [QMUITips showLoadingInView:XWKeyWindow]; |
| 262 | [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_account.text countryCode:_countryCode success:^(id result) { | 264 | [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_account.text countryCode:_countryCode success:^(id result) { |
| 263 | button.userInteractionEnabled = YES; | 265 | button.userInteractionEnabled = YES; |
| 264 | __strong typeof(weakSelf) strongSelf = weakSelf; | 266 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 265 | if(!strongSelf) return; | 267 | if(!strongSelf) return; |
| 266 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | ||
| 267 | - [QMUITips showSucceed:@"验证码已发送" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 268 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 269 | + [QMUITips showSucceed:@"验证码已发送" inView:XWKeyWindow hideAfterDelay:timeValue]; | ||
| 268 | button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0]; | 270 | button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0]; |
| 269 | button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); | 271 | button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); |
| 270 | [button setImage:nil forState:UIControlStateNormal]; | 272 | [button setImage:nil forState:UIControlStateNormal]; |
| @@ -275,11 +277,11 @@ static const NSInteger timeValue = 1.5; | @@ -275,11 +277,11 @@ static const NSInteger timeValue = 1.5; | ||
| 275 | button.userInteractionEnabled = YES; | 277 | button.userInteractionEnabled = YES; |
| 276 | __strong typeof(weakSelf) strongSelf = weakSelf; | 278 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 277 | if(!strongSelf) return; | 279 | if(!strongSelf) return; |
| 278 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | 280 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 279 | if ([errorDic[@"errorCode"] integerValue] == 408) { | 281 | if ([errorDic[@"errorCode"] integerValue] == 408) { |
| 280 | - [QMUITips showError:@"请输入正确的手机号" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 282 | + [QMUITips showError:@"请输入正确的手机号" inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 281 | }else{ | 283 | }else{ |
| 282 | - [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 284 | + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 283 | } | 285 | } |
| 284 | 286 | ||
| 285 | }]; | 287 | }]; |
| @@ -312,18 +314,18 @@ static const NSInteger timeValue = 1.5; | @@ -312,18 +314,18 @@ static const NSInteger timeValue = 1.5; | ||
| 312 | [_code resignFirstResponder]; | 314 | [_code resignFirstResponder]; |
| 313 | //登录 | 315 | //登录 |
| 314 | if ([_account.text isEqualToString:@""]) { | 316 | if ([_account.text isEqualToString:@""]) { |
| 315 | - [QMUITips showError:@"请输入手机号" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 317 | + [QMUITips showError:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 316 | return; | 318 | return; |
| 317 | } | 319 | } |
| 318 | if ([_code.text isEqualToString:@""]) { | 320 | if ([_code.text isEqualToString:@""]) { |
| 319 | - [QMUITips showError:@"请输入验证码" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 321 | + [QMUITips showError:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:timeValue]; |
| 320 | return; | 322 | return; |
| 321 | } | 323 | } |
| 322 | btn.userInteractionEnabled = NO; | 324 | btn.userInteractionEnabled = NO; |
| 323 | // 隐藏键盘 | 325 | // 隐藏键盘 |
| 324 | [self.superview endEditing:YES]; | 326 | [self.superview endEditing:YES]; |
| 325 | 327 | ||
| 326 | - [QMUITips showLoading:@"登录中" inView:[UIApplication sharedApplication].keyWindow]; | 328 | + [QMUITips showLoading:@"登录中" inView:XWKeyWindow]; |
| 327 | 329 | ||
| 328 | __weak typeof(self) weakSelf = self; | 330 | __weak typeof(self) weakSelf = self; |
| 329 | [CNLiveUserSystemCenter shortcutLoginWithUserName:_account.text countryCode:_countryCode verificationCode:_code.text frmId:@"apple" success:^(id result) { | 331 | [CNLiveUserSystemCenter shortcutLoginWithUserName:_account.text countryCode:_countryCode verificationCode:_code.text frmId:@"apple" success:^(id result) { |
| @@ -337,8 +339,8 @@ static const NSInteger timeValue = 1.5; | @@ -337,8 +339,8 @@ static const NSInteger timeValue = 1.5; | ||
| 337 | btn.userInteractionEnabled = YES; | 339 | btn.userInteractionEnabled = YES; |
| 338 | __strong typeof(weakSelf) strongSelf = weakSelf; | 340 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 339 | if(!strongSelf) return; | 341 | if(!strongSelf) return; |
| 340 | - [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES]; | ||
| 341 | - [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:timeValue]; | 342 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; |
| 343 | + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:XWKeyWindow hideAfterDelay:timeValue]; | ||
| 342 | }]; | 344 | }]; |
| 343 | } | 345 | } |
| 344 | 346 |