Commit a195b89f78a78281034388be6137b074f2aafbdd

Authored by zhangxiaowen
1 parent 31293f79

no message

CNLiveSettingModule.podspec
... ... @@ -146,6 +146,9 @@ TODO: 网家家-设置模块.
146 146 s.dependency 'CNLiveBusinessTools'
147 147  
148 148 s.dependency 'CNLiveCommonClass'
  149 +
  150 + # 切换城市
  151 + s.dependency 'CNLiveChooseCountry'
149 152  
150 153 s.static_framework = true
151 154  
... ...
CNLiveSettingModule/Classes/Controller/CNLiveSettingController.m
... ... @@ -37,7 +37,6 @@
37 37  
38 38 @implementation CNLiveSettingController
39 39 static const NSInteger timeValue = 1.5;
40   -
41 40 #pragma mark - 加载数据
42 41 - (void)loadData {
43 42 NSArray *data = @[
... ... @@ -112,8 +111,8 @@ static const NSInteger timeValue = 1.5;
112 111 @"height":@"51",
113 112 @"lineHeight":@"1"
114 113 }
115   -
116   - ];
  114 +
  115 + ];
117 116 for(NSDictionary *dic in data){
118 117 [self.data addObject:[CNLiveSettingModel mj_objectWithKeyValues:dic]];
119 118 }
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelController.m
... ... @@ -7,7 +7,7 @@
7 7 //
8 8  
9 9 #import "CNLiveUpdateTelController.h"
10   -//#import "CNSelectCountriesViewController.h"
  10 +#import "CNLiveChooseCountryController.h"
11 11 #import "YYKit.h"
12 12 #import <Masonry/Masonry.h>
13 13 #import "QMUIKit.h"
... ... @@ -19,11 +19,7 @@
19 19 #import "CNLiveSettingNavigationBar.h"
20 20 #import "CNLiveUpdateTelView.h"
21 21  
22   -//@interface CNLiveUpdateTelController ()<UITextFieldDelegate,SelectCountriesDelegate>{
23   -
24   -@interface CNLiveUpdateTelController()<UITextFieldDelegate, CNLiveSettingNavigationBarDelegate, CNLiveUpdateTelViewDelegate>{
25   - NSString * _code;
26   -}
  22 +@interface CNLiveUpdateTelController()<UITextFieldDelegate, CNLiveSettingNavigationBarDelegate, CNLiveUpdateTelViewDelegate, ChooseCountriesDelegate>
27 23  
28 24 @property (nonatomic, strong) CNLiveSettingNavigationBar *navigationBar;
29 25 @property (nonatomic, strong) CNLiveUpdateTelView *updateTel;//背景
... ... @@ -32,6 +28,7 @@
32 28 @end
33 29  
34 30 @implementation CNLiveUpdateTelController
  31 +static const NSInteger timeValue = 1.5;
35 32  
36 33 - (void)viewWillAppear:(BOOL)animated {
37 34 [super viewWillAppear:animated];
... ... @@ -42,8 +39,6 @@
42 39 - (void)viewDidLoad {
43 40 [super viewDidLoad];
44 41 // Do any additional setup after loading the view.
45   -
46   - _code = @"86";
47 42  
48 43 self.view.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
49 44  
... ... @@ -104,20 +99,20 @@
104 99 // Dispose of any resources that can be recreated.
105 100 }
106 101  
107   -#pragma mark - SelectCountriesDelegate
108   -//- (void)selectViewController:(CNSelectCountriesViewController *)viewController countryName:(NSString *)name countryCode:(NSString *)code{
109   -// _countryName.text = name;
110   -// _countryCode.text = [NSString stringWithFormat:@"+%@",code];
111   -// _codeStr = code;
112   -// NSLog(@"%@---%@",name,code);
113   -//
114   -//}
  102 +#pragma mark - ChooseCountriesDelegate
  103 +- (void)chooseViewController:(CNLiveChooseCountryController *)controller countryName:(NSString *)name countryCode:(NSString *)code{
  104 + _updateTel.countryName.text = name;
  105 + _updateTel.countryCode.text = [NSString stringWithFormat:@"+%@",code];
  106 + _updateTel.codeNum = code;
  107 +
  108 +}
115 109  
  110 +#pragma mark - CNLiveUpdateTelViewDelegate
116 111 - (void)selectCountry:(CNLiveUpdateTelView *)view{
117   - // CNSelectCountriesViewController *vc = [[CNSelectCountriesViewController alloc]init];
118   - // vc.delegate = self;
119   - // vc.hidesBottomBarWhenPushed = YES;
120   - // [self presentViewController:vc animated:YES completion:nil];
  112 + CNLiveChooseCountryController *vc = [[CNLiveChooseCountryController alloc]init];
  113 + vc.delegate = self;
  114 + vc.hidesBottomBarWhenPushed = YES;
  115 + [self presentViewController:vc animated:YES completion:nil];
121 116 }
122 117  
123 118 - (void)bindingSuccess:(CNLiveUpdateTelView *)view{
... ... @@ -125,7 +120,7 @@
125 120 }
126 121  
127 122 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
128   - [self.updateTel.numberTF resignFirstResponder];
  123 + [self.updateTel.telTF resignFirstResponder];
129 124 }
130 125  
131 126 #pragma mark - Lazy Loading
... ... @@ -144,7 +139,7 @@
144 139 if (!_updateTel) {
145 140 _updateTel = [[CNLiveUpdateTelView alloc] init];
146 141 _updateTel.delegate = self;
147   - _updateTel.code = _code;
  142 + _updateTel.codeNum = @"86";
148 143 }
149 144 return _updateTel;
150 145 }
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.h
... ... @@ -21,13 +21,13 @@ NS_ASSUME_NONNULL_BEGIN
21 21 @property (nonatomic, strong) UILabel *countryName;
22 22 @property (nonatomic, strong) UILabel *countryCode;
23 23  
24   -@property (nonatomic, strong) UITextField *numberTF;
  24 +@property (nonatomic, strong) UITextField *telTF;
