Commit d9415ff5143f45764476400fbc34204dc412a9b7

Authored by zhangxiaowen
1 parent 7c0ddad3

no message

CNLiveSettingModule.podspec
... ... @@ -46,7 +46,7 @@ TODO: 网家家-设置模块.
46 46 ss.dependency 'CNLiveSettingModule/Cancellation'
47 47 ss.dependency 'CNLiveSettingModule/FontSize'
48 48 ss.dependency 'CNLiveSettingModule/BackgroundImage'
49   -
  49 + ss.dependency 'CNLiveSettingModule/UpdateTel'
50 50 end
51 51  
52 52 # View
... ... @@ -96,6 +96,12 @@ TODO: 网家家-设置模块.
96 96 ss.dependency 'CNLiveSettingModule/View'
97 97 end
98 98  
  99 + # 更换手机号
  100 + s.subspec 'UpdateTel' do |ss|
  101 + ss.source_files = 'CNLiveSettingModule/Classes/UpdateTel/*.{h,m}'
  102 + ss.dependency 'CNLiveSettingModule/View'
  103 + end
  104 +
99 105 s.resource_bundles = {
100 106 'CNLiveSettingModule' => ['CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets']
101 107 }
... ... @@ -109,6 +115,7 @@ TODO: 网家家-设置模块.
109 115 s.dependency 'CNLiveTripartiteManagement/SDWebImage'
110 116 s.dependency 'CNLiveTripartiteManagement/Masonry'
111 117 s.dependency 'CNLiveTripartiteManagement/MJExtension'
  118 + s.dependency 'CNLiveTripartiteManagement/YYKit'
112 119  
113 120 # 服务层
114 121 s.dependency 'CNLiveServices'
... ... @@ -125,13 +132,18 @@ TODO: 网家家-设置模块.
125 132 # 用户协议
126 133 s.dependency 'CNLiveUserAgreementManager'
127 134  
  135 + #基础库
128 136 s.dependency 'CNLiveBaseKit'
129 137  
130   -
  138 + # 相册
131 139 s.dependency 'CNLiveImagePickerController'
  140 +
  141 + # 相机
132 142 s.dependency 'CNLiveAVCamera'
133   - s.dependency 'CNLiveBusinessTools'
134 143  
135   - s.static_framework = true
  144 + # 工具库
  145 + s.dependency 'CNLiveBusinessTools'
  146 +
  147 + s.dependency 'CNLiveCommonClass'
136 148  
137 149 end
... ...
CNLiveSettingModule/Classes/Controller/CNLiveSettingController.m
... ... @@ -18,6 +18,7 @@
18 18 #import "CNLiveServices.h"
19 19 #import "CNLiveSettingNavigationBar.h"
20 20  
  21 +#import "CNLiveUpdateTelController.h"//修改手机号
