diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 4c5a3b36..41eb8797 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -57,6 +57,10 @@ 73FFADDC93E195344047A2EC /* Pods_xplan_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CACF623970097D653132D69A /* Pods_xplan_ios.framework */; }; 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; }; E8B825BA26E9A9D5009E8E9F /* BaseObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825B926E9A9D5009E8E9F /* BaseObject.m */; }; + E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; }; + E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; }; + E872309026E8D29300B90D4F /* LoginVerifCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */; }; + E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -160,6 +164,14 @@ CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E8B825B826E9A9D5009E8E9F /* BaseObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseObject.h; sourceTree = ""; }; E8B825B926E9A9D5009E8E9F /* BaseObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseObject.m; sourceTree = ""; }; + E872308726E89BE000B90D4F /* LoginPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPhoneViewController.h; sourceTree = ""; }; + E872308826E89BE000B90D4F /* LoginPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPhoneViewController.m; sourceTree = ""; }; + E872308B26E89DAA00B90D4F /* LoginInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginInputView.h; sourceTree = ""; }; + E872308C26E89DAA00B90D4F /* LoginInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginInputView.m; sourceTree = ""; }; + E872308E26E8D29300B90D4F /* LoginVerifCodeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeViewController.h; sourceTree = ""; }; + E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeViewController.m; sourceTree = ""; }; + E872309126E8D31500B90D4F /* LoginVerifCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeView.h; sourceTree = ""; }; + E872309226E8D31500B90D4F /* LoginVerifCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeView.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -341,8 +353,13 @@ 189DD58A26DF978700AB55B1 /* View */ = { isa = PBXGroup; children = ( + E872308A26E89D5100B90D4F /* CustomView */, 189DD56326DE465A00AB55B1 /* LoginViewController.h */, 189DD56426DE465A00AB55B1 /* LoginViewController.m */, + E872308726E89BE000B90D4F /* LoginPhoneViewController.h */, + E872308826E89BE000B90D4F /* LoginPhoneViewController.m */, + E872308E26E8D29300B90D4F /* LoginVerifCodeViewController.h */, + E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */, ); path = View; sourceTree = ""; @@ -492,6 +509,17 @@ path = Pods; sourceTree = ""; }; + E872308A26E89D5100B90D4F /* CustomView */ = { + isa = PBXGroup; + children = ( + E872308B26E89DAA00B90D4F /* LoginInputView.h */, + E872308C26E89DAA00B90D4F /* LoginInputView.m */, + E872309126E8D31500B90D4F /* LoginVerifCodeView.h */, + E872309226E8D31500B90D4F /* LoginVerifCodeView.m */, + ); + path = CustomView; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -643,14 +671,18 @@ 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */, 189DD56526DE465A00AB55B1 /* LoginViewController.m in Sources */, 187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */, + E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */, 189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */, 187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */, 189DD74026E21C3F00AB55B1 /* YYUtility+App.m in Sources */, 189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */, 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */, + E872309026E8D29300B90D4F /* LoginVerifCodeViewController.m in Sources */, 189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */, + E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */, 189DD75926E6003C00AB55B1 /* Api.m in Sources */, 189DD53F26DE255600AB55B1 /* main.m in Sources */, + E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */, 189DD58F26DF97E700AB55B1 /* LoginPresenter.m in Sources */, 189DD55026DE37F900AB55B1 /* MvpViewController.m in Sources */, ); diff --git a/xplan-ios/Main/Login/Api/Api+Login.h b/xplan-ios/Main/Login/Api/Api+Login.h index 9cb5a4f4..4daaf59e 100644 --- a/xplan-ios/Main/Login/Api/Api+Login.h +++ b/xplan-ios/Main/Login/Api/Api+Login.h @@ -13,6 +13,11 @@ NS_ASSUME_NONNULL_BEGIN + (void)phoneQuickLogin:(HttpRequestHelperCompletion)completion accessToken:(NSString *)accessToken token:(NSString *)token; +/// 获取手机号的验证码 +/// @param completion 请求完成 +/// @param mobile 手机号 +/// @param type 类型 业务类型,必填,1注册,2登录,3重设密码,4绑定手机,5绑定xczAccount,6重设xcz密码,7解绑手机 ++ (void)phoneSmsCode:(HttpRequestHelperCompletion)completion mobile:(NSString *)mobile type:(NSString *)type; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Api/Api+Login.m b/xplan-ios/Main/Login/Api/Api+Login.m index 4a82e84b..03e7a490 100644 --- a/xplan-ios/Main/Login/Api/Api+Login.m +++ b/xplan-ios/Main/Login/Api/Api+Login.m @@ -13,4 +13,13 @@ [self makeRequest:@"acc/oneclick/login" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, accessToken, token, nil]; } + +/// 获取手机号的验证码 +/// @param completion 请求完成 +/// @param mobile 手机号 +/// @param type 类型 业务类型,必填,1注册,2登录,3重设密码,4绑定手机,5绑定xczAccount,6重设xcz密码,7解绑手机 ++ (void)phoneSmsCode:(HttpRequestHelperCompletion)completion mobile:(NSString *)mobile type:(NSString *)type { + [self makeRequest:@"sms/getCode" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, mobile, type]; +} + @end diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.h b/xplan-ios/Main/Login/Presenter/LoginPresenter.h index e385d156..e46e2447 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.h +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.h @@ -13,6 +13,14 @@ NS_ASSUME_NONNULL_BEGIN - (void)phoneQuickLogin:(NSString *)accessToken token:(NSString*) token; +/// 获取手机的验证码 +/// @param phone 手机号 +/// @param type 类型 +- (void)phoneSmsCode:(NSString *)phone type:(int)type; + +/// 开启一个倒计时 +/// @param total 倒计时的时间 +- (void)openCutDownWithTotal:(int)total; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.m b/xplan-ios/Main/Login/Presenter/LoginPresenter.m index 31a11c4d..9cfea336 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.m +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.m @@ -6,6 +6,8 @@ // #import "LoginPresenter.h" +///第三方 +#import #import "LoginProtocol.h" #import "Api+Login.h" #import "AccountInfoStorage.h" @@ -25,4 +27,36 @@ }] accessToken:accessToken token:token]; } +/// 获取手机的验证码 +/// @param phone 手机号 +/// @param type 类型 +- (void)phoneSmsCode:(NSString *)phone type:(int)type { + [Api phoneSmsCode:[self createHttpCompletion:^(id _Nonnull data) { + [[self getView] phoneSmsCodeSuccess]; + ///开启一个倒计时60 + [self openCutDownWithTotal:60]; + } fail:^(NSInteger code, NSString * _Nullable msg) { + + } showLoading:NO errorToast:YES] mobile:phone type:[NSString stringWithFormat:@"%d", type]]; + + +} + + +/// 开启一个倒计时 +/// @param total 倒计时的时间 +- (void)openCutDownWithTotal:(int)total { + __block int blockTotle = total; + __block RACDisposable * disposable; + disposable = [[RACSignal interval:1 onScheduler:[RACScheduler mainThreadScheduler]] subscribeNext:^(NSDate * _Nullable) { + blockTotle--; + [[self getView] countDownWithCurrent:blockTotle]; + ///倒计时结束 停止监听 + if (blockTotle == 0) { + [[self getView] countDownFinish]; + [disposable dispose]; + } + }]; +} + @end diff --git a/xplan-ios/Main/Login/Protocol/LoginProtocol.h b/xplan-ios/Main/Login/Protocol/LoginProtocol.h index 7e501c7b..bbab75c0 100644 --- a/xplan-ios/Main/Login/Protocol/LoginProtocol.h +++ b/xplan-ios/Main/Login/Protocol/LoginProtocol.h @@ -12,7 +12,12 @@ NS_ASSUME_NONNULL_BEGIN @protocol LoginProtocol - (void)phoneQuickLoginSuccess; - +///请求手机号的验证码成功 +- (void)phoneSmsCodeSuccess; +///倒计时进行中 +- (void)countDownWithCurrent:(int)current; +///倒计时结束 +- (void)countDownFinish; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/CustomView/LoginInputView.h b/xplan-ios/Main/Login/View/CustomView/LoginInputView.h new file mode 100644 index 00000000..065d1a8b --- /dev/null +++ b/xplan-ios/Main/Login/View/CustomView/LoginInputView.h @@ -0,0 +1,20 @@ +// +// LoginInputView.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// +///登录模块 自定义输入框 +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginInputView : UIView +///输入框 +@property (nonatomic,strong, readonly) UITextField *textField; +///占位的文字 +@property (nonatomic,copy) NSString *placeHolder; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/CustomView/LoginInputView.m b/xplan-ios/Main/Login/View/CustomView/LoginInputView.m new file mode 100644 index 00000000..dbda1a15 --- /dev/null +++ b/xplan-ios/Main/Login/View/CustomView/LoginInputView.m @@ -0,0 +1,96 @@ +// +// LoginInputView.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "LoginInputView.h" +///第三方 +#import +///工具类 + + +@interface LoginInputView () +///容器 +@property (nonatomic,strong) UIStackView *stackView; +///显示文本 +@property (nonatomic,strong) UILabel *titleLabel; +///输入框 +@property (nonatomic,strong) UITextField *textField; +@end + +@implementation LoginInputView + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self addSubview:self.stackView]; + + [self.stackView addArrangedSubview:self.titleLabel]; + [self.stackView addArrangedSubview:self.textField]; +} + +- (void)initSubViewConstraints { + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(50); + }]; + + [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self).offset(15); + make.right.top.bottom.mas_equalTo(self); + }]; +} + +#pragma mark - Getters And Setters +- (void)setPlaceHolder:(NSString *)placeHolder { + _placeHolder = placeHolder; + if (_placeHolder) { + self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:_placeHolder attributes:@{NSForegroundColorAttributeName: ThemeTextColor, NSFontAttributeName:[UIFont systemFontOfSize:14]}]; + } +} + +- (UIStackView *)stackView { + if (!_stackView) { + _stackView = [[UIStackView alloc] init]; + _stackView.axis = UILayoutConstraintAxisHorizontal; + _stackView.distribution = UIStackViewDistributionFill; + _stackView.alignment = UIStackViewAlignmentCenter; + _stackView.spacing = 0; + } + return _stackView; +} + +- (UILabel *)titleLabel { + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.font = [UIFont systemFontOfSize:18]; + _titleLabel.textColor = [UIColor whiteColor]; + _titleLabel.text = @"+86"; + } + return _titleLabel; +} + + +- (UITextField *)textField { + if (!_textField) { + _textField = [[UITextField alloc] init]; + _textField.textColor = [UIColor whiteColor]; + _textField.font = [UIFont systemFontOfSize:18.f]; + _textField.borderStyle = UITextBorderStyleNone; + _textField.keyboardType = UIKeyboardTypeNumberPad; + _textField.tintColor = ThemeBackgroundColor; + _textField.backgroundColor = [UIColor redColor]; + } + return _textField; +} + +@end diff --git a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h new file mode 100644 index 00000000..6c2f1058 --- /dev/null +++ b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h @@ -0,0 +1,18 @@ +// +// LoginVerifCodeView.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginVerifCodeView : UIView + +///输入的验证码 有几位 +@property (nonatomic,assign) int number; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m new file mode 100644 index 00000000..d1089431 --- /dev/null +++ b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m @@ -0,0 +1,103 @@ +// +// LoginVerifCodeView.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "LoginVerifCodeView.h" +///第三方 +#import +#import + +@interface LoginVerifCodeView () +///输入框的占位符 +@property (nonatomic,strong) UITextField *textField; +///显示label的数组 +@property (nonatomic,strong) NSMutableArray *lableArray; +@end + + +@implementation LoginVerifCodeView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + [self initEvents]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self addSubview:self.textField]; +} + +- (void)initSubViewConstraints { + [self.textField mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; +} + +- (void)initEvents { + [[self.textField rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UITextField *textField) { + NSLog(@"text%@", textField.text); + }]; +} + +- (void)configLabelArray { + CGFloat itemWidth = 45; + CGFloat itemHeight = 45; + CGFloat itemSpace = 11; + for (int i = 0; i < _number; i++) { + UILabel * label = [[UILabel alloc] init]; + label.textColor = [UIColor whiteColor]; + label.font = [UIFont systemFontOfSize:18]; + label.textAlignment = NSTextAlignmentCenter; + label.backgroundColor = UIColorFromRGB(0x2A2A39); + label.layer.masksToBounds = YES; + label.layer.cornerRadius = 10; + [self addSubview:label]; + [label mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(itemWidth, itemHeight)); + make.centerY.mas_equalTo(self); + make.left.mas_equalTo(self).offset((itemWidth + itemSpace)* i); + }]; + [self.lableArray addObject:label]; + } + + UILabel * label = [self.lableArray lastObject]; + if (label) { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(label.mas_right); + make.height.mas_equalTo(itemHeight); + }]; + } +} + +#pragma mark - Getters And Setters +- (void)setNumber:(int)number { + _number = number; + if (_number > 0) { + [self configLabelArray]; + } +} + +- (UITextField *)textField { + if (!_textField) { + _textField = [[UITextField alloc] init]; + } + return _textField; +} + +- (NSMutableArray *)lableArray { + if (!_lableArray) { + _lableArray = [NSMutableArray array]; + } + return _lableArray; +} + +@end diff --git a/xplan-ios/Main/Login/View/LoginPhoneViewController.h b/xplan-ios/Main/Login/View/LoginPhoneViewController.h new file mode 100644 index 00000000..4721007b --- /dev/null +++ b/xplan-ios/Main/Login/View/LoginPhoneViewController.h @@ -0,0 +1,16 @@ +// +// LoginPhoneViewController.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "BaseViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginPhoneViewController : BaseViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/LoginPhoneViewController.m b/xplan-ios/Main/Login/View/LoginPhoneViewController.m new file mode 100644 index 00000000..e8486f12 --- /dev/null +++ b/xplan-ios/Main/Login/View/LoginPhoneViewController.m @@ -0,0 +1,194 @@ +// +// LoginPhoneViewController.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "LoginPhoneViewController.h" +///第三方 +#import +#import +///Tool +#import "UIImage+Utils.h" +///View +#import "LoginInputView.h" +///ViewController +#import "LoginVerifCodeViewController.h" + +@interface LoginPhoneViewController () +///返回按钮 +@property (nonatomic,strong) UIButton *backButton; +///密码登录 +@property (nonatomic,strong) UIButton *passwordLoginButton; +///标题的容器 +@property (nonatomic,strong) UIStackView *titleStackView; +///标题 +@property (nonatomic,strong) UILabel *titleLabel; +///未注册手机号自定登录 +@property (nonatomic,strong) UILabel *autoLoginLabel; +///输入手机号 +@property (nonatomic,strong) LoginInputView *phoneView; +///下一步 +@property (nonatomic,strong) UIButton *nextButton; +///手机号 +@property (nonatomic,copy) NSString *phone; + +@end + +@implementation LoginPhoneViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self initSubViews]; + [self initSubViewConstraints]; + [self initEevents]; + +} +#pragma mark - Private Method +- (void)initSubViews { + [self.view addSubview:self.backButton]; + [self.view addSubview:self.passwordLoginButton]; + [self.view addSubview:self.titleStackView]; + [self.view addSubview:self.phoneView]; + [self.view addSubview:self.nextButton]; + + [self.titleStackView addArrangedSubview:self.titleLabel]; + [self.titleStackView addArrangedSubview:self.autoLoginLabel]; +} + +- (void)initSubViewConstraints { + [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(15, 15)); + make.left.mas_equalTo(self.view).offset(15); + make.top.mas_equalTo(37+ kSafeAreaTopHeight); + }]; + + [self.passwordLoginButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.view).offset(-15); + make.top.mas_equalTo(self.backButton.mas_bottom).offset(15); + }]; + + [self.titleStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self.view); + make.top.mas_equalTo(self.view).offset(140 + kSafeAreaTopHeight); + }]; + + [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view).inset(52); + make.height.mas_equalTo(45); + make.top.mas_equalTo(self.titleStackView.mas_bottom).offset(65); + }]; + + [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.height.mas_equalTo(self.phoneView); + make.top.mas_equalTo(self.phoneView.mas_bottom).offset(20); + }]; +} + +- (void)initEevents { + @weakify(self); + ///点击了返回的按钮 + [[self.backButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { + + }]; + ///点击了密码登录 + [[self.passwordLoginButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { + + }]; + + [[self.nextButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { + @strongify(self); + LoginVerifCodeViewController * codeVC = [[LoginVerifCodeViewController alloc] init]; + codeVC.phone = self.phone; + [self.navigationController pushViewController:codeVC animated:YES]; + }]; + + RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) { + @strongify(self); + self.phone = value; + return value.length ==11; + }]; +} + +#pragma mark - Getters And Setters +- (UIButton *)backButton { + if (!_backButton) { + _backButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_backButton setImage:[UIImage imageNamed:@"icon_unattention"] forState:UIControlStateNormal]; + [_backButton setImage:[UIImage imageNamed:@"icon_small_attention"] forState:UIControlStateSelected]; + } + return _backButton; +} + +- (UIButton *)passwordLoginButton { + if (!_passwordLoginButton) { + _passwordLoginButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_passwordLoginButton setTitle:@"密码登录" forState:UIControlStateNormal]; + [_passwordLoginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _passwordLoginButton.titleLabel.font = [UIFont systemFontOfSize:15]; + _passwordLoginButton.layer.masksToBounds = YES; + _passwordLoginButton.layer.cornerRadius = 10; + } + return _passwordLoginButton; +} + +- (UIStackView *)titleStackView { + if (!_titleStackView) { + _titleStackView = [[UIStackView alloc] init]; + _titleStackView.axis = UILayoutConstraintAxisVertical; + _titleStackView.distribution = UIStackViewDistributionFillEqually; + _titleStackView.alignment = UIStackViewAlignmentCenter; + _titleStackView.spacing = 10; + } + return _titleStackView; +} + +- (UILabel *)autoLoginLabel { + if (!_autoLoginLabel) { + _autoLoginLabel = [[UILabel alloc] init]; + _autoLoginLabel.text = @"未注册的手机号自动登录"; + _autoLoginLabel.textAlignment = NSTextAlignmentCenter; + _autoLoginLabel.font = [UIFont systemFontOfSize:11]; + _autoLoginLabel.textColor = [UIColor whiteColor]; + } + return _autoLoginLabel; +} + +- (UILabel *)titleLabel{ + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.font = [UIFont boldSystemFontOfSize:18]; + _titleLabel.text = @"你的手机号是多少"; + _titleLabel.textColor = [UIColor whiteColor]; + } + return _titleLabel; +} + +- (LoginInputView *)phoneView { + if (!_phoneView) { + _phoneView = [[LoginInputView alloc] init]; + _phoneView.backgroundColor = UIColorFromRGB(0x2A2A39); + _phoneView.layer.masksToBounds = YES; + _phoneView.layer.cornerRadius = 45/2; + } + return _phoneView; +} + +- (UIButton *)nextButton{ + if (!_nextButton) { + _nextButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _nextButton.layer.masksToBounds = YES; + _nextButton.layer.cornerRadius = 45/2.f; + [_nextButton setTitle:@"下一步" forState:UIControlStateNormal]; + _nextButton.titleLabel.font = [UIFont systemFontOfSize:15]; + [_nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _nextButton.enabled = NO; + UIImage *image = [UIImage gradientColorImageFromColors:@[ThemeButtonGradientStartColor,ThemeButtonGradientEndColor] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)]; + [_nextButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[ThemeTabbarNormalColor, ThemeTabbarNormalColor] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled]; + [_nextButton setBackgroundImage:image forState:UIControlStateNormal]; + } + return _nextButton; +} + +@end diff --git a/xplan-ios/Main/Login/View/LoginVerifCodeViewController.h b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.h new file mode 100644 index 00000000..5d14401c --- /dev/null +++ b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.h @@ -0,0 +1,18 @@ +// +// LoginVerifCodeViewController.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "MvpViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginVerifCodeViewController : MvpViewController + +///输入的手机号 +@property (nonatomic,copy) NSString *phone; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m new file mode 100644 index 00000000..9f74c061 --- /dev/null +++ b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m @@ -0,0 +1,185 @@ +// +// LoginVerifCodeViewController.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/8. +// + +#import "LoginVerifCodeViewController.h" +///第三方 +#import +#import +///Tool +#import "XCHUDTool.h" +///Presenter +#import "LoginPresenter.h" +///Protocole +#import "LoginProtocol.h" +///View +#import "LoginVerifCodeView.h" + +@interface LoginVerifCodeViewController () +///标题的容器 +@property (nonatomic,strong) UIStackView *titleStackView; +///标题 +@property (nonatomic,strong) UILabel *titleLabel; +///未注册手机号自定登录 +@property (nonatomic,strong) UILabel *codeSendLabel; +///输入验证码 +@property (nonatomic,strong) LoginVerifCodeView *codeView; +///重新获取验证码 和 倒计时 +@property (nonatomic,strong) UIStackView *retryStackView; +///显示倒计时 +@property (nonatomic,strong) UILabel *cutdownLabel; +///重新获得验证码 +@property (nonatomic,strong) UIButton *retryCodeButton; +@end + +@implementation LoginVerifCodeViewController + +- (void)dealloc +{ + NSLog(@"aaaaa"); +} + +- (LoginPresenter *)createPresenter { + return [[LoginPresenter alloc] init]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + [self initSubViews]; + [self initSubViewConstraints]; + [self initEvents]; + [self httpRequestPhoneSmsCode]; + +} + +#pragma mark - Private Method +- (void)initSubViews { + [self.view addSubview:self.titleStackView]; + [self.view addSubview:self.codeView]; + [self.view addSubview:self.retryStackView]; + + [self.titleStackView addArrangedSubview:self.titleLabel]; + [self.titleStackView addArrangedSubview:self.codeSendLabel]; + + [self.retryStackView addArrangedSubview:self.cutdownLabel]; + [self.retryStackView addArrangedSubview:self.retryCodeButton]; +} + +- (void)initSubViewConstraints { + [self.titleStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self.view); + make.top.mas_equalTo(self.view).offset(140 + kSafeAreaTopHeight); + }]; + + [self.codeView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.titleStackView.mas_bottom).offset(50); + make.centerX.mas_equalTo(self.view); + }]; + + [self.retryStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.codeView.mas_bottom).offset(16); + }]; +} + +- (void)initEvents { + @weakify(self); + [[[self rac_signalForSelector:@selector(phoneSmsCodeSuccess)] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(RACTuple * _Nullable x) { + @strongify(self); + self.codeSendLabel.text = [NSString stringWithFormat:@"验证码已发送至:%@", self.phone]; + }]; +} + +- (void)httpRequestPhoneSmsCode { + [self.presenter phoneSmsCode:self.phone type:1]; +} + +#pragma mark - LoginProtocol +- (void)phoneSmsCodeSuccess { + [XCHUDTool showSuccessWithMessage:@"发送成功"]; +} + +- (void)countDownFinish { + self.retryCodeButton.hidden = NO; + self.cutdownLabel.hidden = YES; +} + +- (void)countDownWithCurrent:(int)current { + self.cutdownLabel.text = [NSString stringWithFormat:@"%ds 后重新获取验证码", current]; + self.retryCodeButton.hidden = YES; + self.cutdownLabel.hidden = NO; +} + +#pragma mark - Getters And Setters +- (UIStackView *)titleStackView { + if (!_titleStackView) { + _titleStackView = [[UIStackView alloc] init]; + _titleStackView.axis = UILayoutConstraintAxisVertical; + _titleStackView.distribution = UIStackViewDistributionFillEqually; + _titleStackView.alignment = UIStackViewAlignmentCenter; + _titleStackView.spacing = 10; + } + return _titleStackView; +} + +- (UILabel *)codeSendLabel { + if (!_codeSendLabel) { + _codeSendLabel = [[UILabel alloc] init]; + _codeSendLabel.textAlignment = NSTextAlignmentCenter; + _codeSendLabel.font = [UIFont systemFontOfSize:11]; + _codeSendLabel.textColor = [UIColor whiteColor]; + } + return _codeSendLabel; +} + +- (UILabel *)titleLabel{ + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.font = [UIFont boldSystemFontOfSize:18]; + _titleLabel.text = @"填写验证码"; + _titleLabel.textColor = [UIColor whiteColor]; + } + return _titleLabel; +} + +- (LoginVerifCodeView *)codeView { + if (!_codeView) { + _codeView= [[LoginVerifCodeView alloc] init]; + _codeView.number = 5; + } + return _codeView; +} + +- (UIStackView *)retryStackView { + if (!_retryStackView) { + _retryStackView = [[UIStackView alloc] init]; + _retryStackView.axis = UILayoutConstraintAxisVertical; + _retryStackView.distribution = UIStackViewDistributionFill; + _retryStackView.alignment = UIStackViewAlignmentCenter; + _retryStackView.spacing = 0; + } + return _retryStackView; +} + +- (UILabel *)cutdownLabel { + if (!_cutdownLabel) { + _cutdownLabel = [[UILabel alloc] init]; + _cutdownLabel.textAlignment = NSTextAlignmentCenter; + _cutdownLabel.hidden = NO; + } + return _cutdownLabel; +} + +- (UIButton *)retryCodeButton { + if (!_retryCodeButton) { + _retryCodeButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_retryCodeButton setTitle:@"重新获取验证码" forState:UIControlStateNormal]; + [_retryCodeButton setTitleColor:ThemeDefaultColor forState:UIControlStateNormal]; + _retryCodeButton.titleLabel.font = [UIFont systemFontOfSize:11]; + _retryCodeButton.hidden = YES; + } + return _retryCodeButton; +} +@end diff --git a/xplan-ios/Main/Login/View/LoginViewController.m b/xplan-ios/Main/Login/View/LoginViewController.m index e4e95738..d236e5dd 100644 --- a/xplan-ios/Main/Login/View/LoginViewController.m +++ b/xplan-ios/Main/Login/View/LoginViewController.m @@ -15,6 +15,7 @@ #import #import #import +#import "LoginPhoneViewController.h" // 易盾 本机一键登录 #ifdef DEBUG @@ -277,8 +278,8 @@ typedef NS_ENUM(NSInteger,XYThirdLoginType) { UIView * view = tap.view; if (self.agreeButton.isSelected) { if ([view isEqual:self.phoneButtonView]) { - // InputPhoneLoginViewController *inputPhoneVC = [[InputPhoneLoginViewController alloc] init]; - // [self.navigationController pushViewController:inputPhoneVC animated:YES]; + LoginPhoneViewController *inputPhoneVC = [[LoginPhoneViewController alloc] init]; + [self.navigationController pushViewController:inputPhoneVC animated:YES]; } else if([view isEqual:self.qqButtonView]) { [XCHUDTool showLoading]; // [GetCore(AuthCore) thirdLoginPlatform:SSDKPlatformTypeQQ];