Commit 27d8543147f2bd831f8e746c60473afc15863cb7

Authored by iOS-Xiaowen
1 parent b986563f

no message

CNLiveLoginModule.podspec
@@ -70,7 +70,7 @@ TODO: 网家家-登录模块. @@ -70,7 +70,7 @@ TODO: 网家家-登录模块.
70 'CNLiveLoginModule' => ['CNLiveLoginModule/Assets/CNLiveLoginModule.xcassets'] 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 # s.frameworks = 'UIKit', 'MapKit' 74 # s.frameworks = 'UIKit', 'MapKit'
75 75
76 # pod 76 # pod
CNLiveLoginModule/Classes/Controller/CNLiveLoginController.m
@@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@
94 94
95 #pragma mark - CNLiveLoginViewDelegate 95 #pragma mark - CNLiveLoginViewDelegate
96 - (void)loginSuccess:(CNLiveLoginView *)view isNewUser:(BOOL)isNewUser result:(id _Nonnull)result{ 96 - (void)loginSuccess:(CNLiveLoginView *)view isNewUser:(BOOL)isNewUser result:(id _Nonnull)result{
97 - if (isNewUser) { 97 + if (!isNewUser) {
98 // 新用户 -> 设置昵称和头像 98 // 新用户 -> 设置昵称和头像
99 CNLiveCompleteInfoController *vc = [[CNLiveCompleteInfoController alloc]init]; 99 CNLiveCompleteInfoController *vc = [[CNLiveCompleteInfoController alloc]init];
100 vc.hidesBottomBarWhenPushed = YES; 100 vc.hidesBottomBarWhenPushed = YES;
CNLiveLoginModule/Classes/Model/CNLiveLoginRequest.m
@@ -84,9 +84,7 @@ static const NSInteger timeValue = 1.5; @@ -84,9 +84,7 @@ static const NSInteger timeValue = 1.5;
84 failed(31012, @"获取token失败"); 84 failed(31012, @"获取token失败");
85 } 85 }
86 } 86 }
87 -  
88 } 87 }
89 -  
90 }else{ 88 }else{
91 if (failed) failed(31012, @"获取token失败"); 89 if (failed) failed(31012, @"获取token失败");
92 } 90 }
@@ -97,7 +95,6 @@ static const NSInteger timeValue = 1.5; @@ -97,7 +95,6 @@ static const NSInteger timeValue = 1.5;
97 // 登录IM 95 // 登录IM
98 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{ 96 - (void)loginTIM:(NSString *)uid success:(void (^)(void))success failed:(void (^)(int code, NSString * msg))failed{
99 [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow]; 97 [QMUITips showLoading:@"正在连接服务器..." inView:XWKeyWindow];
100 -  
101 // 1.获取token 98 // 1.获取token
102 [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) { 99 [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) {
103 100
CNLiveLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m
@@ -9,8 +9,13 @@ @@ -9,8 +9,13 @@
9 #import "CNLiveBindingTelView.h" 9 #import "CNLiveBindingTelView.h"
10 #import "YYKit.h" 10 #import "YYKit.h"
11 #import "QMUIKit.h" 11 #import "QMUIKit.h"
  12 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  13 +
12 #import "CNLiveCategory.h" 14 #import "CNLiveCategory.h"
13 #import "CNLiveEnvironment.h" 15 #import "CNLiveEnvironment.h"
  16 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
  17 +#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h>
  18 +#import "CNUserInfoManager.h"
14 19
15 #import "CNLiveLoginCountryView.h" 20 #import "CNLiveLoginCountryView.h"
16 #import "CNLiveLoginTextField.h" 21 #import "CNLiveLoginTextField.h"
@@ -31,6 +36,7 @@ @@ -31,6 +36,7 @@
31 @end 36 @end
32 37
33 @implementation CNLiveBindingTelView 38 @implementation CNLiveBindingTelView
  39 +#define XWKeyWindow [UIApplication sharedApplication].keyWindow
34 static NSInteger const rowHeight = 40; 40 static NSInteger const rowHeight = 40;
35 static NSInteger const space = 40; 41 static NSInteger const space = 40;
36 static const NSInteger timeValue = 1.5; 42 static const NSInteger timeValue = 1.5;
@@ -209,33 +215,42 @@ static const NSInteger timeValue = 1.5; @@ -209,33 +215,42 @@ static const NSInteger timeValue = 1.5;
209 - (void)countDownButtonDidClick:(CNLiveCountDownButton *)button { 215 - (void)countDownButtonDidClick:(CNLiveCountDownButton *)button {
210 //获取验证码 216 //获取验证码
211 if ([_account.text isEqualToString:@""]) { 217 if ([_account.text isEqualToString:@""]) {
212 - [QMUITips showError:@"请输入手机号" inView:self.superview hideAfterDelay:timeValue]; 218 + [QMUITips showWithText:@"请输入手机号"];
213 return; 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 button.userInteractionEnabled = NO; 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 // button.backgroundColor = HexColor(0xdedede); 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,44 +270,92 @@ static const NSInteger timeValue = 1.5;
255 button.backgroundColor = [UIColor whiteColor]; 270 button.backgroundColor = [UIColor whiteColor];
256 button.userInteractionEnabled = YES; 271 button.userInteractionEnabled = YES;
257 [button setTitle:@"" forState:UIControlStateNormal]; 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 [button setImage:image2 forState:UIControlStateNormal]; 274 [button setImage:image2 forState:UIControlStateNormal];
260 } 275 }
261 276
262 #pragma mark - Action 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 return; 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 if (self.delegate && [self.delegate respondsToSelector:@selector(bindingSuccess:type:)]) { 356 if (self.delegate && [self.delegate respondsToSelector:@selector(bindingSuccess:type:)]) {
287 [self.delegate bindingSuccess:self type:self.type]; 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 @end 361 @end
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
@@ -89,7 +89,8 @@ static const NSInteger timeValue = 1.5; @@ -89,7 +89,8 @@ static const NSInteger timeValue = 1.5;
89 [next setTitle:@"下一步" forState:UIControlStateNormal]; 89 [next setTitle:@"下一步" forState:UIControlStateNormal];
90 [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 90 [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
91 next.titleLabel.font = [UIFont systemFontOfSize:15.0]; 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 next.layer.cornerRadius = 20; 94 next.layer.cornerRadius = 20;
94 next.layer.masksToBounds = YES; 95 next.layer.masksToBounds = YES;
95 next.adjustsImageWhenHighlighted = NO; 96 next.adjustsImageWhenHighlighted = NO;
@@ -216,8 +217,9 @@ static const NSInteger timeValue = 1.5; @@ -216,8 +217,9 @@ static const NSInteger timeValue = 1.5;
216 [alertController addAction:cancel]; 217 [alertController addAction:cancel];
217 218
218 NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; 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 NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; 224 NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
223 cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; 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,65 +245,85 @@ static const NSInteger timeValue = 1.5;
243 } 245 }
244 self.next.userInteractionEnabled = NO; 246 self.next.userInteractionEnabled = NO;
245 [self.superview endEditing:YES]; 247 [self.superview endEditing:YES];
246 - [self modifyIcon]; 248 + [self modifyNickName];
247 } 249 }
248 250
249 -// 修改头像  
250 -- (void)modifyIcon { 251 +// 修改名字
  252 +- (void)modifyNickName {
251 [QMUITips showLoading:@"修改中" inView:self.superview]; 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 }else{ 265 }else{
260 - faceUrl = deFaceUrl; 266 + [strongSelf modifyIcon];
261 } 267 }
262 - CNUserShareModel.faceUrl = faceUrl;  
263 - [self modifyNickName];  
264 - 268 +
265 } failure:^(NSDictionary *errorDic) { 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 [QMUITips showLoading:@"修改中" inView:self.superview]; 281 [QMUITips showLoading:@"修改中" inView:self.superview];
275 __weak typeof(self) weakSelf = self; 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 __strong typeof(weakSelf) strongSelf = weakSelf; 284 __strong typeof(weakSelf) strongSelf = weakSelf;
278 if(!strongSelf) return; 285 if(!strongSelf) return;
279 strongSelf.next.userInteractionEnabled = YES; 286 strongSelf.next.userInteractionEnabled = YES;
280 - CNUserShareModel.nickname = strongSelf.nickname.text;  
281 [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; 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 } failure:^(NSDictionary *errorDic) { 299 } failure:^(NSDictionary *errorDic) {
289 __strong typeof(weakSelf) strongSelf = weakSelf; 300 __strong typeof(weakSelf) strongSelf = weakSelf;
290 if(!strongSelf) return; 301 if(!strongSelf) return;
291 strongSelf.next.userInteractionEnabled = YES; 302 strongSelf.next.userInteractionEnabled = YES;
292 [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; 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 // 连接IM 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 __weak typeof(self) weakSelf = self; 319 __weak typeof(self) weakSelf = self;
301 [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{ 320 [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
302 __strong typeof(weakSelf) strongSelf = weakSelf; 321 __strong typeof(weakSelf) strongSelf = weakSelf;
303 if(!strongSelf) return; 322 if(!strongSelf) return;
304 // 进入tabbar 323 // 进入tabbar
  324 + if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(loginSuccess:result:)]) {
  325 + [strongSelf.delegate loginSuccess:strongSelf result:result];
  326 + }
305 327
306 } failed:^(int code, NSString * _Nonnull msg) { 328 } failed:^(int code, NSString * _Nonnull msg) {
307 __strong typeof(weakSelf) strongSelf = weakSelf; 329 __strong typeof(weakSelf) strongSelf = weakSelf;
@@ -310,7 +332,7 @@ static const NSInteger timeValue = 1.5; @@ -310,7 +332,7 @@ static const NSInteger timeValue = 1.5;
310 [QMUITips showError:msg inView:strongSelf.superview hideAfterDelay:timeValue]; 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,24 +141,19 @@ static const NSInteger timeValue = 1.5;
141 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ 141 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
142 if ([textField isEqual:_account] || [textField isEqual:_code]) { 142 if ([textField isEqual:_account] || [textField isEqual:_code]) {
143 return YES; 143 return YES;
144 -  
145 } 144 }
146 else { 145 else {
147 return YES; 146 return YES;
148 -  
149 } 147 }
150 } 148 }
151 149
152 - (void)textFieldDidChange:(UITextField *)textField { 150 - (void)textFieldDidChange:(UITextField *)textField {
153 if (![_account.text isEqualToString:@""] && ![_code.text isEqualToString:@""]) { 151 if (![_account.text isEqualToString:@""] && ![_code.text isEqualToString:@""]) {
154 _login.enabled = YES; 152 _login.enabled = YES;
155 -  
156 } 153 }
157 else { 154 else {
158 _login.enabled = NO; 155 _login.enabled = NO;
159 -  
160 } 156 }
161 -  
162 } 157 }
163 158
164 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 159 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
@@ -234,12 +229,9 @@ static const NSInteger timeValue = 1.5; @@ -234,12 +229,9 @@ static const NSInteger timeValue = 1.5;
234 - (void)chooseCountryName:(NSString *)countryName countryCode:(NSString *)countryCode{ 229 - (void)chooseCountryName:(NSString *)countryName countryCode:(NSString *)countryCode{
235 [_account resignFirstResponder]; 230 [_account resignFirstResponder];
236 [_code resignFirstResponder]; 231 [_code resignFirstResponder];
237 -  
238 if(![_countryCode isEqualToString:countryCode]){ 232 if(![_countryCode isEqualToString:countryCode]){
239 _countryCode = countryCode; 233 _countryCode = countryCode;
240 -  
241 } 234 }
242 -  
243 } 235 }
244 #pragma mark - CNLiveCountDownButton DataSource 236 #pragma mark - CNLiveCountDownButton DataSource
245 // 设置倒计时总秒数 237 // 设置倒计时总秒数
@@ -305,7 +297,7 @@ static const NSInteger timeValue = 1.5; @@ -305,7 +297,7 @@ static const NSInteger timeValue = 1.5;
305 button.backgroundColor = [UIColor whiteColor]; 297 button.backgroundColor = [UIColor whiteColor];
306 button.userInteractionEnabled = YES; 298 button.userInteractionEnabled = YES;
307 [button setTitle:@"" forState:UIControlStateNormal]; 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 [button setImage:image2 forState:UIControlStateNormal]; 301 [button setImage:image2 forState:UIControlStateNormal];
310 } 302 }
311 303
@@ -333,6 +325,7 @@ static const NSInteger timeValue = 1.5; @@ -333,6 +325,7 @@ static const NSInteger timeValue = 1.5;
333 btn.userInteractionEnabled = YES; 325 btn.userInteractionEnabled = YES;
334 __strong typeof(weakSelf) strongSelf = weakSelf; 326 __strong typeof(weakSelf) strongSelf = weakSelf;
335 if(!strongSelf) return; 327 if(!strongSelf) return;
  328 + [QMUITips hideAllToastInView:XWKeyWindow animated:YES];
336 // 连接IM 329 // 连接IM
337 [strongSelf connectionIM:result]; 330 [strongSelf connectionIM:result];
338 331
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
@@ -298,10 +298,12 @@ @@ -298,10 +298,12 @@
298 inputPaths = ( 298 inputPaths = (
299 "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh", 299 "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-resources.sh",
300 "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveLoginModule/CNLiveLoginModule.bundle", 300 "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveLoginModule/CNLiveLoginModule.bundle",
  301 + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.bundle",
301 ); 302 );
302 name = "[CP] Copy Pods Resources"; 303 name = "[CP] Copy Pods Resources";
303 outputPaths = ( 304 outputPaths = (
304 "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveLoginModule.bundle", 305 "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveLoginModule.bundle",
  306 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveUserAgreementManager.bundle",
305 ); 307 );
306 runOnlyForDeploymentPostprocessing = 0; 308 runOnlyForDeploymentPostprocessing = 0;
307 shellPath = /bin/sh; 309 shellPath = /bin/sh;
@@ -334,7 +336,6 @@ @@ -334,7 +336,6 @@
334 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", 336 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
335 "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", 337 "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework",
336 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", 338 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework",
337 - "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework",  
338 "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", 339 "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework",
339 "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", 340 "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
340 "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", 341 "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework",
@@ -369,7 +370,6 @@ @@ -369,7 +370,6 @@
369 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", 370 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
370 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", 371 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework",
371 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", 372 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework",
372 - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework",  
373 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", 373 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework",
374 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework", 374 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
375 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", 375 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework",
@@ -554,7 +554,7 @@ @@ -554,7 +554,7 @@
554 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; 554 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch";
555 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; 555 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist";
556 MODULE_NAME = ExampleApp; 556 MODULE_NAME = ExampleApp;
557 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAddd.CNLiveLoginModule; 557 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd;
558 PRODUCT_NAME = "登录模块"; 558 PRODUCT_NAME = "登录模块";
559 SWIFT_VERSION = 4.0; 559 SWIFT_VERSION = 4.0;
560 WRAPPER_EXTENSION = app; 560 WRAPPER_EXTENSION = app;
@@ -573,7 +573,7 @@ @@ -573,7 +573,7 @@
573 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; 573 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch";
574 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; 574 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist";
575 MODULE_NAME = ExampleApp; 575 MODULE_NAME = ExampleApp;
576 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAddd.CNLiveLoginModule; 576 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd;
577 PRODUCT_NAME = "登录模块"; 577 PRODUCT_NAME = "登录模块";
578 SWIFT_VERSION = 4.0; 578 SWIFT_VERSION = 4.0;
579 WRAPPER_EXTENSION = app; 579 WRAPPER_EXTENSION = app;
Example/CNLiveLoginModule/CNLIVEAppDelegate.m
@@ -20,37 +20,13 @@ @@ -20,37 +20,13 @@
20 { 20 {
21 // Override point for customization after application launch. 21 // Override point for customization after application launch.
22 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];//UIScreen mainScreen].bounds个人理解获取屏幕的硬件信息然后设置尺寸大小 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 [CNLiveUserSystemCenter setAppId:AppId appKey:APPKey appSecret:AppSecret isTestEnvironment:TestEnvironment]; 24 [CNLiveUserSystemCenter setAppId:AppId appKey:APPKey appSecret:AppSecret isTestEnvironment:TestEnvironment];
27 if ([CNUserShareManager isLogin]) { 25 if ([CNUserShareManager isLogin]) {
28 [CNLiveUserSystemCenter setUserId:CNUserShareModel.uid]; 26 [CNLiveUserSystemCenter setUserId:CNUserShareModel.uid];
29 } 27 }
30 [self networkParamAction]; 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 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init]; 30 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init];
55 vc.isShowClose = YES; 31 vc.isShowClose = YES;
56 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; 32 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
Example/Podfile
1 use_frameworks! 1 use_frameworks!
2 source 'https://github.com/CocoaPods/Specs.git' 2 source 'https://github.com/CocoaPods/Specs.git'
3 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' 3 source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
4 - 4 +#com.cnlive.CNLiveNetAddd.CNLiveLoginModule
5 platform :ios, '9.0' 5 platform :ios, '9.0'
6 6
7 target 'CNLiveLoginModule_Example' do 7 target 'CNLiveLoginModule_Example' do
@@ -9,13 +9,4 @@ target &#39;CNLiveLoginModule_Example&#39; do @@ -9,13 +9,4 @@ target &#39;CNLiveLoginModule_Example&#39; do
9 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} 9 pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
10 end 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 end 12 end