手机验证码登录部分逻辑完善
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
///工具类
|
///工具类
|
||||||
|
|
||||||
|
|
||||||
@interface LoginInputView ()
|
@interface LoginInputView () <UITextFieldDelegate>
|
||||||
///容器
|
///容器
|
||||||
@property (nonatomic,strong) UIStackView *stackView;
|
@property (nonatomic,strong) UIStackView *stackView;
|
||||||
///显示文本
|
///显示文本
|
||||||
@@ -87,10 +87,19 @@
|
|||||||
_textField.font = [UIFont systemFontOfSize:18.f];
|
_textField.font = [UIFont systemFontOfSize:18.f];
|
||||||
_textField.borderStyle = UITextBorderStyleNone;
|
_textField.borderStyle = UITextBorderStyleNone;
|
||||||
_textField.keyboardType = UIKeyboardTypeNumberPad;
|
_textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||||
_textField.tintColor = ThemeBackgroundColor;
|
_textField.tintColor = ThemeDefaultColor;
|
||||||
_textField.backgroundColor = [UIColor clearColor];
|
_textField.backgroundColor = [UIColor clearColor];
|
||||||
|
_textField.delegate = self;
|
||||||
}
|
}
|
||||||
return _textField;
|
return _textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
||||||
|
return textField.text.length <= 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)textFieldDidChangeSelection:(UITextField *)textField {
|
||||||
|
textField.text = [textField.text substringToIndex:MIN(textField.text.length, 11)];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -54,8 +54,6 @@
|
|||||||
if (textField.text.length > self.lableArray.count) {
|
if (textField.text.length > self.lableArray.count) {
|
||||||
textField.text = [textField.text substringToIndex:self.lableArray.count];
|
textField.text = [textField.text substringToIndex:self.lableArray.count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (textField.text.length >= 5) {
|
if (textField.text.length >= 5) {
|
||||||
[textField resignFirstResponder];
|
[textField resignFirstResponder];
|
||||||
@@ -64,8 +62,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (UILabel *pwLab in self.lableArray) {
|
for (UILabel *pwLab in self.lableArray) {
|
||||||
if (pwLab.tag < (100 + textField.text.length)) {
|
if (pwLab.tag < (100 + textField.text.length)) {
|
||||||
NSRange range = NSMakeRange(pwLab.tag-100, 1);
|
NSRange range = NSMakeRange(pwLab.tag-100, 1);
|
||||||
@@ -119,6 +115,7 @@
|
|||||||
if (!_textField) {
|
if (!_textField) {
|
||||||
_textField = [[UITextField alloc] init];
|
_textField = [[UITextField alloc] init];
|
||||||
_textField.tintColor = [UIColor clearColor];
|
_textField.tintColor = [UIColor clearColor];
|
||||||
|
_textField.textColor = [UIColor clearColor];
|
||||||
_textField.keyboardType = UIKeyboardTypeNumberPad;
|
_textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||||
[_textField becomeFirstResponder];
|
[_textField becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,8 @@
|
|||||||
RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) {
|
RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) {
|
||||||
@strongify(self);
|
@strongify(self);
|
||||||
self.phone = value;
|
self.phone = value;
|
||||||
return value.length ==11;
|
self.nextButton.enabled = value.length == 11;
|
||||||
|
return value.length == 11;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,6 +76,7 @@
|
|||||||
|
|
||||||
[self.retryStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.retryStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.top.mas_equalTo(self.codeView.mas_bottom).offset(16);
|
make.top.mas_equalTo(self.codeView.mas_bottom).offset(16);
|
||||||
|
make.centerX.mas_equalTo(self.view);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +84,15 @@
|
|||||||
@weakify(self);
|
@weakify(self);
|
||||||
[[[self rac_signalForSelector:@selector(phoneSmsCodeSuccess)] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(RACTuple * _Nullable x) {
|
[[[self rac_signalForSelector:@selector(phoneSmsCodeSuccess)] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(RACTuple * _Nullable x) {
|
||||||
@strongify(self);
|
@strongify(self);
|
||||||
self.codeSendLabel.text = [NSString stringWithFormat:@"验证码已发送至:%@", self.phone];
|
self.codeSendLabel.text = [NSString stringWithFormat:@"验证码已发送至:%@", self.phone];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
self.codeView.textFieldChangeBlock = ^(NSString * _Nonnull smsCode) {
|
||||||
|
if (self.phone.length > 0 && smsCode.length == 5) {
|
||||||
|
@strongify(self);
|
||||||
|
[self.presenter loginWithPhone:self.phone code:smsCode];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)httpRequestPhoneSmsCode {
|
- (void)httpRequestPhoneSmsCode {
|
||||||
@@ -108,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)loginSuccess {
|
- (void)loginSuccess {
|
||||||
[XCHUDTool showSuccessWithMessage:@"登录成功"];
|
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
@@ -166,6 +174,8 @@
|
|||||||
if (!_cutdownLabel) {
|
if (!_cutdownLabel) {
|
||||||
_cutdownLabel = [[UILabel alloc] init];
|
_cutdownLabel = [[UILabel alloc] init];
|
||||||
_cutdownLabel.textAlignment = NSTextAlignmentCenter;
|
_cutdownLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
|
_cutdownLabel.font = [UIFont boldSystemFontOfSize:11];
|
||||||
|
_cutdownLabel.textColor = ThemeTextColor;
|
||||||
_cutdownLabel.hidden = NO;
|
_cutdownLabel.hidden = NO;
|
||||||
}
|
}
|
||||||
return _cutdownLabel;
|
return _cutdownLabel;
|
||||||
|
Reference in New Issue
Block a user