25 25 @property (nonatomic, strong) UITextField *codeTF;
26 26  
27 27 @property (nonatomic, assign) BOOL gotVerificationCode;
28 28 @property (nonatomic, assign) BOOL gotVerificationCodeIng;
29   -@property (nonatomic, copy, nullable) NSString *phoneNum;
30   -@property (nonatomic, copy) NSString *code;
  29 +
  30 +@property (nonatomic, copy) NSString *codeNum;
31 31  
32 32 @end
33 33  
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.m
... ... @@ -32,6 +32,8 @@
32 32  
33 33 @implementation CNLiveUpdateTelView
34 34 static const NSInteger margin = 15;
  35 +static const NSInteger timeValue = 1.5;
  36 +
35 37 #pragma mark - Init
36 38 - (instancetype)initWithFrame:(CGRect)frame {
37 39 self = [super initWithFrame:frame];
... ... @@ -43,8 +45,8 @@ static const NSInteger margin = 15;
43 45 }
44 46  
45 47 #pragma mark - Data
46   -- (void)setCode:(NSString *)code{
47   - _code = code;
  48 +- (void)setCodeNum:(NSString *)codeNum{
  49 + _codeNum = codeNum;
48 50 }
49 51  
50 52 #pragma mark - UI
... ... @@ -55,7 +57,7 @@ static const NSInteger margin = 15;
55 57 [self addSubview:self.countryCode];
56 58  
57 59 [self addSubview:self.numberLabel];
58   - [self addSubview:self.numberTF];
  60 + [self addSubview:self.telTF];
59 61  
60 62 [self addSubview:self.codeLabel];
61 63 [self addSubview:self.codeTF];
... ... @@ -102,7 +104,7 @@ static const NSInteger margin = 15;
102 104 make.width.mas_equalTo(100);
103 105 make.height.mas_equalTo(30);
104 106 }];
105   - [self.numberTF mas_makeConstraints:^(MASConstraintMaker *make) {
  107 + [self.telTF mas_makeConstraints:^(MASConstraintMaker *make) {
106 108 make.centerY.equalTo(self.numberLabel);
107 109 make.left.equalTo(self.numberLabel.mas_right).offset(20);
108 110 make.right.equalTo(self.verification.mas_left).offset(-10);
... ... @@ -117,7 +119,7 @@ static const NSInteger margin = 15;
117 119 [self.codeTF mas_makeConstraints:^(MASConstraintMaker *make) {
118 120 make.centerY.equalTo(self.codeLabel);
119 121 make.left.equalTo(self.codeLabel.mas_right).offset(20);
120   - make.width.equalTo(self.numberTF);
  122 + make.width.equalTo(self.telTF);
121 123 }];
122 124  
123 125 [self.bindingView mas_makeConstraints:^(MASConstraintMaker *make) {
... ... @@ -246,18 +248,18 @@ static const NSInteger margin = 15;
246 248 return _codeLabel;
247 249 }
248 250  
249   -- (UITextField *)numberTF {
250   - if (!_numberTF) {
251   - _numberTF = [[UITextField alloc] init];
252   - _numberTF.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
253   - _numberTF.font = [UIFont systemFontOfSize:14];
254   - _numberTF.placeholder = @"请输入新手机号";
255   - _numberTF.delegate = self;
256   - _numberTF.keyboardType = UIKeyboardTypeNumberPad;
257   - [_numberTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
258   - _numberTF.tag = 10001;
  251 +- (UITextField *)telTF {
  252 + if (!_telTF) {
  253 + _telTF = [[UITextField alloc] init];
  254 + _telTF.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
  255 + _telTF.font = [UIFont systemFontOfSize:14];
  256 + _telTF.placeholder = @"请输入新手机号";
  257 + _telTF.delegate = self;
  258 + _telTF.keyboardType = UIKeyboardTypeNumberPad;
  259 + [_telTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  260 + _telTF.tag = 10001;
259 261 }
260   - return _numberTF;
  262 + return _telTF;
261 263 }
262 264  
263 265 - (UITextField *)codeTF {
... ... @@ -283,7 +285,7 @@ static const NSInteger margin = 15;
283 285 _verification.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
284 286 _verification.layer.cornerRadius = 15;
285 287 _verification.layer.masksToBounds = YES;
286   - [_verification addTarget:self action:@selector(verificationCodeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  288 + [_verification addTarget:self action:@selector(verificationDidClicked:) forControlEvents:UIControlEventTouchUpInside];
287 289 }
288 290 return _verification;
289 291 }
... ... @@ -336,8 +338,8 @@ static const NSInteger margin = 15;
336 338 }
337 339 }
338 340  
339   -- (void)verificationCodeBtnAction:(UIButton *)sender {
340   - if ([NSString isEmpty:self.numberTF.text] || [self.numberTF.text isWhitespaceAndNewlines]) {
  341 +- (void)verificationDidClicked:(UIButton *)sender {
  342 + if ([NSString isEmpty:self.telTF.text] || [self.telTF.text isWhitespaceAndNewlines]) {
341 343 QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
342 344 }];
343 345 QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"请输入正确的手机号码" message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
... ... @@ -349,33 +351,34 @@ static const NSInteger margin = 15;
349 351  
350 352 [alertController showWithAnimated:YES];
351 353 }
352   - else if ([self.numberTF.text isEqualToString:CNUserShareModel.mobile]) {
353   - [QMUITips showWithText:@"您更新的手机号与旧手机号一致,请重新输入确认" inView:self hideAfterDelay:1.5];
  354 + else if ([self.telTF.text isEqualToString:CNUserShareModel.mobile]) {
  355 + [QMUITips showWithText:@"您更新的手机号与旧手机号一致,请重新输入确认" inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:timeValue];
354 356 }
355 357 else {
356 358 // 发送验证码
357   - self.phoneNum = self.numberTF.text;
  359 + [self.telTF resignFirstResponder];
  360 + [self.codeTF becomeFirstResponder];
  361 +
358 362 self.verification.userInteractionEnabled = NO;
359 363 self.verification.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
360 364 [self.verification setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1.0] forState:UIControlStateNormal];
361 365 self.gotVerificationCodeIng = YES;
362 366  
363   - [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeRegister mobile:self.numberTF.text countryCode:_code success:^(id result) {
  367 + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeRegister mobile:self.telTF.text countryCode:_codeNum success:^(id result) {
364 368  
365   - [QMUITips showWithText:@"短信发送成功" inView:self hideAfterDelay:1.5];
  369 + [QMUITips showSucceed:@"短信发送成功" inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:timeValue];
366 370 self.gotVerificationCode = YES;
367 371 [self countDown];
368 372  
369 373 } failure:^(NSDictionary *errorDic) {
370   -
371 374 NSString *errMsg;
372 375 if ([[NSString stringWithFormat:@"%@",errorDic[@"errorCode"]] isEqualToString:@"408"]) {
373 376 errMsg = @"请填写正确的手机号";
374 377 } else {
375 378 errMsg = errorDic[@"errorMessage"];
376 379 }
377   - [QMUITips showWithText:errMsg inView:self hideAfterDelay:1.5];
378   - self.phoneNum = nil;
  380 + [QMUITips showError:errMsg inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:timeValue];
  381 +
379 382 self.gotVerificationCode = NO;
380 383 self.verification.userInteractionEnabled = YES;
381 384 self.verification.backgroundColor = [UIColor colorWithRed:0/255.0 green:194/255.0 blue:0/255.0 alpha:1.0];
... ... @@ -391,8 +394,8 @@ static const NSInteger margin = 15;
391 394 if (self.gotVerificationCode) {
392 395 if (self.codeTF.text.length == 6) {
393 396 [QMUITips showLoadingInView:self];
394   - [CNLiveUserSystemCenter updateMobileWithUid:CNUserShareModel.uid mobile:self.phoneNum countryCode:_code verificationCode:self.codeTF.text success:^(id result) {
395   - CNUserShareModel.mobile = self.phoneNum;
  397 + [CNLiveUserSystemCenter updateMobileWithUid:CNUserShareModel.uid mobile:self.telTF.text countryCode:_codeNum verificationCode:self.codeTF.text success:^(id result) {
  398 + CNUserShareModel.mobile = self.telTF.text;
396 399 [CNUserInfoModel setLocalUserInfo:self.countryName.text withKey:@"countryname"];
397 400 [CNUserInfoModel setLocalUserInfo:self.countryCode.text withKey:@"countrycode"];
398 401 [QMUITips hideAllToastInView:self animated:YES];
... ... @@ -402,7 +405,7 @@ static const NSInteger margin = 15;
402 405  
403 406 } failure:^(NSDictionary *errorDic) {
404 407 [QMUITips hideAllToastInView:self animated:YES];
405   - [QMUITips showError:errorDic[@"errorMessage"] inView:self hideAfterDelay:1.5];
  408 + [QMUITips showError:errorDic[@"errorMessage"] inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:timeValue];
406 409  
407 410 }];
408 411  
... ... @@ -421,7 +424,7 @@ static const NSInteger margin = 15;
421 424  
422 425 } else {
423 426 NSString *alertText = @"请先获取验证码";
424   - if (self.numberTF.text.length != 11) {
  427 + if (self.telTF.text.length != 11) {
425 428 alertText = @"请先输入正确的手机号码";
426 429 } else {
427 430 alertText = @"请先获取验证码";
... ... @@ -443,7 +446,7 @@ static const NSInteger margin = 15;
443 446 }
444 447  
445 448 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
446   - [self.numberTF resignFirstResponder];
  449 + [self.telTF resignFirstResponder];
447 450 }
448 451  
449 452 #pragma mark - 倒计时
... ... @@ -459,7 +462,7 @@ static const NSInteger margin = 15;
459 462 dispatch_source_set_event_handler(timer, ^{
460 463 dispatch_async(dispatch_get_main_queue(), ^{
461 464 if (second == 0) {
462   - [self setupTextFieldUI:self.numberTF];
  465 + [self setupTextFieldUI:self.telTF];
463 466 self.gotVerificationCodeIng = NO;
464 467 [self.verification setTitle:[NSString stringWithFormat:@"获取验证码"] forState:UIControlStateNormal];
465 468 second = TIMECOUNT;
... ...
Example/CNLiveSettingModule.xcodeproj/project.pbxproj
... ... @@ -352,6 +352,7 @@
352 352 "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework",
353 353 "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework",
354 354 "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework",
  355 + "${BUILT_PRODUCTS_DIR}/CNLiveChooseCountry/CNLiveChooseCountry.framework",
355 356 "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework",
356 357 "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
357 358 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
... ... @@ -378,6 +379,7 @@
378 379 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework",
379 380 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework",
380 381 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework",
  382 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveChooseCountry.framework",
381 383 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework",
382 384 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
383 385 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
... ...
Example/CNLiveSettingModule/CNLIVEAppDelegate.m
... ... @@ -9,6 +9,7 @@
9 9 #import "CNLIVEAppDelegate.h"
10 10 #import "CNLiveSettingController.h"
11 11 #import "CNLiveEnvironment.h"
  12 +#import "CNUserInfoManager.h"
12 13  
13 14 @implementation CNLIVEAppDelegate
14 15  
... ... @@ -21,6 +22,26 @@
21 22 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
22 23 self.window.rootViewController = nav;//设置根视图控制器
23 24 [self.window makeKeyAndVisible];
  25 + [CNUserInfoManager saveUserinfoDic:@{
  26 + @"bigFaceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697.jpg",
  27 + @"countryCode":@"86",
  28 + @"email":@"",
  29 + @"extInfo":@"",
  30 + @"faceUrl":@"http://yweb0.cnliveimg.com/images/headImg/2019/1030/1572439148697_small.jpg",
  31 + @"gender":@"m",
  32 + @"hUid":@"",
  33 + @"isNewUser":@"0",
  34 + @"location":@"北京市海淀区",
  35 + @"mobile":@"17600922519",
  36 + @"nickName":@"金帝",
  37 + @"platformId":@"769_jetj7bq525",
  38 + @"qqUid":@"",
  39 + @"renrenUid":@"",
  40 + @"sinaUid":@"",
  41 + @"token":@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj",
  42 + @"uid":@"10514405",
  43 + @"wxUid":@""
  44 + }];
24 45 return YES;
25 46 }
26 47  
... ...