手机验证码登录部分逻辑完善
This commit is contained in:
@@ -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
|
||||
|
@@ -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];
|
||||
}
|
||||
|
@@ -95,6 +95,7 @@
|
||||
RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) {
|
||||
@strongify(self);
|
||||
self.phone = value;
|
||||
self.nextButton.enabled = value.length == 11;
|
||||
return value.length == 11;
|
||||
}];
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user