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