Commit 27d8543147f2bd831f8e746c60473afc15863cb7
1 parent
b986563f
no message
Showing
9 changed files
with
175 additions
and
133 deletions
CNLiveLoginModule.podspec
| ... | ... | @@ -70,7 +70,7 @@ TODO: 网家家-登录模块. |
| 70 | 70 | 'CNLiveLoginModule' => ['CNLiveLoginModule/Assets/CNLiveLoginModule.xcassets'] |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - # s.public_header_files = 'Pod/Classes/**/*.h' | |
| 73 | +# s.public_header_files = 'CNLiveLoginModule/Classes/**/*.h' | |
| 74 | 74 | # s.frameworks = 'UIKit', 'MapKit' |
| 75 | 75 | |
| 76 | 76 | # pod | ... | ... |
CNLiveLoginModule/Classes/Controller/CNLiveLoginController.m
| ... | ... | @@ -94,7 +94,7 @@ |
| 94 | 94 | |
| 95 | 95 | #pragma mark - CNLiveLoginViewDelegate |
| 96 | 96 | - (void)loginSuccess:(CNLiveLoginView *)view isNewUser:(BOOL)isNewUser result:(id _Nonnull)result{ |
| 97 | - if (isNewUser) { | |
| 97 | + if (!isNewUser) { | |
| 98 | 98 | // 新用户 -> 设置昵称和头像 |
| 99 | 99 | CNLiveCompleteInfoController *vc = [[CNLiveCompleteInfoController alloc]init]; |
| 100 | 100 | vc.hidesBottomBarWhenPushed = YES; | ... | ... |
CNLiveLoginModule/Classes/Model/CNLiveLoginRequest.m
| ... | ... | @@ -84,9 +84,7 @@ static const NSInteger timeValue = 1.5; |
| 84 | 84 | failed(31012, @"获取token失败"); |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - | |
| 88 | 87 | } |
| 89 | - | |
| 90 | 88 | }else{ |
| 91 | 89 | if (failed) failed(31012, @"获取token失败"); |
| 92 | 90 | } |
| ... | ... | @@ -97,7 +95,6 @@ static const NSInteger timeValue = 1.5; |
| 97 | 95 | // 登录IM |
| 98 | 96 | - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{ |
| 99 | 97 | [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow]; |
| 100 | - | |
| 101 | 98 | // 1.获取token |
| 102 | 99 | [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) { |
| 103 | 100 | ... | ... |
CNLiveLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m
| ... | ... | @@ -9,8 +9,13 @@ |
| 9 | 9 | #import "CNLiveBindingTelView.h" |
| 10 | 10 | #import "YYKit.h" |
| 11 | 11 | #import "QMUIKit.h" |
| 12 | +#import <CNLiveRequestBastKit/CNLiveNetworking.h> | |
| 13 | + | |
| 12 | 14 | #import "CNLiveCategory.h" |
| 13 | 15 | #import "CNLiveEnvironment.h" |
| 16 | +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h> | |
| 17 | +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h> | |
| 18 | +#import "CNUserInfoManager.h" | |
| 14 | 19 | |
| 15 | 20 | #import "CNLiveLoginCountryView.h" |
| 16 | 21 | #import "CNLiveLoginTextField.h" |
| ... | ... | @@ -31,6 +36,7 @@ |
| 31 | 36 | @end |
| 32 | 37 | |
| 33 | 38 | @implementation CNLiveBindingTelView |
| 39 | +#define XWKeyWindow [UIApplication sharedApplication].keyWindow | |
| 34 | 40 | static NSInteger const rowHeight = 40; |
| 35 | 41 | static NSInteger const space = 40; |
| 36 | 42 | static const NSInteger timeValue = 1.5; |
| ... | ... | @@ -209,33 +215,42 @@ static const NSInteger timeValue = 1.5; |
| 209 | 215 | - (void)countDownButtonDidClick:(CNLiveCountDownButton *)button { |
| 210 | 216 | //获取验证码 |
| 211 | 217 | if ([_account.text isEqualToString:@""]) { |
| 212 | - [QMUITips showError:@"请输入手机号" inView:self.superview hideAfterDelay:timeValue]; | |
| 218 | + [QMUITips showWithText:@"请输入手机号"]; | |
| 213 | 219 | return; |
| 214 | 220 | } |
| 215 | - // 按钮点击后将enabled设置为NO | |
| 221 | + if(![CNLiveNetworking isNetworking]){ | |
| 222 | + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:timeValue]; | |
| 223 | + return ; | |
| 224 | + } | |
| 225 | + _code.text = @""; | |
| 226 | + [_code becomeFirstResponder]; | |
| 227 | + | |
| 216 | 228 | button.userInteractionEnabled = NO; |
| 217 | - __weak typeof(self) weakSelf = self; | |
| 218 | -// [XWUserRequest verificationCodeWithType:XWCodeTypeShortcutLogin mobile:_account.text countryCode:_countryCode success:^(id _Nonnull result) { | |
| 219 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 220 | -// if(!strongSelf) return; | |
| 221 | -// // 获取的验证码 | |
| 222 | -// strongSelf->_verificationCode = @"666666"; | |
| 223 | -// | |
| 224 | -// [XWAlertView alertSucceedViewWithTextMessage:@"获取成功" view:strongSelf.superview]; | |
| 229 | + [QMUITips showLoadingInView:XWKeyWindow]; | |
| 230 | + | |
| 231 | + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_account.text countryCode:@"86" success:^(id result) { | |
| 232 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | |
| 233 | + [QMUITips showWithText:@"验证码已发送"]; | |
| 234 | + | |
| 225 | 235 | // button.backgroundColor = HexColor(0xdedede); |
| 226 | -// button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); | |
| 227 | -// [button setImage:nil forState:UIControlStateNormal]; | |
| 228 | -// NSString *title = [NSString stringWithFormat:@"%d秒后重新发送", 60]; | |
| 229 | -// [button setTitle:title forState:UIControlStateNormal]; | |
| 230 | -// [button startCountDown]; | |
| 231 | -// | |
| 232 | -// } failure:^(NSDictionary * _Nonnull errorDic) { | |
| 233 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 234 | -// if(!strongSelf) return; | |
| 235 | -// button.userInteractionEnabled = YES; | |
| 236 | -// [XWAlertView alertErrorViewWithTextMessage:@"获取失败" view:strongSelf.superview]; | |
| 237 | -// | |
| 238 | -// }]; | |
| 236 | + button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); | |
| 237 | + [button setImage:nil forState:UIControlStateNormal]; | |
| 238 | + NSString *title = [NSString stringWithFormat:@"%d秒后重新发送", 60]; | |
| 239 | + [button setTitle:title forState:UIControlStateNormal]; | |
| 240 | + [button startCountDown]; | |
| 241 | + | |
| 242 | + | |
| 243 | + } failure:^(NSDictionary *errorDic) { | |
| 244 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | |
| 245 | + if ([errorDic[@"errorCode"] integerValue] == 408) { | |
| 246 | + [QMUITips showWithText:@"请输入正确的手机号"]; | |
| 247 | + } | |
| 248 | + else{ | |
| 249 | + [QMUITips showWithText:errorDic[@"errorMessage"]]; | |
| 250 | + } | |
| 251 | + button.userInteractionEnabled = YES; | |
| 252 | + | |
| 253 | + }]; | |
| 239 | 254 | |
| 240 | 255 | } |
| 241 | 256 | |
| ... | ... | @@ -255,44 +270,92 @@ static const NSInteger timeValue = 1.5; |
| 255 | 270 | button.backgroundColor = [UIColor whiteColor]; |
| 256 | 271 | button.userInteractionEnabled = YES; |
| 257 | 272 | [button setTitle:@"" forState:UIControlStateNormal]; |
| 258 | - UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 273 | + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 259 | 274 | [button setImage:image2 forState:UIControlStateNormal]; |
| 260 | 275 | } |
| 261 | 276 | |
| 262 | 277 | #pragma mark - Action |
| 263 | -- (void)codeDidClicked:(UIButton *)btn{ | |
| 264 | - //获取验证码 | |
| 265 | - if ([_account.text isEqualToString:@""]) { | |
| 266 | - [QMUITips showError:@"请输入手机号" inView:self.superview hideAfterDelay:timeValue]; | |
| 278 | +- (void)bindingDidClicked:(UIButton *)btn{ | |
| 279 | + if ([self.account.text isEqualToString:@""]) { | |
| 280 | + [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 267 | 281 | return; |
| 268 | 282 | } |
| 269 | - __weak typeof(self) weakSelf = self; | |
| 270 | -// [XWUserRequest verificationCodeWithType:XWCodeTypeShortcutLogin mobile:_account.text countryCode:_countryCode success:^(id _Nonnull result) { | |
| 271 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 272 | -// if(!strongSelf) return; | |
| 273 | -// [XWAlertView alertSucceedViewWithTextMessage:@"获取成功" view:strongSelf.superview]; | |
| 274 | -// strongSelf->_verificationCode = @"666666"; | |
| 275 | -// | |
| 276 | -// } failure:^(NSDictionary * _Nonnull errorDic) { | |
| 277 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 278 | -// if(!strongSelf) return; | |
| 279 | -// [XWAlertView alertErrorViewWithTextMessage:@"获取失败" view:strongSelf.superview]; | |
| 280 | -// | |
| 281 | -// }]; | |
| 283 | + if ([self.code.text isEqualToString:@""]) { | |
| 284 | + [QMUITips showWithText:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 285 | + return; | |
| 286 | + } | |
| 287 | + [self endEditing:YES]; | |
| 288 | + if(![CNLiveNetworking isNetworking]){ | |
| 289 | + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 290 | + return ; | |
| 291 | + } | |
| 292 | + btn.userInteractionEnabled = NO; | |
| 293 | + // 绑定手机号请求登录 | |
| 294 | + [self thirdPartyLoginBindingTel]; | |
| 282 | 295 | |
| 283 | 296 | } |
| 284 | 297 | |
| 285 | -- (void)bindingDidClicked:(UIButton *)btn{ | |
| 298 | +// 绑定手机号请求登录 | |
| 299 | +- (void)thirdPartyLoginBindingTel{ | |
| 300 | + NSDictionary *params = @{ | |
| 301 | + @"mobile":self.account.text, | |
| 302 | +// @"countryCode":self.model.countryCode?self.model.countryCode:@"", | |
| 303 | +// @"verificationCode":self.code.text, | |
| 304 | +// @"thirdPartyPlat":self.model.thirdPartyPlat?self.model.thirdPartyPlat:@"", | |
| 305 | +// @"thirdPartyId":self.model.thirdPartyId?self.model.thirdPartyId:@"", | |
| 306 | +// @"frmId":self.model.frmId?self.model.frmId:@"", | |
| 307 | +// @"clientPlat":@"i", | |
| 308 | +// @"nickName":self.model.nickName?self.model.nickName:@"", | |
| 309 | +// @"gender":self.model.gender?self.model.gender:@"", | |
| 310 | +// @"location":self.model.location?self.model.location:@"", | |
| 311 | +// @"faceUrl":self.model.faceUrl?self.model.faceUrl:@"" | |
| 312 | + }; | |
| 313 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 314 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 315 | + | |
| 316 | + [QMUITips showLoadingInView:XWKeyWindow]; | |
| 317 | + __weak typeof(self) weakSelf = self; | |
| 318 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNLoginIn3rdAndMobileForWJJUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 319 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 320 | + if(!strongSelf) return; | |
| 321 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | |
| 322 | + strongSelf.binding.userInteractionEnabled = YES; | |
| 323 | + if (error.code == -1001 || error.code == -1009) { | |
| 324 | + [QMUITips showError:@"无法连接网络" inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 325 | + return ; | |
| 326 | + } | |
| 327 | + if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) { | |
| 328 | + | |
| 329 | + // 给用户库使用 | |
| 330 | + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
| 331 | + [userDefaults setObject:responseObject[@"data"][@"token"] forKey:@"CNLiveAuthToken"]; | |
| 332 | + [userDefaults setObject:responseObject[@"data"][@"uid"] forKey:@"CNLiveUserSid"]; | |
| 333 | + [userDefaults synchronize]; | |
| 334 | + | |
| 335 | + //登录成功,连接IM | |
| 336 | + [strongSelf connectionIM:responseObject[@"data"]]; | |
| 337 | + } | |
| 338 | + else if ([responseObject isKindOfClass:[NSDictionary class]]) { | |
| 339 | + [QMUITips showError:responseObject[@"errorMessage"] inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 340 | + } | |
| 341 | + else{ | |
| 342 | + [QMUITips showError:@"登录失败" inView:XWKeyWindow hideAfterDelay:1.5]; | |
| 343 | + } | |
| 344 | + | |
| 345 | + }]; | |
| 346 | + | |
| 347 | +} | |
| 348 | +- (void)connectionIM:(id)result{ | |
| 349 | + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]]; | |
| 350 | + NSString *faceUrl = [dic objectForKey:@"faceUrl"]; | |
| 351 | + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | |
| 352 | + //网家家默认头像地址 | |
| 353 | + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"]; | |
| 354 | + } | |
| 355 | + [CNUserInfoManager saveUserinfoDic:dic]; | |
| 286 | 356 | if (self.delegate && [self.delegate respondsToSelector:@selector(bindingSuccess:type:)]) { |
| 287 | 357 | [self.delegate bindingSuccess:self type:self.type]; |
| 288 | 358 | } |
| 289 | -// [XWUserRequest thirdPartyLoginBindingWithUserName:_account.text verificationCode:_code.text countryCode:_countryCode model:User_Model fromId:nil success:^(id _Nonnull result) { | |
| 290 | -// | |
| 291 | -// } failure:^(NSDictionary * _Nonnull errorDic) { | |
| 292 | -// | |
| 293 | -// }]; | |
| 294 | - | |
| 295 | 359 | } |
| 296 | 360 | |
| 297 | - | |
| 298 | 361 | @end | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
| ... | ... | @@ -89,7 +89,8 @@ static const NSInteger timeValue = 1.5; |
| 89 | 89 | [next setTitle:@"下一步" forState:UIControlStateNormal]; |
| 90 | 90 | [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
| 91 | 91 | next.titleLabel.font = [UIFont systemFontOfSize:15.0]; |
| 92 | - next.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | |
| 92 | + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | |
| 93 | + next.backgroundColor = color; | |
| 93 | 94 | next.layer.cornerRadius = 20; |
| 94 | 95 | next.layer.masksToBounds = YES; |
| 95 | 96 | next.adjustsImageWhenHighlighted = NO; |
| ... | ... | @@ -216,8 +217,9 @@ static const NSInteger timeValue = 1.5; |
| 216 | 217 | [alertController addAction:cancel]; |
| 217 | 218 | |
| 218 | 219 | NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; |
| 219 | - | |
| 220 | - titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | |
| 220 | + UIColor *color = Business?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | |
| 221 | + | |
| 222 | + titleAttributs[NSForegroundColorAttributeName] = color; | |
| 221 | 223 | |
| 222 | 224 | NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; |
| 223 | 225 | cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; |
| ... | ... | @@ -243,65 +245,85 @@ static const NSInteger timeValue = 1.5; |
| 243 | 245 | } |
| 244 | 246 | self.next.userInteractionEnabled = NO; |
| 245 | 247 | [self.superview endEditing:YES]; |
| 246 | - [self modifyIcon]; | |
| 248 | + [self modifyNickName]; | |
| 247 | 249 | } |
| 248 | 250 | |
| 249 | -// 修改头像 | |
| 250 | -- (void)modifyIcon { | |
| 251 | +// 修改名字 | |
| 252 | +- (void)modifyNickName { | |
| 251 | 253 | [QMUITips showLoading:@"修改中" inView:self.superview]; |
| 252 | - [CNLiveUserSystemCenter uploadIconWithUid:CNUserShareModel.uid icon:_image success:^(id result) { | |
| 253 | - [QMUITips hideAllToastInView:self.superview animated:YES]; | |
| 254 | - NSLog(@"result:%@",result); | |
| 255 | - NSString *deFaceUrl = result[@"data"][@"faceUrl"]; | |
| 256 | - NSString *faceUrl = @""; | |
| 257 | - if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | |
| 258 | - faceUrl = CNLiveNetAddDefaultHead; | |
| 254 | + __weak typeof(self) weakSelf = self; | |
| 255 | + [CNLiveUserSystemCenter modifyUserInfoType:UserInfoTypeNickName uid:CNUserShareModel.uid modifyInfo:_nickname.text success:^(id result) { | |
| 256 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 257 | + if(!strongSelf) return; | |
| 258 | + strongSelf.next.userInteractionEnabled = YES; | |
| 259 | + CNUserShareModel.nickname = strongSelf.nickname.text; | |
| 260 | + [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; | |
| 261 | + | |
| 262 | + if (!strongSelf->_image) { | |
| 263 | + [strongSelf connectionIM:result]; | |
| 264 | + | |
| 259 | 265 | }else{ |
| 260 | - faceUrl = deFaceUrl; | |
| 266 | + [strongSelf modifyIcon]; | |
| 261 | 267 | } |
| 262 | - CNUserShareModel.faceUrl = faceUrl; | |
| 263 | - [self modifyNickName]; | |
| 264 | - | |
| 268 | + | |
| 265 | 269 | } failure:^(NSDictionary *errorDic) { |
| 266 | - [QMUITips hideAllToastInView:self.superview animated:YES]; | |
| 267 | - [QMUITips showError:errorDic[@"errorMessage"] inView:self.superview hideAfterDelay:timeValue]; | |
| 270 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 271 | + if(!strongSelf) return; | |
| 272 | + strongSelf.next.userInteractionEnabled = YES; | |
| 273 | + [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; | |
| 274 | + [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; | |
| 268 | 275 | }]; |
| 269 | 276 | |
| 270 | 277 | } |
| 271 | 278 | |
| 272 | -// 修改名字 | |
| 273 | -- (void)modifyNickName { | |
| 279 | +// 修改头像 | |
| 280 | +- (void)modifyIcon { | |
| 274 | 281 | [QMUITips showLoading:@"修改中" inView:self.superview]; |
| 275 | 282 | __weak typeof(self) weakSelf = self; |
| 276 | - [CNLiveUserSystemCenter modifyUserInfoType:UserInfoTypeNickName uid:CNUserShareModel.uid modifyInfo:_nickname.text success:^(id result) { | |
| 283 | + [CNLiveUserSystemCenter uploadIconWithUid:CNUserShareModel.uid icon:_image success:^(id result) { | |
| 277 | 284 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 278 | 285 | if(!strongSelf) return; |
| 279 | 286 | strongSelf.next.userInteractionEnabled = YES; |
| 280 | - CNUserShareModel.nickname = strongSelf.nickname.text; | |
| 281 | 287 | [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; |
| 282 | - if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) { | |
| 283 | - [strongSelf.delegate loginSuccess:strongSelf result:result]; | |
| 288 | + NSLog(@"result:%@",result); | |
| 289 | + NSString *deFaceUrl = result[@"data"][@"faceUrl"]; | |
| 290 | + NSString *faceUrl = @""; | |
| 291 | + if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | |
| 292 | + faceUrl = CNLiveNetAddDefaultHead; | |
| 293 | + }else{ | |
| 294 | + faceUrl = deFaceUrl; | |
| 284 | 295 | } |
| 285 | - | |
| 286 | - [strongSelf connectionIM]; | |
| 287 | - | |
| 296 | + CNUserShareModel.faceUrl = faceUrl; | |
| 297 | + [strongSelf connectionIM:result]; | |
| 298 | + | |
| 288 | 299 | } failure:^(NSDictionary *errorDic) { |
| 289 | 300 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 290 | 301 | if(!strongSelf) return; |
| 291 | 302 | strongSelf.next.userInteractionEnabled = YES; |
| 292 | 303 | [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; |
| 293 | - [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; | |
| 304 | + [QMUITips showError:errorDic[@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; | |
| 294 | 305 | }]; |
| 295 | 306 | |
| 296 | 307 | } |
| 297 | 308 | |
| 298 | 309 | // 连接IM |
| 299 | -- (void)connectionIM { | |
| 310 | +- (void)connectionIM:(id)result{ | |
| 311 | + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]]; | |
| 312 | + NSString *faceUrl = [dic objectForKey:@"faceUrl"]; | |
| 313 | + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | |
| 314 | + //网家家默认头像地址 | |
| 315 | + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"]; | |
| 316 | + } | |
| 317 | + [CNUserInfoManager saveUserinfoDic:dic]; | |
| 318 | + | |
| 300 | 319 | __weak typeof(self) weakSelf = self; |
| 301 | 320 | [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{ |
| 302 | 321 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 303 | 322 | if(!strongSelf) return; |
| 304 | 323 | // 进入tabbar |
| 324 | + if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) { | |
| 325 | + [strongSelf.delegate loginSuccess:strongSelf result:result]; | |
| 326 | + } | |
| 305 | 327 | |
| 306 | 328 | } failed:^(int code, NSString * _Nonnull msg) { |
| 307 | 329 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| ... | ... | @@ -310,7 +332,7 @@ static const NSInteger timeValue = 1.5; |
| 310 | 332 | [QMUITips showError:msg inView:strongSelf.superview hideAfterDelay:timeValue]; |
| 311 | 333 | |
| 312 | 334 | }]; |
| 313 | - | |
| 335 | + | |
| 314 | 336 | } |
| 315 | 337 | |
| 316 | 338 | /* | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginView.m
| ... | ... | @@ -141,24 +141,19 @@ static const NSInteger timeValue = 1.5; |
| 141 | 141 | - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ |
| 142 | 142 | if ([textField isEqual:_account] || [textField isEqual:_code]) { |
| 143 | 143 | return YES; |
| 144 | - | |
| 145 | 144 | } |
| 146 | 145 | else { |
| 147 | 146 | return YES; |
| 148 | - | |
| 149 | 147 | } |
| 150 | 148 | } |
| 151 | 149 | |
| 152 | 150 | - (void)textFieldDidChange:(UITextField *)textField { |
| 153 | 151 | if (![_account.text isEqualToString:@""] && ![_code.text isEqualToString:@""]) { |
| 154 | 152 | _login.enabled = YES; |
| 155 | - | |
| 156 | 153 | } |
| 157 | 154 | else { |
| 158 | 155 | _login.enabled = NO; |
| 159 | - | |
| 160 | 156 | } |
| 161 | - | |
| 162 | 157 | } |
| 163 | 158 | |
| 164 | 159 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
| ... | ... | @@ -234,12 +229,9 @@ static const NSInteger timeValue = 1.5; |
| 234 | 229 | - (void)chooseCountryName:(NSString *)countryName countryCode:(NSString *)countryCode{ |
| 235 | 230 | [_account resignFirstResponder]; |
| 236 | 231 | [_code resignFirstResponder]; |
| 237 | - | |
| 238 | 232 | if(![_countryCode isEqualToString:countryCode]){ |
| 239 | 233 | _countryCode = countryCode; |
| 240 | - | |
| 241 | 234 | } |
| 242 | - | |
| 243 | 235 | } |
| 244 | 236 | #pragma mark - CNLiveCountDownButton DataSource |
| 245 | 237 | // 设置倒计时总秒数 |
| ... | ... | @@ -305,7 +297,7 @@ static const NSInteger timeValue = 1.5; |
| 305 | 297 | button.backgroundColor = [UIColor whiteColor]; |
| 306 | 298 | button.userInteractionEnabled = YES; |
| 307 | 299 | [button setTitle:@"" forState:UIControlStateNormal]; |
| 308 | - UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 300 | + UIImage *image2 = [self getImageWithImageName:Business?@"login_get_code_b":@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 309 | 301 | [button setImage:image2 forState:UIControlStateNormal]; |
| 310 | 302 | } |
| 311 | 303 | |
| ... | ... | @@ -333,6 +325,7 @@ static const NSInteger timeValue = 1.5; |
| 333 | 325 | btn.userInteractionEnabled = YES; |
| 334 | 326 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 335 | 327 | if(!strongSelf) return; |
| 328 | + [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | |
| 336 | 329 | // 连接IM |
| 337 | 330 | [strongSelf connectionIM:result]; |
| 338 | 331 | ... | ... |
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
| ... | ... | @@ -298,10 +298,12 @@ |
| 298 | 298 | inputPaths = ( |
| 299 | 299 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh", |
| 300 | 300 | "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveLoginModule/CNLiveLoginModule.bundle", |
| 301 | + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.bundle", | |
| 301 | 302 | ); |
| 302 | 303 | name = "[CP] Copy Pods Resources"; |
| 303 | 304 | outputPaths = ( |
| 304 | 305 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveLoginModule.bundle", |
| 306 | + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveUserAgreementManager.bundle", | |
| 305 | 307 | ); |
| 306 | 308 | runOnlyForDeploymentPostprocessing = 0; |
| 307 | 309 | shellPath = /bin/sh; |
| ... | ... | @@ -334,7 +336,6 @@ |
| 334 | 336 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 335 | 337 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 336 | 338 | "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", |
| 337 | - "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", | |
| 338 | 339 | "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", |
| 339 | 340 | "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", |
| 340 | 341 | "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", |
| ... | ... | @@ -369,7 +370,6 @@ |
| 369 | 370 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 370 | 371 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 371 | 372 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", |
| 372 | - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", | |
| 373 | 373 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", |
| 374 | 374 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework", |
| 375 | 375 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", |
| ... | ... | @@ -554,7 +554,7 @@ |
| 554 | 554 | GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; |
| 555 | 555 | INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; |
| 556 | 556 | MODULE_NAME = ExampleApp; |
| 557 | - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAddd.CNLiveLoginModule; | |
| 557 | + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; | |
| 558 | 558 | PRODUCT_NAME = "登录模块"; |
| 559 | 559 | SWIFT_VERSION = 4.0; |
| 560 | 560 | WRAPPER_EXTENSION = app; |
| ... | ... | @@ -573,7 +573,7 @@ |
| 573 | 573 | GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; |
| 574 | 574 | INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; |
| 575 | 575 | MODULE_NAME = ExampleApp; |
| 576 | - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAddd.CNLiveLoginModule; | |
| 576 | + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd; | |
| 577 | 577 | PRODUCT_NAME = "登录模块"; |
| 578 | 578 | SWIFT_VERSION = 4.0; |
| 579 | 579 | WRAPPER_EXTENSION = app; | ... | ... |
Example/CNLiveLoginModule/CNLIVEAppDelegate.m
| ... | ... | @@ -20,37 +20,13 @@ |
| 20 | 20 | { |
| 21 | 21 | // Override point for customization after application launch. |
| 22 | 22 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];//UIScreen mainScreen].bounds个人理解获取屏幕的硬件信息然后设置尺寸大小 |
| 23 | - | |
| 24 | - [CNLiveEnvironmentManager setEnvironment:CNLiveProductionAppStore]; | |
| 25 | - [CNLiveEnvironmentManager setAppType:CNLiveAppTypeBusiness]; | |
| 23 | + [CNLiveEnvironmentManager setAppType:CNLiveAppTypeBusiness environmentType:CNLiveProductionAppStore]; | |
| 26 | 24 | [CNLiveUserSystemCenter setAppId:AppId appKey:APPKey appSecret:AppSecret isTestEnvironment:TestEnvironment]; |
| 27 | 25 | if ([CNUserShareManager isLogin]) { |
| 28 | 26 | [CNLiveUserSystemCenter setUserId:CNUserShareModel.uid]; |
| 29 | 27 | } |
| 30 | 28 | [self networkParamAction]; |
| 31 | 29 | |
| 32 | - [CNUserInfoManager saveUserinfoDic:@{ | |
| 33 | - @"bigFaceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697.jpg", | |
| 34 | - @"countryCode":@"86", | |
| 35 | - @"email":@"", | |
| 36 | - @"extInfo":@"", | |
| 37 | - @"faceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697_small.jpg", | |
| 38 | - @"gender":@"m", | |
| 39 | - @"hUid":@"", | |
| 40 | - @"isNewUser":@"0", | |
| 41 | - @"location":@"北京市海淀区", | |
| 42 | - @"mobile":@"17600922519", | |
| 43 | - @"nickName":@"金帝", | |
| 44 | - @"platformId":@"769_jetj7bq525", | |
| 45 | - @"qqUid":@"", | |
| 46 | - @"renrenUid":@"", | |
| 47 | - @"sinaUid":@"", | |
| 48 | - @"token":@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj", | |
| 49 | - @"uid":@"10514405", | |
| 50 | - @"wxUid":@"" | |
| 51 | - }]; | |
| 52 | - [[NSUserDefaults standardUserDefaults] setObject:@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj" forKey:@"CNLiveAuthToken"]; | |
| 53 | - | |
| 54 | 30 | CNLiveLoginController *vc = [[CNLiveLoginController alloc] init]; |
| 55 | 31 | vc.isShowClose = YES; |
| 56 | 32 | UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; | ... | ... |
Example/Podfile
| 1 | 1 | use_frameworks! |
| 2 | 2 | source 'https://github.com/CocoaPods/Specs.git' |
| 3 | 3 | source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' |
| 4 | - | |
| 4 | +#com.cnlive.CNLiveNetAddd.CNLiveLoginModule | |
| 5 | 5 | platform :ios, '9.0' |
| 6 | 6 | |
| 7 | 7 | target 'CNLiveLoginModule_Example' do |
| ... | ... | @@ -9,13 +9,4 @@ target 'CNLiveLoginModule_Example' do |
| 9 | 9 | pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - post_install do |installer| | |
| 13 | - installer.pods_project.targets.each do |target| | |
| 14 | - target.build_configurations.each do |config| | |
| 15 | - if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0 | |
| 16 | - config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0' | |
| 17 | - end | |
| 18 | - end | |
| 19 | - end | |
| 20 | - end | |
| 21 | 12 | end | ... | ... |