21 22 #import "CNLivePrivacyController.h"//隐私
22 23 #import "CNLiveCancellationController.h"//注销
23 24 #import "CNLiveAboutUsController.h"//关于我们
... ... @@ -191,7 +192,9 @@ static const NSInteger timeValue = 1.5;
191 192  
192 193 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
193 194 if(indexPath.row == 0){ // 更换手机号
194   -
  195 + CNLiveUpdateTelController *vc = [[CNLiveUpdateTelController alloc]init];
  196 + [self.navigationController pushViewController:vc animated:YES];
  197 +
195 198 }
196 199 else if(indexPath.row == 1){ //绑定管理
197 200  
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelController.h 0 → 100644
  1 +//
  2 +// CNLiveUpdateTelController.h
  3 +// CNLiveSettingModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNCommonViewController.h"
  10 +
  11 +@interface CNLiveUpdateTelController : CNCommonViewController
  12 +
  13 +@end
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelController.m 0 → 100644
  1 +//
  2 +// CNLiveUpdateTelController.m
  3 +// CNLiveSettingModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveUpdateTelController.h"
  10 +//#import "CNSelectCountriesViewController.h"
  11 +#import "YYKit.h"
  12 +#import <Masonry/Masonry.h>
  13 +#import "QMUIKit.h"
  14 +
  15 +#import "CNUserInfoManager.h"
  16 +#import "NSString+CNLiveExtension.h"
  17 +
  18 +#import "CNLiveSettingNavigationBar.h"
  19 +#import "CNLiveUpdateTelView.h"
  20 +
  21 +//@interface CNLiveUpdateTelController ()<UITextFieldDelegate,SelectCountriesDelegate>{
  22 +
  23 +@interface CNLiveUpdateTelController()<UITextFieldDelegate, CNLiveSettingNavigationBarDelegate>{
  24 + NSString * _code;
  25 +}
  26 +
  27 +@property (nonatomic, strong) CNLiveSettingNavigationBar *navigationBar;
  28 +@property (nonatomic, strong) CNLiveUpdateTelView *updateTelView;//背景
  29 +@property (nonatomic, strong) UIButton *changeBtn;//改变按钮
  30 +@property (nonatomic, strong) YYLabel *connectionLab;
  31 +
  32 +@end
  33 +
  34 +@implementation CNLiveUpdateTelController
  35 +
  36 +- (void)viewWillAppear:(BOOL)animated {
  37 + [super viewWillAppear:animated];
  38 + self.navigationController.navigationBarHidden = YES;
  39 +
  40 +}
  41 +
  42 +- (void)viewDidLoad {
  43 + [super viewDidLoad];
  44 + // Do any additional setup after loading the view.
  45 +
  46 + _code = @"86";
  47 +
  48 + self.view.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  49 +
  50 + [self createSubViews];
  51 + [self xw_layoutSubviews];
  52 +
  53 + __weak typeof(self) weakSelf = self;
  54 + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"确定" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  55 +
  56 + }];
  57 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  58 + __strong typeof(weakSelf) strongSelf = weakSelf;
  59 + if(!strongSelf) return ;
  60 + [strongSelf.navigationController popViewControllerAnimated:YES];
  61 +
  62 + }];
  63 +
  64 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"更换手机号将只能使用新绑定的手机号登录app,是否继续修改?" message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
  65 + [alertController addAction:sure];
  66 + [alertController addAction:cancel];
  67 +
  68 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  69 +
  70 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  71 +
  72 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  73 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  74 +
  75 + sure.buttonAttributes = titleAttributs;
  76 + cancel.buttonAttributes = cancelAttributs;
  77 +
  78 + [alertController showWithAnimated:YES];
  79 +
  80 +}
  81 +
  82 +#pragma mark - UI
  83 +- (void)createSubViews{
  84 + [self.view addSubview:self.navigationBar];
  85 + [self.view addSubview:self.updateTelView];
  86 + [self.view addSubview:self.changeBtn];
  87 + [self.view addSubview:self.connectionLab];
  88 +}
  89 +
  90 +- (void)xw_layoutSubviews{
  91 + [self.updateTelView mas_makeConstraints:^(MASConstraintMaker *make) {
  92 + make.left.right.equalTo(self.view);
  93 + make.top.equalTo(self.view).offset(NavigationContentTop+1);
  94 + make.height.mas_equalTo(150+10);
  95 + }];
  96 + [self.changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  97 + make.top.equalTo(self.updateTelView.mas_bottom).offset(16);
  98 + make.left.equalTo(self.view).offset(60);
  99 + make.right.equalTo(self.view).offset(-60);
  100 + make.height.mas_equalTo(45);
  101 + }];
  102 + [self.connectionLab mas_makeConstraints:^(MASConstraintMaker *make) {
  103 + make.left.right.equalTo(self.view);
  104 + make.bottom.equalTo(self.view.mas_bottom).offset(-30);
  105 + }];
  106 +
  107 +}
  108 +
  109 +- (void)didReceiveMemoryWarning {
  110 + [super didReceiveMemoryWarning];
  111 + // Dispose of any resources that can be recreated.
  112 +}
  113 +
  114 +#pragma mark - Action
  115 +- (void)compleBtnAction:(UIButton *)sender {
  116 + if (self.updateTelView.gotVerificationCode) {
  117 + if (self.updateTelView.codeTF.text.length == 6) {
  118 + [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 +// }];
  132 +
  133 + } else {
  134 + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  135 + }];
  136 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"请输入正确的验证码" message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
  137 + [alertController addAction:sure];
  138 +
  139 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  140 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  141 + sure.buttonAttributes = titleAttributs;
  142 +
  143 + [alertController showWithAnimated:YES];
  144 + }
  145 +
  146 + } else {
  147 + NSString *alertText = @"请先获取验证码";
  148 + if (self.updateTelView.numberTF.text.length != 11) {
  149 + alertText = @"请先输入正确的手机号码";
  150 + } else {
  151 + alertText = @"请先获取验证码";
  152 + }
  153 +
  154 + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  155 + }];
  156 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:alertText message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
  157 + [alertController addAction:sure];
  158 +
  159 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  160 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  161 + sure.buttonAttributes = titleAttributs;
  162 +
  163 + [alertController showWithAnimated:YES];
  164 +
  165 + }
  166 +
  167 +}
  168 +
  169 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  170 + [self.updateTelView.numberTF resignFirstResponder];
  171 +}
  172 +
  173 +#pragma mark - SelectCountriesDelegate
  174 +//- (void)selectViewController:(CNSelectCountriesViewController *)viewController countryName:(NSString *)name countryCode:(NSString *)code{
  175 +// _countryName.text = name;
  176 +// _countryCode.text = [NSString stringWithFormat:@"+%@",code];
  177 +// _codeStr = code;
  178 +// NSLog(@"%@---%@",name,code);
  179 +//
  180 +//}
  181 +
  182 +#pragma mark - Lazy Loading
  183 +- (CNLiveSettingNavigationBar *)navigationBar {
  184 + if (!_navigationBar) {
  185 + _navigationBar = [[CNLiveSettingNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
  186 + _navigationBar.backgroundColor = [UIColor whiteColor];
  187 + _navigationBar.delegate = self;
  188 + _navigationBar.title.text = @"更换手机号";
  189 + _navigationBar.right = nil;
  190 + }
  191 + return _navigationBar;
  192 +}
  193 +
  194 +- (CNLiveUpdateTelView *)updateTelView{
  195 + if (!_updateTelView) {
  196 + _updateTelView = [[CNLiveUpdateTelView alloc] init];
  197 + _updateTelView.backgroundColor = [UIColor whiteColor];
  198 + }
  199 + return _updateTelView;
  200 +}
  201 +
  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];
  220 + }
  221 + return _changeBtn;
  222 +}
  223 +
  224 +- (YYLabel *)connectionLab {
  225 + if (!_connectionLab) {
  226 + _connectionLab = [[YYLabel alloc] init];
  227 + [_connectionLab setFont:UIFontMake(12)];
  228 + _connectionLab.numberOfLines = 0;
  229 + NSString *str = @"若当前号码已不用或丢失,请点击联系客服";
  230 + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:str];
  231 + text.color = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
  232 + [text setTextHighlightRange:NSMakeRange(text.length-4, 4) color:[UIColor colorWithRed:44/255.0 green:209/255.0 blue:201/255.0 alpha:1.0] backgroundColor:[UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  233 +
  234 + NSString *phoneStr = @"010-65832485";
  235 +
  236 + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"好" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  237 + if (@available(iOS 10.0, *)) {
  238 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneStr]] options:@{} completionHandler:nil];
  239 + } else {
  240 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneStr]]];
  241 + }
  242 +
  243 + }];
  244 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  245 + }];
  246 +
  247 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"联系客服" message:[NSString stringWithFormat:@"将给%@拨打电话",phoneStr] preferredStyle:QMUIAlertControllerStyleAlert];
  248 + [alertController addAction:sure];
  249 + [alertController addAction:cancel];
  250 +
  251 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  252 +
  253 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  254 +
  255 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  256 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  257 +
  258 + sure.buttonAttributes = titleAttributs;
  259 + cancel.buttonAttributes = cancelAttributs;
  260 +
  261 + [alertController showWithAnimated:YES];
  262 +
  263 + } ];
  264 + _connectionLab.attributedText = text;
  265 + _connectionLab.textAlignment = NSTextAlignmentCenter;
  266 +
  267 + }
  268 + return _connectionLab;
  269 +}
  270 +
  271 +/*
  272 +#pragma mark - Navigation
  273 +
  274 +// In a storyboard-based application, you will often want to do a little preparation before navigation
  275 +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  276 + // Get the new view controller using [segue destinationViewController].
  277 + // Pass the selected object to the new view controller.
  278 +}
  279 +*/
  280 +
  281 +/**
  282 + * 创建图片
  283 + *
  284 + * @param imageName 图片名字
  285 + * @param bundleName 图片所在的bundle名字
  286 + * @param targetClass 类和bundle的同级目录
  287 + * @return 返回UIImage
  288 + */
  289 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
  290 + NSBundle *bundle = [NSBundle bundleForClass:targetClass];
  291 + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
  292 + NSBundle *targetBundle = [NSBundle bundleWithURL:url];
  293 + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
  294 + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
  295 +}
  296 +
  297 +#pragma mark - CNLiveSettingNavigationBarDelegate
  298 +- (void)navigationBar:(CNLiveSettingNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
  299 + if ([actionEvents isEqualToString:@"1"]) {
  300 + [self.navigationController popViewControllerAnimated:YES];
  301 + }else if ([actionEvents isEqualToString:@"2"]){
  302 +
  303 + }
  304 +}
  305 +
  306 +@end
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.h 0 → 100644
  1 +//
  2 +// CNLiveUpdateTelView.h
  3 +// CNLiveSettingModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/21.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@class CNLiveUpdateTelView;
  13 +@protocol CNLiveUpdateTelViewDelegate <NSObject>
  14 +- (void)clickedCancellation:(CNLiveUpdateTelView *)view;
  15 +
  16 +@end
  17 +@interface CNLiveUpdateTelView : UIView
  18 +@property (nonatomic, weak) id<CNLiveUpdateTelViewDelegate> delegate;
  19 +@property (nonatomic, strong) UITextField *numberTF;//手机号tf
  20 +@property (nonatomic, strong) UITextField *codeTF;//验证码tf
  21 +
  22 +@property (nonatomic, assign) BOOL gotVerificationCode;
  23 +@property (nonatomic, assign) BOOL gotVerificationCodeIng;
  24 +@property (nonatomic, copy) NSString *phoneNum;
  25 +
  26 +@end
  27 +
  28 +NS_ASSUME_NONNULL_END
