手机验证码登录部分逻辑完善

This commit is contained in:
zu
2021-09-09 20:38:51 +08:00
parent 9574a71282
commit 8a4cfc2eb5
4 changed files with 26 additions and 9 deletions

View File

@@ -11,7 +11,7 @@
///
@interface LoginInputView ()
@interface LoginInputView () <UITextFieldDelegate>
///
@property (nonatomic,strong) UIStackView *stackView;
///
@@ -87,10 +87,19 @@
_textField.font = [UIFont systemFontOfSize:18.f];
_textField.borderStyle = UITextBorderStyleNone;
_textField.keyboardType = UIKeyboardTypeNumberPad;
_textField.tintColor = ThemeBackgroundColor;
_textField.tintColor = ThemeDefaultColor;
_textField.backgroundColor = [UIColor clearColor];
_textField.delegate = self;
}
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

View File

@@ -55,8 +55,6 @@
textField.text = [textField.text substringToIndex:self.lableArray.count];
}
if (textField.text.length >= 5) {
[textField resignFirstResponder];
if (_textFieldChangeBlock) {
@@ -64,8 +62,6 @@
}
}
for (UILabel *pwLab in self.lableArray) {
if (pwLab.tag < (100 + textField.text.length)) {
NSRange range = NSMakeRange(pwLab.tag-100, 1);
@@ -119,6 +115,7 @@
if (!_textField) {
_textField = [[UITextField alloc] init];
_textField.tintColor = [UIColor clearColor];
_textField.textColor = [UIColor clearColor];
_textField.keyboardType = UIKeyboardTypeNumberPad;
[_textField becomeFirstResponder];
}

View File

@@ -95,7 +95,8 @@
RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) {
@strongify(self);
self.phone = value;
return value.length ==11;
self.nextButton.enabled = value.length == 11;
return value.length == 11;
}];
}

View File

@@ -76,6 +76,7 @@
[self.retryStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.codeView.mas_bottom).offset(16);
make.centerX.mas_equalTo(self.view);
}];
}
@@ -83,8 +84,15 @@
@weakify(self);
[[[self rac_signalForSelector:@selector(phoneSmsCodeSuccess)] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(RACTuple * _Nullable x) {
@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 {
@@ -108,7 +116,7 @@
}
- (void)loginSuccess {
[XCHUDTool showSuccessWithMessage:@"登录成功"];
[self.navigationController popToRootViewControllerAnimated:NO];
}
#pragma mark - Getters And Setters
@@ -166,6 +174,8 @@
if (!_cutdownLabel) {
_cutdownLabel = [[UILabel alloc] init];
_cutdownLabel.textAlignment = NSTextAlignmentCenter;
_cutdownLabel.font = [UIFont boldSystemFontOfSize:11];
_cutdownLabel.textColor = ThemeTextColor;
_cutdownLabel.hidden = NO;
}
return _cutdownLabel;