178 lines
6.8 KiB
Objective-C
178 lines
6.8 KiB
Objective-C
//
|
|
// XPMineVerifIdentityViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/18.
|
|
//
|
|
|
|
#import "XPMineVerifIdentityViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
///Tool
|
|
|
|
#import "CountDownHelper.h"
|
|
#import "UIImage+Utils.h"
|
|
///Model
|
|
#import "UserInfoModel.h"
|
|
///View
|
|
#import "XPMineVerifIdentityView.h"
|
|
///P
|
|
#import "XPMineVerifIdentityPresenter.h"
|
|
#import "XPMineVerifIdentityProtocol.h"
|
|
///VC
|
|
#import "XPMineResetPayPwdViewController.h"
|
|
|
|
@interface XPMineVerifIdentityViewController ()<XPMineVerifIdentityProtocol, CountDownHelperDelegate>
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///手机号
|
|
@property (nonatomic,strong) XPMineVerifIdentityView *phoneView;
|
|
///验证码
|
|
@property (nonatomic,strong) XPMineVerifIdentityView *smsCodeView;
|
|
///下一步
|
|
@property (nonatomic,strong) UIButton *nextButton;
|
|
@end
|
|
|
|
@implementation XPMineVerifIdentityViewController
|
|
- (void)dealloc {
|
|
[[CountDownHelper shareHelper] stopCountDown];
|
|
}
|
|
- (XPMineVerifIdentityPresenter *)createPresenter {
|
|
return [[XPMineVerifIdentityPresenter alloc] init];;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self initEvents];
|
|
}
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated {
|
|
[super viewDidDisappear:animated];
|
|
[[CountDownHelper shareHelper] stopCountDown];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.title = YMLocalizedString(@"XPMineVerifIdentityViewController0");
|
|
self.phoneView.contentTextField.text = self.userInfo.phone;
|
|
self.phoneView.contentTextField.enabled = self.userInfo.phone.length > 0;
|
|
[CountDownHelper shareHelper].delegate = self;
|
|
[self.view addSubview:self.stackView];
|
|
[self.view addSubview:self.nextButton];
|
|
|
|
[self.stackView addArrangedSubview:self.phoneView];
|
|
[self.stackView addArrangedSubview:self.smsCodeView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.top.mas_equalTo(self.view);
|
|
}];
|
|
|
|
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.stackView.mas_bottom).offset(45);
|
|
make.trailing.mas_equalTo(self.view).offset(-32);
|
|
make.leading.mas_equalTo(self.view).offset(32);
|
|
make.height.mas_equalTo(45);
|
|
}];
|
|
}
|
|
|
|
- (void)initEvents {
|
|
@weakify(self);
|
|
RAC(self.nextButton, enabled) = [RACSignal combineLatest:@[self.phoneView.contentTextField.rac_textSignal, self.smsCodeView.contentTextField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString * code){
|
|
return @(phone.length > 0 && code.length > 0);
|
|
}];
|
|
|
|
self.smsCodeView.smsCodeBlock = ^(UIButton * _Nonnull sender) {
|
|
@strongify(self);
|
|
if (self.phoneView.contentTextField.text.length > 0) {
|
|
[self.presenter phoneSmsCode:self.phoneView.contentTextField.text type:GetSmsType_Unbind_Phone phoneAreaCode:@""];
|
|
} else {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineVerifIdentityViewController1")];
|
|
}
|
|
};
|
|
}
|
|
#pragma mark - XPMineVerifIdentityProtocol
|
|
- (void)phoneSmsCodeSuccess {
|
|
self.smsCodeView.smsCodeButton.enabled = NO;
|
|
[self showSuccessToast:YMLocalizedString(@"XPMineVerifIdentityViewController2")];
|
|
[[CountDownHelper shareHelper] openCountdownWithTime:60];
|
|
}
|
|
|
|
- (void)checkMoblieCodeWithMoblieSuccess {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineVerifIdentityViewController3")];
|
|
[[CountDownHelper shareHelper] stopCountDown];
|
|
XPMineResetPayPwdViewController * vc = [[XPMineResetPayPwdViewController alloc] init];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
|
|
#pragma mark - CountDownHelperDelegate
|
|
///倒计时进行中
|
|
- (void)onCountdownOpen:(int)time {
|
|
[self.smsCodeView.smsCodeButton setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPMineVerifIdentityViewController4"), time] forState:UIControlStateDisabled];
|
|
}
|
|
///倒计时结束
|
|
- (void)onCountdownFinish {
|
|
self.smsCodeView.smsCodeButton.enabled= YES;
|
|
[self.smsCodeView.smsCodeButton setTitle:YMLocalizedString(@"XPMineVerifIdentityViewController5") forState:UIControlStateNormal];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)nextButtonAction:(UIButton *)sender {
|
|
[self.presenter checkMoblieCodeWithMoblie:self.phoneView.contentTextField.text code:self.smsCodeView.contentTextField.text phoneAreaCode:@""];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIButton *)nextButton {
|
|
if (!_nextButton) {
|
|
_nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_nextButton setTitleColor:[DJDKMIMOMColor confirmButtonTextColor] forState:UIControlStateNormal];
|
|
[_nextButton setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
|
|
[_nextButton setTitle:YMLocalizedString(@"XPMineVerifIdentityViewController6") forState:UIControlStateNormal];
|
|
_nextButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
|
_nextButton.layer.masksToBounds = YES;
|
|
_nextButton.layer.cornerRadius = 45/2;
|
|
_nextButton.enabled = NO;
|
|
[_nextButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
|
[_nextButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
|
[_nextButton addTarget:self action:@selector(nextButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _nextButton;
|
|
}
|
|
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
_stackView.spacing = 0;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (XPMineVerifIdentityView *)phoneView {
|
|
if (!_phoneView) {
|
|
_phoneView = [[XPMineVerifIdentityView alloc] init];
|
|
_phoneView.type = XPMineVerifIdentityType_Phone;
|
|
_phoneView.placeholder = YMLocalizedString(@"XPMineVerifIdentityViewController7");
|
|
_phoneView.contentTextField.secureTextEntry = NO;
|
|
}
|
|
return _phoneView;
|
|
}
|
|
|
|
- (XPMineVerifIdentityView *)smsCodeView {
|
|
if (!_smsCodeView) {
|
|
_smsCodeView = [[XPMineVerifIdentityView alloc] init];
|
|
_smsCodeView.type = XPMineVerifIdentityType_Sms;
|
|
_smsCodeView.placeholder = YMLocalizedString(@"XPMineVerifIdentityViewController8");
|
|
_smsCodeView.contentTextField.secureTextEntry = NO;
|
|
}
|
|
return _smsCodeView;
|
|
}
|
|
|
|
@end
|