211 lines
8.0 KiB
Objective-C
211 lines
8.0 KiB
Objective-C
//
|
|
// XPMineModifPayPwdViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/18.
|
|
//
|
|
|
|
#import "XPMineModifPayPwdViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
///Tool
|
|
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
#import "UIImage+Utils.h"
|
|
///View
|
|
#import "XPMineModifPayPwdView.h"
|
|
///P
|
|
#import "XPMineModifPayPwdPresenter.h"
|
|
#import "XPMineModifPayProtocol.h"
|
|
///VC
|
|
#import "XPMineSettingViewController.h"
|
|
|
|
@interface XPMineModifPayPwdViewController ()<XPMineModifPayProtocol>
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///当前的密码
|
|
@property (nonatomic,strong) XPMineModifPayPwdView *currentPwdView;
|
|
///新密码
|
|
@property (nonatomic,strong) XPMineModifPayPwdView *newsPwdView;
|
|
///检查密码
|
|
@property (nonatomic,strong) XPMineModifPayPwdView *checkPwdView;
|
|
///忘记密码
|
|
@property (nonatomic, strong) UIButton *forgetBtn;
|
|
///提交
|
|
@property (nonatomic, strong) UIButton *submitBtn;
|
|
@end
|
|
|
|
@implementation XPMineModifPayPwdViewController
|
|
|
|
- (XPMineModifPayPwdPresenter *)createPresenter {
|
|
return [[XPMineModifPayPwdPresenter alloc] init];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self initEvents];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
self.title = YMLocalizedString(@"XPMineModifPayPwdViewController0");
|
|
[self.view addSubview:self.stackView];
|
|
[self.view addSubview:self.forgetBtn];
|
|
[self.view addSubview:self.submitBtn];
|
|
[self.stackView addArrangedSubview:self.currentPwdView];
|
|
[self.stackView addArrangedSubview:self.newsPwdView];
|
|
[self.stackView addArrangedSubview:self.checkPwdView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(30);
|
|
make.leading.trailing.mas_equalTo(self.view);
|
|
}];
|
|
|
|
[self.forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(self.view).offset(-32);
|
|
make.top.mas_equalTo(self.stackView.mas_bottom).offset(8);
|
|
}];
|
|
[self.submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(275);
|
|
make.trailing.mas_equalTo(self.view).offset(-15);
|
|
make.leading.mas_equalTo(self.view).offset(15);
|
|
make.height.mas_equalTo(46);
|
|
}];
|
|
}
|
|
|
|
- (void)initEvents {
|
|
RAC(self.submitBtn, enabled) = [RACSignal combineLatest:@[self.currentPwdView.contentTextField.rac_textSignal, self.newsPwdView.contentTextField.rac_textSignal, self.checkPwdView.contentTextField.rac_textSignal] reduce:^id _Nonnull(NSString *currentPassword, NSString *newsPassword, NSString *checkPassword){
|
|
return @(currentPassword.length == 6 && newsPassword.length == 6 && checkPassword.length == 6);
|
|
}];
|
|
}
|
|
///判断一个字符串是纯数字
|
|
- (BOOL)isPureNum:(NSString *)text {
|
|
if (!text) {
|
|
return NO;
|
|
}
|
|
NSScanner *scan = [NSScanner scannerWithString:text];
|
|
int val;
|
|
return [scan scanInt:&val] && [scan isAtEnd];
|
|
}
|
|
|
|
|
|
#pragma mark - XPMineModifPayProtocol
|
|
- (void)modifPayPasswordSuccess {
|
|
[self showSuccessToast:YMLocalizedString(@"XPMineModifPayPwdViewController1")];
|
|
for (UIViewController *VC in self.navigationController.viewControllers) {
|
|
if ([VC isKindOfClass:[XPMineSettingViewController class]]) {
|
|
[self.navigationController popToViewController:VC animated:YES];
|
|
return;
|
|
}
|
|
}
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)forgetBtnAction:(UIButton *)sender {
|
|
|
|
TTAlertConfig * config = [[TTAlertConfig alloc] init];
|
|
config.title = YMLocalizedString(@"PKIDLoginViewController2");
|
|
config.message = YMLocalizedString(@"PKIDLoginViewController3");
|
|
config.actionStyle = TTAlertActionConfirmStyle;
|
|
config.confirmButtonConfig.title = YMLocalizedString(@"PKIDLoginViewController4");
|
|
[TTPopup alertWithConfig:config confirmHandler:^{
|
|
|
|
} cancelHandler:^{
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
- (void)submitBtnAction:(UIButton *)sender {
|
|
if (![self.newsPwdView.contentTextField.text isEqual:self.checkPwdView.contentTextField.text]) {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineModifPayPwdViewController2")];
|
|
return;
|
|
}
|
|
|
|
if (![self isPureNum:self.checkPwdView.contentTextField.text] || ![self isPureNum:self.newsPwdView.contentTextField.text]) {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineModifPayPwdViewController3")];
|
|
return;
|
|
}
|
|
|
|
[self.presenter modifyPaymentPasswordWitholdPassword:self.currentPwdView.contentTextField.text newPassword:self.newsPwdView.contentTextField.text];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
_stackView.spacing = 25;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (XPMineModifPayPwdView *)currentPwdView {
|
|
if (!_currentPwdView) {
|
|
_currentPwdView = [[XPMineModifPayPwdView alloc] init];
|
|
_currentPwdView.placeholder = YMLocalizedString(@"XPMineModifPayPwdViewController4");
|
|
_currentPwdView.contentTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
}
|
|
return _currentPwdView;
|
|
}
|
|
|
|
- (XPMineModifPayPwdView *)newsPwdView {
|
|
if (!_newsPwdView) {
|
|
_newsPwdView = [[XPMineModifPayPwdView alloc] init];
|
|
_newsPwdView.placeholder = YMLocalizedString(@"XPMineModifPayPwdViewController5");
|
|
_newsPwdView.contentTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
}
|
|
return _newsPwdView;
|
|
}
|
|
|
|
- (XPMineModifPayPwdView *)checkPwdView {
|
|
if (!_checkPwdView) {
|
|
_checkPwdView = [[XPMineModifPayPwdView alloc] init];
|
|
_checkPwdView.placeholder = YMLocalizedString(@"XPMineModifPayPwdViewController6");
|
|
_checkPwdView.contentTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
}
|
|
return _checkPwdView;
|
|
}
|
|
|
|
- (UIButton *)submitBtn {
|
|
if (!_submitBtn) {
|
|
_submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_submitBtn setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
|
|
[_submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[_submitBtn setTitle:YMLocalizedString(@"XPMineModifPayPwdViewController7") forState:UIControlStateNormal];
|
|
_submitBtn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
|
|
_submitBtn.layer.masksToBounds = YES;
|
|
_submitBtn.layer.cornerRadius = 45/2;
|
|
_submitBtn.enabled = YES;
|
|
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
|
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
|
[_submitBtn addTarget:self action:@selector(submitBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _submitBtn;
|
|
}
|
|
|
|
- (UIButton *)forgetBtn {
|
|
if (!_forgetBtn) {
|
|
_forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_forgetBtn setEnlargeEdgeWithTop:5 right:5 bottom:5 left:5];
|
|
[_forgetBtn setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal];
|
|
[_forgetBtn setTitle:YMLocalizedString(@"XPMineModifPayPwdViewController8") forState:UIControlStateNormal];
|
|
_forgetBtn.titleLabel.font = [UIFont systemFontOfSize:13];
|
|
[_forgetBtn addTarget:self action:@selector(forgetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _forgetBtn;
|
|
}
|
|
|
|
@end
|