Commit 053874a426ef0cb3dff8571efb5ccf70c99a6272

Authored by zhangxiaowen
1 parent d9415ff5

no message

CNLiveSettingModule.podspec
... ... @@ -111,6 +111,7 @@ TODO: 网家家-设置模块.
111 111 # s.dependency 'AFNetworking', '~> 2.3'
112 112  
113 113 # pod
  114 + s.dependency 'CNLiveSDKs/CNLiveUserSystemSDK', '~> 0.3.1.3' #GitHub所以指定版本号
114 115 s.dependency 'CNLiveTripartiteManagement/QMUIKit'
115 116 s.dependency 'CNLiveTripartiteManagement/SDWebImage'
116 117 s.dependency 'CNLiveTripartiteManagement/Masonry'
... ... @@ -146,4 +147,6 @@ TODO: 网家家-设置模块.
146 147  
147 148 s.dependency 'CNLiveCommonClass'
148 149  
  150 + s.static_framework = true
  151 +
149 152 end
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelController.m
... ... @@ -12,6 +12,7 @@
12 12 #import <Masonry/Masonry.h>
13 13 #import "QMUIKit.h"
14 14  
  15 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
15 16 #import "CNUserInfoManager.h"
16 17 #import "NSString+CNLiveExtension.h"
17 18  
... ... @@ -20,13 +21,13 @@
20 21  
21 22 //@interface CNLiveUpdateTelController ()<UITextFieldDelegate,SelectCountriesDelegate>{
22 23  
23   -@interface CNLiveUpdateTelController()<UITextFieldDelegate, CNLiveSettingNavigationBarDelegate>{
  24 +@interface CNLiveUpdateTelController()<UITextFieldDelegate, CNLiveSettingNavigationBarDelegate, CNLiveUpdateTelViewDelegate>{
24 25 NSString * _code;
25 26 }
26 27  
27 28 @property (nonatomic, strong) CNLiveSettingNavigationBar *navigationBar;
28 29 @property (nonatomic, strong) CNLiveUpdateTelView *updateTelView;//背景
29   -@property (nonatomic, strong) UIButton *changeBtn;//改变按钮
  30 +@property (nonatomic, strong) UIButton *binding;//改变按钮
30 31 @property (nonatomic, strong) YYLabel *connectionLab;
31 32  
32 33 @end
... ... @@ -83,7 +84,7 @@
83 84 - (void)createSubViews{
84 85 [self.view addSubview:self.navigationBar];
85 86 [self.view addSubview:self.updateTelView];
86   - [self.view addSubview:self.changeBtn];
  87 + [self.view addSubview:self.binding];
87 88 [self.view addSubview:self.connectionLab];
88 89 }
89 90  
... ... @@ -93,7 +94,7 @@
93 94 make.top.equalTo(self.view).offset(NavigationContentTop+1);
94 95 make.height.mas_equalTo(150+10);
95 96 }];
96   - [self.changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  97 + [self.binding mas_makeConstraints:^(MASConstraintMaker *make) {
97 98 make.top.equalTo(self.updateTelView.mas_bottom).offset(16);
98 99 make.left.equalTo(self.view).offset(60);
99 100 make.right.equalTo(self.view).offset(-60);
... ... @@ -112,23 +113,22 @@
112 113 }
113 114  
114 115 #pragma mark - Action
115   -- (void)compleBtnAction:(UIButton *)sender {
  116 +- (void)bindingDidClicked:(UIButton *)sender {
116 117 if (self.updateTelView.gotVerificationCode) {
117 118 if (self.updateTelView.codeTF.text.length == 6) {
118 119 [QMUITips showLoadingInView:self.view];
119   -// [CNLiveUserSystemCenter updateMobileWithUid:CNUserShareModel.uid mobile:self.phoneNum countryCode:_codeStr verificationCode:self.codeTF.text success:^(id result) {
120   -// CNUserShareModel.mobile = self.phoneNum;
121   -// [CNUserInfoModel setLocalUserInfo:_countryName.text withKey:@"countryname"];
122   -// [CNUserInfoModel setLocalUserInfo:_countryCode.text withKey:@"countrycode"];
123   -// [QMUITips hideAllToastInView:self.view animated:YES];
124   -// [[AppDelegate sharedAppDelegate] popViewController];
125   -//
126   -// } failure:^(NSDictionary *errorDic) {
127   -//
128   -// [QMUITips hideAllToastInView:self.view animated:YES];
129   -// [QMUITips showError:errorDic[@"errorMessage"] inView:self.view hideAfterDelay:1.5];
130   -//
131   -// }];
  120 + [CNLiveUserSystemCenter updateMobileWithUid:CNUserShareModel.uid mobile:self.updateTelView.phoneNum countryCode:_code verificationCode:self.updateTelView.codeTF.text success:^(id result) {
  121 + CNUserShareModel.mobile = self.updateTelView.phoneNum;
  122 + [CNUserInfoModel setLocalUserInfo:self.updateTelView.countryName.text withKey:@"countryname"];
  123 + [CNUserInfoModel setLocalUserInfo:self.updateTelView.countryCode.text withKey:@"countrycode"];
  124 + [QMUITips hideAllToastInView:self.view animated:YES];
  125 + [self.navigationController popViewControllerAnimated:YES];
  126 +
  127 + } failure:^(NSDictionary *errorDic) {
  128 + [QMUITips hideAllToastInView:self.view animated:YES];
  129 + [QMUITips showError:errorDic[@"errorMessage"] inView:self.view hideAfterDelay:1.5];
  130 +
  131 + }];
132 132  
133 133 } else {
134 134 QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
... ... @@ -179,6 +179,13 @@
179 179 //
180 180 //}
181 181  
  182 +- (void)selectCountry:(CNLiveUpdateTelView *)view{
  183 + // CNSelectCountriesViewController *vc = [[CNSelectCountriesViewController alloc]init];
  184 + // vc.delegate = self;
  185 + // vc.hidesBottomBarWhenPushed = YES;
  186 + // [self presentViewController:vc animated:YES completion:nil];
  187 +}
  188 +
182 189 #pragma mark - Lazy Loading
183 190 - (CNLiveSettingNavigationBar *)navigationBar {
184 191 if (!_navigationBar) {
... ... @@ -195,30 +202,24 @@
195 202 if (!_updateTelView) {
196 203 _updateTelView = [[CNLiveUpdateTelView alloc] init];
197 204 _updateTelView.backgroundColor = [UIColor whiteColor];
  205 + _updateTelView.delegate = self;
  206 + _updateTelView.code = _code;
198 207 }
199 208 return _updateTelView;
200 209 }
201 210  
202   -- (void)countryTap:(UITapGestureRecognizer *)tap{
203   -// CNSelectCountriesViewController *vc = [[CNSelectCountriesViewController alloc]init];
204   -// vc.delegate = self;
205   -// vc.hidesBottomBarWhenPushed = YES;
206   -// [self presentViewController:vc animated:YES completion:nil];
207   -
208   -}
209   -
210   -- (UIButton *)changeBtn{
211   - if (!_changeBtn) {
212   - _changeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
213   - [_changeBtn setTitle:@"验证后绑定新手机号" forState:UIControlStateNormal];
214   - [_changeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
215   - _changeBtn.titleLabel.font = [UIFont systemFontOfSize:15];
216   - _changeBtn.backgroundColor = [UIColor colorWithRed:0/255.0 green:194/255.0 blue:0/255.0 alpha:1.0];
217   - _changeBtn.layer.cornerRadius = 45/2.0;
218   - _changeBtn.layer.masksToBounds = YES;
219   - [_changeBtn addTarget:self action:@selector(compleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  211 +- (UIButton *)binding{
  212 + if (!_binding) {
  213 + _binding = [UIButton buttonWithType:UIButtonTypeCustom];
  214 + [_binding setTitle:@"验证后绑定新手机号" forState:UIControlStateNormal];
  215 + [_binding setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  216 + _binding.titleLabel.font = [UIFont systemFontOfSize:15];
  217 + _binding.backgroundColor = [UIColor colorWithRed:0/255.0 green:194/255.0 blue:0/255.0 alpha:1.0];
  218 + _binding.layer.cornerRadius = 45/2.0;
  219 + _binding.layer.masksToBounds = YES;
  220 + [_binding addTarget:self action:@selector(bindingDidClicked:) forControlEvents:UIControlEventTouchUpInside];
220 221 }
221   - return _changeBtn;
  222 + return _binding;
222 223 }
223 224  
224 225 - (YYLabel *)connectionLab {
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.h
... ... @@ -11,17 +11,21 @@
11 11 NS_ASSUME_NONNULL_BEGIN
12 12 @class CNLiveUpdateTelView;
13 13 @protocol CNLiveUpdateTelViewDelegate <NSObject>
14   -- (void)clickedCancellation:(CNLiveUpdateTelView *)view;
  14 +- (void)selectCountry:(CNLiveUpdateTelView *)view;
15 15  
16 16 @end
17 17 @interface CNLiveUpdateTelView : UIView
18 18 @property (nonatomic, weak) id<CNLiveUpdateTelViewDelegate> delegate;
19   -@property (nonatomic, strong) UITextField *numberTF;//手机号tf
20   -@property (nonatomic, strong) UITextField *codeTF;//验证码tf
  19 +
  20 +@property (nonatomic, strong) UILabel *countryName;
  21 +@property (nonatomic, strong) UILabel *countryCode;
  22 +@property (nonatomic, strong) UITextField *numberTF;
  23 +@property (nonatomic, strong) UITextField *codeTF;
21 24  
22 25 @property (nonatomic, assign) BOOL gotVerificationCode;
23 26 @property (nonatomic, assign) BOOL gotVerificationCodeIng;
24 27 @property (nonatomic, copy) NSString *phoneNum;
  28 +@property (nonatomic, copy) NSString *code;
25 29  
26 30 @end
27 31  
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.m
... ... @@ -11,22 +11,18 @@
11 11 #import <Masonry/Masonry.h>
12 12 #import "QMUIKit.h"
13 13  
  14 +#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h>
14 15 #import "NSString+CNLiveExtension.h"
15 16 #import "CNUserInfoManager.h"
16 17  
17 18 #define TIMECOUNT 60;
18 19  
19 20 @interface CNLiveUpdateTelView()<UITextFieldDelegate>
20   -@property (nonatomic, strong) UILabel *countryName;//国家
21   -@property (nonatomic, strong) UILabel *countryCode;
  21 +
22 22 @property (nonatomic, strong) UILabel *interval;
23 23 @property (nonatomic, strong) UIImageView *countryImg;
24   -
25 24 @property (nonatomic, strong) UILabel *numberLabel;//手机号
26   -//@property (nonatomic, strong) UITextField *numberTF;//手机号tf
27   -
28 25 @property (nonatomic, strong) UILabel *codeLabel;//验证码
29   -//@property (nonatomic, strong) UITextField *codeTF;//验证码tf
30 26 @property (nonatomic, strong) UIButton *verificationCodeBtn;//验证码按钮
31 27  
32 28 @end
... ... @@ -203,12 +199,11 @@ static const NSInteger margin = 15;
203 199 }
204 200 return _countryCode;
205 201 }
  202 +
206 203 - (void)countryTap:(UITapGestureRecognizer *)tap{
207   -// CNSelectCountriesViewController *vc = [[CNSelectCountriesViewController alloc]init];
208   -// vc.delegate = self;
209   -// vc.hidesBottomBarWhenPushed = YES;
210   -// [self presentViewController:vc animated:YES completion:nil];
211   -
  204 + if (self.delegate && [self.delegate respondsToSelector:@selector(selectCountry:)]) {
  205 + [self.delegate selectCountry:self];
  206 + }
212 207 }
213 208  
214 209 - (UILabel *)numberLabel {
... ... @@ -290,14 +285,12 @@ static const NSInteger margin = 15;
290 285 return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
291 286  
292 287 }
293   -
  288 +- (void)setCode:(NSString *)code{
  289 + _code = code;
  290 +}
294 291 #pragma mark - Action
295 292 - (void)verificationCodeBtnAction:(UIButton *)sender {
296 293 if ([NSString isEmpty:self.numberTF.text] || [self.numberTF.text isWhitespaceAndNewlines]) {
297   -// UIAlertController *con = [UIAlertController alertControllerWithTitle:@"提示" message:@"请输入正确的手机号码" preferredStyle:1];
298   -// UIAlertAction *action = [UIAlertAction actionWithTitle:@"我知道了" style:1 handler:nil];
299   -// [con addAction:action];
300   -// [self presentViewController:con animated:YES completion:nil];
301 294 QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
302 295 }];
303 296 QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"请输入正确的手机号码" message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
... ... @@ -320,29 +313,29 @@ static const NSInteger margin = 15;
320 313 [self.verificationCodeBtn setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1.0] forState:UIControlStateNormal];
321 314 self.gotVerificationCodeIng = YES;
322 315  
323   -// [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeRegister mobile:self.numberTF.text countryCode:_codeStr success:^(id result) {
324   -//
325   -// [QMUITips showWithText:@"短信发送成功" inView:self.view hideAfterDelay:1.5];
326   -// self.gotVerificationCode = YES;
327   -// [self countDown];
328   -//
329   -// } failure:^(NSDictionary *errorDic) {
330   -//
331   -// NSString *errMsg;
332   -// if ([[NSString stringWithFormat:@"%@",errorDic[@"errorCode"]] isEqualToString:@"408"]) {
333   -// errMsg = @"请填写正确的手机号";
334   -// } else {
335   -// errMsg = errorDic[@"errorMessage"];
336   -// }
337   -// [QMUITips showWithText:errMsg inView:self.view hideAfterDelay:1.5];
338   -// self.phoneNum = nil;
339   -// self.gotVerificationCode = NO;
340   -// self.verificationCodeBtn.userInteractionEnabled = YES;
341   -// self.verificationCodeBtn.backgroundColor = KGreen194Color;
342   -// [self.verificationCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
343   -// self.gotVerificationCodeIng = NO;
344   -//
345   -// }];
  316 + [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeRegister mobile:self.numberTF.text countryCode:_code success:^(id result) {
  317 +
  318 + [QMUITips showWithText:@"短信发送成功" inView:self hideAfterDelay:1.5];
  319 + self.gotVerificationCode = YES;
  320 + [self countDown];
  321 +
  322 + } failure:^(NSDictionary *errorDic) {
  323 +
  324 + NSString *errMsg;
  325 + if ([[NSString stringWithFormat:@"%@",errorDic[@"errorCode"]] isEqualToString:@"408"]) {
  326 + errMsg = @"请填写正确的手机号";
  327 + } else {
  328 + errMsg = errorDic[@"errorMessage"];
  329 + }
  330 + [QMUITips showWithText:errMsg inView:self hideAfterDelay:1.5];
  331 + self.phoneNum = nil;
  332 + self.gotVerificationCode = NO;
  333 + self.verificationCodeBtn.userInteractionEnabled = YES;
  334 + self.verificationCodeBtn.backgroundColor = [UIColor colorWithRed:0/255.0 green:194/255.0 blue:0/255.0 alpha:1.0];
  335 + [self.verificationCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  336 + self.gotVerificationCodeIng = NO;
  337 +
  338 + }];
346 339 }
347 340  
348 341 }
... ...
Example/CNLiveSettingModule.xcodeproj/project.pbxproj
... ... @@ -208,6 +208,7 @@
208 208 6003F587195388D20070C39A /* Frameworks */,
209 209 6003F588195388D20070C39A /* Resources */,
210 210 6A7F75A7B7E637A2752F7EE5 /* [CP] Embed Pods Frameworks */,
  211 + 17743842CB67A72F2519D76B /* [CP] Copy Pods Resources */,
211 212 );
212 213 buildRules = (
213 214 );
... ... @@ -298,6 +299,24 @@
298 299 /* End PBXResourcesBuildPhase section */
299 300  
300 301 /* Begin PBXShellScriptBuildPhase section */
  302 + 17743842CB67A72F2519D76B /* [CP] Copy Pods Resources */ = {
  303 + isa = PBXShellScriptBuildPhase;
  304 + buildActionMask = 2147483647;
  305 + files = (
  306 + );
  307 + inputPaths = (
  308 + "${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-resources.sh",
  309 + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveSettingModule/CNLiveSettingModule.bundle",
  310 + );
  311 + name = "[CP] Copy Pods Resources";
  312 + outputPaths = (
  313 + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveSettingModule.bundle",
  314 + );
  315 + runOnlyForDeploymentPostprocessing = 0;
  316 + shellPath = /bin/sh;
  317 + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-resources.sh\"\n";
  318 + showEnvVarsInLog = 0;
  319 + };
301 320 653FED99FAD33AD7306D3799 /* [CP] Check Pods Manifest.lock */ = {
302 321 isa = PBXShellScriptBuildPhase;
303 322 buildActionMask = 2147483647;
... ... @@ -338,7 +357,6 @@
338 357 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
339 358 "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework",
340 359 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
341   - "${BUILT_PRODUCTS_DIR}/CNLiveSettingModule/CNLiveSettingModule.framework",
342 360 "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework",
343 361 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework",
344 362 "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework",
... ... @@ -365,7 +383,6 @@
365 383 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
366 384 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework",
367 385 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
368   - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveSettingModule.framework",
369 386 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework",
370 387 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework",
371 388 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework",
... ...