... ...
CNLiveSettingModule/Classes/UpdateTel/CNLiveUpdateTelView.m 0 → 100644
  1 +//
  2 +// CNLiveUpdateTelView.m
  3 +// CNLiveSettingModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/21.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveUpdateTelView.h"
  10 +#import "YYKit.h"
  11 +#import <Masonry/Masonry.h>
  12 +#import "QMUIKit.h"
  13 +
  14 +#import "NSString+CNLiveExtension.h"
  15 +#import "CNUserInfoManager.h"
  16 +
  17 +#define TIMECOUNT 60;
  18 +
  19 +@interface CNLiveUpdateTelView()<UITextFieldDelegate>
  20 +@property (nonatomic, strong) UILabel *countryName;//国家
  21 +@property (nonatomic, strong) UILabel *countryCode;
  22 +@property (nonatomic, strong) UILabel *interval;
  23 +@property (nonatomic, strong) UIImageView *countryImg;
  24 +
  25 +@property (nonatomic, strong) UILabel *numberLabel;//手机号
  26 +//@property (nonatomic, strong) UITextField *numberTF;//手机号tf
  27 +
  28 +@property (nonatomic, strong) UILabel *codeLabel;//验证码
  29 +//@property (nonatomic, strong) UITextField *codeTF;//验证码tf
  30 +@property (nonatomic, strong) UIButton *verificationCodeBtn;//验证码按钮
  31 +
  32 +@end
  33 +
  34 +@implementation CNLiveUpdateTelView
  35 +static const NSInteger margin = 15;
  36 +#pragma mark - Init
  37 +- (instancetype)initWithFrame:(CGRect)frame {
  38 + self = [super initWithFrame:frame];
  39 + if (self) {
  40 + self.backgroundColor = [UIColor whiteColor];
  41 + [self setup];
  42 + }
  43 + return self;
  44 +}
  45 +- (void)dealloc{
  46 +
  47 +}
  48 +
  49 +#pragma mark - UI
  50 +- (void)setup {
  51 + [self addSubview:self.countryName];
  52 + [self addSubview:self.interval];
  53 + [self addSubview:self.countryImg];
  54 + [self addSubview:self.countryCode];
  55 +
  56 + [self addSubview:self.numberLabel];
  57 + [self addSubview:self.numberTF];
  58 +
  59 + [self addSubview:self.codeLabel];
  60 + [self addSubview:self.codeTF];
  61 +
  62 + [self addSubview:self.verificationCodeBtn];
  63 +
  64 +}
  65 +- (void)layoutSubviews{
  66 + [super layoutSubviews];
  67 +
  68 + [self.countryName mas_makeConstraints:^(MASConstraintMaker *make) {
  69 + make.top.equalTo(self).offset(0);
  70 + make.left.equalTo(self).offset(margin);
  71 + make.height.mas_equalTo(50);
  72 + }];
  73 + [self.interval mas_makeConstraints:^(MASConstraintMaker *make) {
  74 + make.top.equalTo(self.countryName.mas_bottom).offset(0);
  75 + make.left.right.equalTo(self).offset(0);
  76 + make.height.mas_equalTo(10);
  77 + }];
  78 + [self.countryImg mas_makeConstraints:^(MASConstraintMaker *make) {
  79 + make.top.equalTo(self).offset(0);
  80 + make.right.equalTo(self).offset(-margin);
  81 + make.height.mas_equalTo(50);
  82 + make.width.mas_equalTo(10);
  83 + }];
  84 + [self.countryCode mas_makeConstraints:^(MASConstraintMaker *make) {
  85 + make.top.equalTo(self).offset(0);
  86 + make.right.equalTo(self.countryImg.mas_left).offset(-5);
  87 + make.height.mas_equalTo(50);
  88 + }];
  89 + [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90 + make.top.equalTo(self.interval.mas_bottom).offset(0);
  91 + make.left.equalTo(self).offset(margin);
  92 + make.height.mas_equalTo(50);
  93 + make.width.mas_equalTo(45);
  94 + }];
  95 + [self.verificationCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  96 + make.centerY.equalTo(self.numberLabel);
  97 + make.right.equalTo(self).offset(-margin);
  98 + make.width.mas_equalTo(100);
  99 + make.height.mas_equalTo(30);
  100 + }];
  101 + [self.numberTF mas_makeConstraints:^(MASConstraintMaker *make) {
  102 + make.centerY.equalTo(self.numberLabel);
  103 + make.left.equalTo(self.numberLabel.mas_right).offset(20);
  104 + make.right.equalTo(self.verificationCodeBtn.mas_left).offset(-10);
  105 + }];
  106 + [self.codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  107 + make.top.equalTo(self.numberLabel.mas_bottom).offset(0);
  108 + make.left.equalTo(self.numberLabel);
  109 + make.width.mas_equalTo(45);
  110 + make.height.mas_equalTo(50);
  111 +
  112 + }];
  113 + [self.codeTF mas_makeConstraints:^(MASConstraintMaker *make) {
  114 + make.centerY.equalTo(self.codeLabel);
  115 + make.left.equalTo(self.codeLabel.mas_right).offset(20);
  116 + make.width.equalTo(self.numberTF);
  117 + }];
  118 +}
  119 +
  120 +/*
  121 + // Only override drawRect: if you perform custom drawing.
  122 + // An empty implementation adversely affects performance during animation.
  123 + - (void)drawRect:(CGRect)rect {
  124 + // Drawing code
  125 + }
  126 + */
  127 +
  128 +#pragma mark - UITextFieldDelegate
  129 +- (void)textFieldDidChange:(UITextField *)textField {
  130 + if (textField.tag == 10001) { //手机号
  131 + if (!self.gotVerificationCodeIng) {
  132 + [self setupTextFieldUI:textField];
  133 + }
  134 + }
  135 + else if (textField.tag == 10002) { //验证码
  136 +
  137 + }
  138 +
  139 +}
  140 +
  141 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  142 + if([string length] != 0){
  143 + NSLog(@"增");
  144 + if (textField.tag == 10002) {
  145 + if (textField.text.length>=6) {
  146 + return NO;
  147 + }
  148 + }
  149 + if (textField.tag == 10001) {
  150 + if (textField.text.length>=11) {
  151 + return NO;
  152 + }
  153 + }
  154 + }
  155 + else {
  156 + NSLog(@"删");
  157 + return YES;
  158 + }
  159 + return YES;
  160 +}
  161 +
  162 +#pragma mark - 懒加载
  163 +- (UILabel *)countryName {
  164 + if (!_countryName) {
  165 + _countryName = [[UILabel alloc] init];
  166 + _countryName.textColor = [UIColor colorWithRed:26/255.0 green:26/255.0 blue:26/255.0 alpha:1.0];
  167 + _countryName.font = [UIFont systemFontOfSize:14];
  168 + _countryName.text = @"中国大陆";
  169 + _countryName.textAlignment = NSTextAlignmentLeft;
  170 + }
  171 + return _countryName;
  172 +}
  173 +
  174 +- (UILabel *)interval {
  175 + if (!_interval) {
  176 + _interval = [[UILabel alloc] init];
  177 + _interval.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  178 + }
  179 + return _interval;
  180 +}
  181 +- (UIImageView *)countryImg{
  182 + if (!_countryImg) {
  183 + _countryImg = [[UIImageView alloc] init];
  184 + _countryImg.userInteractionEnabled = YES;
  185 + UIImage *image = [self xw_getImageName:@"mine_info_front" bundleName:@"CNLiveSettingModule" targetClass:[self class]];
  186 + _countryImg.image = image;
  187 + _countryImg.contentMode = UIViewContentModeCenter;
  188 + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(countryTap:)];
  189 + [_countryImg addGestureRecognizer:tap];
  190 + }
  191 + return _countryImg;
  192 +}
  193 +- (UILabel *)countryCode {
  194 + if (!_countryCode) {
  195 + _countryCode = [[UILabel alloc] init];
  196 + _countryCode.textColor = [UIColor colorWithRed:26/255.0 green:26/255.0 blue:26/255.0 alpha:1.0];
  197 + _countryCode.font = [UIFont systemFontOfSize:14];
  198 + _countryCode.text = @"+86";
  199 + _countryCode.textAlignment = NSTextAlignmentLeft;
  200 + _countryCode.userInteractionEnabled = YES;
  201 + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(countryTap:)];
  202 + [_countryCode addGestureRecognizer:tap];
  203 + }
  204 + return _countryCode;
  205 +}
  206 +- (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 +
  212 +}
  213 +
  214 +- (UILabel *)numberLabel {
  215 + if (!_numberLabel) {
  216 + _numberLabel = [[UILabel alloc] init];
  217 + _numberLabel.textColor = [UIColor colorWithRed:26/255.0 green:26/255.0 blue:26/255.0 alpha:1.0];
  218 + _numberLabel.font = [UIFont systemFontOfSize:14];
  219 + _numberLabel.text = @"手机号";
  220 + _numberLabel.textAlignment = NSTextAlignmentLeft;
  221 + }
  222 + return _numberLabel;
  223 +}
  224 +
  225 +- (UILabel *)codeLabel {
  226 + if (!_codeLabel) {
  227 + _codeLabel = [[UILabel alloc] init];
  228 + _codeLabel.textColor = [UIColor colorWithRed:26/255.0 green:26/255.0 blue:26/255.0 alpha:1.0];
  229 + _codeLabel.font = [UIFont systemFontOfSize:14];
  230 + _codeLabel.text = @"验证码";
  231 + _codeLabel.textAlignment = NSTextAlignmentLeft;
  232 + }
  233 + return _codeLabel;
  234 +}
  235 +
  236 +- (UITextField *)numberTF {
  237 + if (!_numberTF) {
  238 + _numberTF = [[UITextField alloc] init];
  239 + _numberTF.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
  240 + _numberTF.font = [UIFont systemFontOfSize:14];
  241 + _numberTF.placeholder = @"请输入新手机号";
  242 + _numberTF.delegate = self;
  243 + _numberTF.keyboardType = UIKeyboardTypeNumberPad;
  244 + [_numberTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  245 + _numberTF.tag = 10001;
  246 + }
  247 + return _numberTF;
  248 +}
  249 +
  250 +- (UITextField *)codeTF {
  251 + if (!_codeTF) {
  252 + _codeTF = [[UITextField alloc] init];
  253 + _codeTF.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
  254 + _codeTF.font = [UIFont systemFontOfSize:14];
  255 + _codeTF.placeholder = @"请输入验证码";
  256 + _codeTF.delegate = self;
  257 + _codeTF.keyboardType = UIKeyboardTypeNumberPad;
  258 + [_codeTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  259 + _codeTF.tag = 10002;
  260 + }
  261 + return _codeTF;
  262 +}
  263 +
  264 +- (UIButton *)verificationCodeBtn{
  265 + if (!_verificationCodeBtn) {
  266 + _verificationCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  267 + [_verificationCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  268 + [_verificationCodeBtn setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1.0] forState:UIControlStateNormal];
  269 + _verificationCodeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  270 + _verificationCodeBtn.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  271 + _verificationCodeBtn.layer.cornerRadius = 15;
  272 + _verificationCodeBtn.layer.masksToBounds = YES;
  273 + [_verificationCodeBtn addTarget:self action:@selector(verificationCodeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  274 + }
  275 + return _verificationCodeBtn;
  276 +}
  277 +/**
  278 + * 创建图片
  279 + *
  280 + * @param imageName 图片名字
  281 + * @param bundleName 图片所在的bundle名字
  282 + * @param targetClass 类和bundle的同级目录
  283 + * @return 返回UIImage
  284 + */
  285 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
  286 + NSBundle *bundle = [NSBundle bundleForClass:targetClass];
  287 + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
  288 + NSBundle *targetBundle = [NSBundle bundleWithURL:url];
  289 + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
  290 + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
  291 +
  292 +}
  293 +
  294 +#pragma mark - Action
  295 +- (void)verificationCodeBtnAction:(UIButton *)sender {
  296 + 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 + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"我知道了" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  302 + }];
  303 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"请输入正确的手机号码" message:@"" preferredStyle:QMUIAlertControllerStyleAlert];
  304 + [alertController addAction:sure];
  305 +
  306 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  307 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  308 + sure.buttonAttributes = titleAttributs;
  309 +
  310 + [alertController showWithAnimated:YES];
  311 + }
  312 + else if ([self.numberTF.text isEqualToString:CNUserShareModel.mobile]) {
  313 + [QMUITips showWithText:@"您更新的手机号与旧手机号一致,请重新输入确认" inView:self hideAfterDelay:1.5];
  314 + }
  315 + else {
  316 + // 发送验证码
  317 + self.phoneNum = self.numberTF.text;
  318 + self.verificationCodeBtn.userInteractionEnabled = NO;
  319 + self.verificationCodeBtn.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  320 + [self.verificationCodeBtn setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1.0] forState:UIControlStateNormal];
  321 + self.gotVerificationCodeIng = YES;
  322 +
  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 +// }];
  346 + }
  347 +
  348 +}
  349 +
  350 +#pragma mark - 倒计时
  351 +- (void)countDown {
  352 +
  353 + __block NSInteger second = TIMECOUNT;
  354 + //(1)
  355 + dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  356 + //(2)
  357 + dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, quene);
  358 + //(3)
  359 + dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
  360 + //(4)
  361 + dispatch_source_set_event_handler(timer, ^{
  362 + dispatch_async(dispatch_get_main_queue(), ^{
  363 + if (second == 0) {
  364 + [self setupTextFieldUI:_numberTF];
  365 + self.gotVerificationCodeIng = NO;
  366 + [self.verificationCodeBtn setTitle:[NSString stringWithFormat:@"获取验证码"] forState:UIControlStateNormal];
  367 + second = TIMECOUNT;
  368 + dispatch_cancel(timer);
  369 + } else {
  370 + [self.verificationCodeBtn setTitle:[NSString stringWithFormat:@"%lds",second] forState:UIControlStateNormal];
  371 + second--;
  372 + }
  373 + });
  374 + });
  375 + //(5)
  376 + dispatch_resume(timer);
  377 +}
  378 +
  379 +- (void)setupTextFieldUI:(UITextField *)textField{
  380 + if (textField.text.length > 0) {
  381 + _verificationCodeBtn.userInteractionEnabled = YES;
  382 + _verificationCodeBtn.backgroundColor = [UIColor colorWithRed:0/255.0 green:194/255.0 blue:0/255.0 alpha:1.0];
  383 + [_verificationCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  384 +
  385 + }
  386 + else {
  387 + _verificationCodeBtn.userInteractionEnabled = NO;
  388 + _verificationCodeBtn.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
  389 + [_verificationCodeBtn setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1.0] forState:UIControlStateNormal];
  390 + }
  391 +}
  392 +
  393 +@end
  394 +
