230 lines
6.6 KiB
Objective-C
230 lines
6.6 KiB
Objective-C
//
|
|
// YMMinePayPwdViewController.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/9/18.
|
|
//
|
|
|
|
#import "XPMinePayPwdViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
///Tool
|
|
#import "UIImage+Utils.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "CountDownHelper.h"
|
|
///Model
|
|
#import "UserInfoModel.h"
|
|
///View
|
|
#import "XPMineModifPayPwdView.h"
|
|
#import "XPMineSettingViewController.h"
|
|
///P
|
|
#import "XPMinePayPwdPresenter.h"
|
|
#import "XPMinePayPwdProtocol.h"
|
|
|
|
@interface XPMinePayPwdViewController ()<XPMinePayPwdProtocol>
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///设置支付密码
|
|
@property (nonatomic, strong) XPMineModifPayPwdView *pwdInputView;
|
|
///再次输入支付密码
|
|
@property (nonatomic, strong) XPMineModifPayPwdView *repeatPwdInputView;
|
|
/////请输入验证码
|
|
//@property (nonatomic, strong) XPMinePayPwdInputView *verificationCodeInputView;
|
|
///提交按钮
|
|
@property (nonatomic, strong) UIButton *submitButton;
|
|
@property (nonatomic, strong) UILabel *tipsLabel;
|
|
@end
|
|
|
|
@implementation XPMinePayPwdViewController
|
|
|
|
- (void)dealloc {
|
|
|
|
}
|
|
|
|
- (XPMinePayPwdPresenter *)createPresenter {
|
|
return [[XPMinePayPwdPresenter alloc] init];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubviews];
|
|
|
|
self.title = YMLocalizedString(@"XPMinePayPwdViewController0");
|
|
|
|
|
|
}
|
|
|
|
- (void)initSubviews {
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
[self.view addSubview:self.stackView];
|
|
[self.view addSubview:self.submitButton];
|
|
[self.stackView addArrangedSubview:self.pwdInputView];
|
|
[self.stackView addArrangedSubview:self.repeatPwdInputView];
|
|
|
|
|
|
|
|
[self makeConstriants];
|
|
}
|
|
|
|
- (void)makeConstriants {
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(30);
|
|
make.leading.trailing.mas_equalTo(self.view);
|
|
}];
|
|
|
|
|
|
[self.submitButton 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)setPayPasswordSuccess {
|
|
NSString *message = YMLocalizedString(@"XPMinePayPwdViewController3");
|
|
[self showSuccessToast:message];
|
|
if(self.delegate && [self.delegate respondsToSelector:@selector(payPasswordSuccess)]){
|
|
[self.delegate payPasswordSuccess];
|
|
}
|
|
@weakify(self)
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
@strongify(self)
|
|
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
|
|
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
|
[self.view endEditing:YES];
|
|
}
|
|
|
|
- (void)onClickSubmitButton {
|
|
[self.view endEditing:YES];
|
|
NSString *pwd = self.pwdInputView.contentTextField.text;
|
|
NSString *repeatPwd = self.repeatPwdInputView.contentTextField.text;
|
|
//
|
|
//
|
|
// // 位数校验
|
|
if (pwd.length != 6) {
|
|
NSString *msg = YMLocalizedString(@"XPMinePayPwdViewController4");
|
|
[self showErrorToast:msg];
|
|
return;
|
|
}
|
|
//
|
|
// // 纯数字校验
|
|
if (![self isPureNum:pwd]) {
|
|
NSString *msg = YMLocalizedString(@"XPMinePayPwdViewController5");
|
|
[self showErrorToast:msg];
|
|
return;
|
|
}
|
|
//
|
|
// // 重复密码校验
|
|
if (![pwd isEqualToString:repeatPwd]) {
|
|
[self showErrorToast:YMLocalizedString(@"XPMinePayPwdViewController6")];
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//设置密码
|
|
[self.presenter setPayPassword:pwd ];
|
|
}
|
|
|
|
#pragma mark - Private
|
|
/** 判断一个字符串是纯数字 */
|
|
- (BOOL)isPureNum:(NSString *)text {
|
|
if (!text) {
|
|
return NO;
|
|
}
|
|
|
|
NSScanner *scan = [NSScanner scannerWithString:text];
|
|
int val;
|
|
return [scan scanInt:&val] && [scan isAtEnd];
|
|
}
|
|
|
|
- (NSString *)phoneNumber {
|
|
return self.userInfo.phone;
|
|
}
|
|
|
|
#pragma mark - Getter && Setter
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
_stackView.spacing = 25;
|
|
}
|
|
return _stackView;
|
|
}
|
|
- (XPMineModifPayPwdView *)pwdInputView {
|
|
if (!_pwdInputView) {
|
|
_pwdInputView = [[XPMineModifPayPwdView alloc] init];
|
|
_pwdInputView.placeholder = YMLocalizedString(@"XPMinePayPwdViewController10");
|
|
_pwdInputView.contentTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
}
|
|
return _pwdInputView;
|
|
}
|
|
|
|
- (XPMineModifPayPwdView *)repeatPwdInputView {
|
|
if (!_repeatPwdInputView) {
|
|
_repeatPwdInputView = [[XPMineModifPayPwdView alloc] init];
|
|
_repeatPwdInputView.placeholder = YMLocalizedString(@"XPMinePayPwdViewController11");
|
|
_repeatPwdInputView.contentTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
|
}
|
|
return _repeatPwdInputView;
|
|
}
|
|
|
|
|
|
|
|
- (UIButton *)submitButton {
|
|
if (!_submitButton) {
|
|
_submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_submitButton setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
|
|
[_submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[_submitButton setTitle:YMLocalizedString(@"XPAnchorAudienceUpMicView2") forState:UIControlStateNormal];
|
|
_submitButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
|
|
_submitButton.layer.masksToBounds = YES;
|
|
_submitButton.layer.cornerRadius = 45/2;
|
|
_submitButton.enabled = YES;
|
|
[_submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
|
[_submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
|
[_submitButton addTarget:self action:@selector(onClickSubmitButton) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _submitButton;
|
|
}
|
|
|
|
- (UILabel *)tipsLabel {
|
|
if (!_tipsLabel) {
|
|
_tipsLabel = [[UILabel alloc] init];
|
|
_tipsLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
_tipsLabel.font = [UIFont systemFontOfSize:13];
|
|
_tipsLabel.numberOfLines = 0;
|
|
_tipsLabel.hidden = YES;
|
|
NSString *phonePrefix = [[self phoneNumber] substringToIndex:3];
|
|
NSString *phoneSuffix = [[self phoneNumber] substringFromIndex:7];
|
|
_tipsLabel.text = [NSString stringWithFormat:YMLocalizedString(@"XPMinePayPwdViewController9"), phonePrefix, phoneSuffix];
|
|
}
|
|
return _tipsLabel;
|
|
}
|
|
|
|
|
|
@end
|