... ...
Example/CNLiveSettingModule.xcodeproj/project.pbxproj
... ... @@ -207,8 +207,7 @@
207 207 6003F586195388D20070C39A /* Sources */,
208 208 6003F587195388D20070C39A /* Frameworks */,
209 209 6003F588195388D20070C39A /* Resources */,
210   - 6D9A35784F56B3BE6F09B722 /* [CP] Embed Pods Frameworks */,
211   - 265B673AE18D46E894A61EF4 /* [CP] Copy Pods Resources */,
  210 + 6A7F75A7B7E637A2752F7EE5 /* [CP] Embed Pods Frameworks */,
212 211 );
213 212 buildRules = (
214 213 );
... ... @@ -299,24 +298,6 @@
299 298 /* End PBXResourcesBuildPhase section */
300 299  
301 300 /* Begin PBXShellScriptBuildPhase section */
302   - 265B673AE18D46E894A61EF4 /* [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   - };
320 301 653FED99FAD33AD7306D3799 /* [CP] Check Pods Manifest.lock */ = {
321 302 isa = PBXShellScriptBuildPhase;
322 303 buildActionMask = 2147483647;
... ... @@ -339,7 +320,7 @@
339 320 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
340 321 showEnvVarsInLog = 0;
341 322 };
342   - 6D9A35784F56B3BE6F09B722 /* [CP] Embed Pods Frameworks */ = {
  323 + 6A7F75A7B7E637A2752F7EE5 /* [CP] Embed Pods Frameworks */ = {
343 324 isa = PBXShellScriptBuildPhase;
344 325 buildActionMask = 2147483647;
345 326 files = (
... ... @@ -353,9 +334,11 @@
353 334 "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework",
354 335 "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework",
355 336 "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework",
  337 + "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
356 338 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
357 339 "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework",
358 340 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
  341 + "${BUILT_PRODUCTS_DIR}/CNLiveSettingModule/CNLiveSettingModule.framework",
359 342 "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework",
360 343 "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework",
361 344 "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework",
... ... @@ -378,9 +361,11 @@
378 361 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework",
379 362 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework",
380 363 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework",
  364 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
381 365 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
382 366 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework",
383 367 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
  368 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveSettingModule.framework",
384 369 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework",
385 370 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework",
386 371 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework",
... ...