190 lines
9.7 KiB
Objective-C
190 lines
9.7 KiB
Objective-C
//
|
|
// QXForgotPwdViewController.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/7.
|
|
//
|
|
|
|
#import "QXForgotPwdViewController.h"
|
|
#import "QXLoginTextField.h"
|
|
#import "UIButton+QX.h"
|
|
#import "QXLoginNetwork.h"
|
|
@interface QXForgotPwdViewController ()<QXLoginTextFieldDelegate>
|
|
@property (nonatomic,strong)UILabel *titleLabel;
|
|
@property (nonatomic,strong)UIButton *backBtn;
|
|
@property (nonatomic,strong)UIButton *firstBtn;
|
|
@property (nonatomic,strong)UIButton *secondBtn;
|
|
@property (nonatomic,strong)UIView *topView;
|
|
|
|
@property (nonatomic,strong)UIImageView *forgotImageView;
|
|
@property (nonatomic,strong)UIScrollView *scrollView;
|
|
@property (nonatomic,strong)QXLoginTextField *accountTextField;
|
|
@property (nonatomic,strong)QXLoginTextField *codeTextField;
|
|
@property (nonatomic,strong)QXLoginTextField *passwordTextField;
|
|
@property (nonatomic,strong)QXLoginTextField *repasswordTextField;
|
|
@property (nonatomic,strong)UIButton *firstCommitBtn;
|
|
@property (nonatomic,strong)UIButton *secondCommitBtn;
|
|
@end
|
|
|
|
@implementation QXForgotPwdViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
|
|
- (void)initSubViews{
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, kSafeAreaTop, SCREEN_WIDTH-140, 40)];
|
|
self.titleLabel.text = QXText(@"忘记密码");
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
|
|
self.titleLabel.textColor = RGB16(0x333333);
|
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self.view addSubview:self.titleLabel];
|
|
|
|
self.backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, kSafeAreaTop, 40, 40)];
|
|
[self.backBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
|
|
[self.backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.view addSubview:self.backBtn];
|
|
|
|
// self.topView = [[UIView alloc] initWithFrame:CGRectMake(16, NavContentHeight+5, SCREEN_WIDTH-32, 70)];
|
|
// self.topView.backgroundColor = [UIColor whiteColor];
|
|
// [self.topView addRoundedCornersWithRadius:9];
|
|
// [self.view addSubview:self.topView];
|
|
//
|
|
// self.firstBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.topView.width/2, self.topView.height)];
|
|
// [self.firstBtn setImage:[UIImage imageNamed:@"forgot_first_nor"] forState:(UIControlStateNormal)];
|
|
// [self.firstBtn setImage:[UIImage imageNamed:@"forgot_first_sel"] forState:(UIControlStateSelected)];
|
|
// [self.firstBtn setTitle:QXText(@"验证手机号") forState:(UIControlStateNormal)];
|
|
// self.firstBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
// [self.firstBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateSelected)];
|
|
// [self.firstBtn setTitleColor:RGB16(0x949494) forState:(UIControlStateNormal)];
|
|
// self.firstBtn.userInteractionEnabled = NO;
|
|
// [self.firstBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleTop) imageTitleSpace:9];
|
|
// self.firstBtn.selected = YES;
|
|
// [self.topView addSubview:self.firstBtn];
|
|
//
|
|
// UIView *line = [[UIView alloc] initWithFrame:CGRectMake((self.topView.width-74)/2, 19, 74, 1.5)];
|
|
// line.backgroundColor = RGB16(0x949494);
|
|
// [self.topView addSubview:line];
|
|
//
|
|
// self.secondBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.firstBtn.right, 0, self.topView.width/2, self.topView.height)];
|
|
// [self.secondBtn setImage:[UIImage imageNamed:@"forgot_second_nor"] forState:(UIControlStateNormal)];
|
|
// [self.secondBtn setImage:[UIImage imageNamed:@"forgot_second_sel"] forState:(UIControlStateSelected)];
|
|
// [self.secondBtn setTitle:QXText(@"设置新密码") forState:(UIControlStateNormal)];
|
|
// self.secondBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
// [self.secondBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateSelected)];
|
|
// [self.secondBtn setTitleColor:RGB16(0x949494) forState:(UIControlStateNormal)];
|
|
// self.secondBtn.userInteractionEnabled = NO;
|
|
// [self.secondBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleTop) imageTitleSpace:9];
|
|
// [self.topView addSubview:self.secondBtn];
|
|
|
|
// self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, self.topView.bottom+17, SCREEN_WIDTH, SCREEN_HEIGHT-self.topView.bottom)];
|
|
// self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2, self.scrollView.height);
|
|
// self.scrollView.scrollEnabled = NO;
|
|
// self.scrollView.backgroundColor = [UIColor clearColor];
|
|
// [self.view addSubview:self.scrollView];
|
|
// forgot_pwd
|
|
|
|
self.forgotImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"forgot_pwd"]];
|
|
self.forgotImageView.frame = CGRectMake((SCREEN_WIDTH-128)/2, NavContentHeight+20, 128, 128);
|
|
[self.view addSubview:self.forgotImageView];
|
|
/// 获取验证码
|
|
self.accountTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(16, self.forgotImageView.bottom+15, SCREEN_WIDTH-32, 44) type:(LoginTextTypeAccount)];
|
|
self.accountTextField.backgroundColor = RGB16(0xECEAF4);
|
|
[self.accountTextField addRoundedCornersWithRadius:22];
|
|
[self.view addSubview:self.accountTextField];
|
|
|
|
self.codeTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(self.accountTextField.left, self.accountTextField.bottom+16, SCREEN_WIDTH-32, 44) type:(LoginTextTypeCode)];
|
|
self.codeTextField.backgroundColor = RGB16(0xECEAF4);
|
|
self.codeTextField.delegate = self;
|
|
[self.codeTextField addRoundedCornersWithRadius:22];
|
|
[self.view addSubview:self.codeTextField];
|
|
|
|
// 修改新密码
|
|
self.passwordTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(self.accountTextField.left, self.codeTextField.bottom+16, SCREEN_WIDTH-32, 44) type:(LoginTextTypePassword)];
|
|
self.passwordTextField.backgroundColor = RGB16(0xECEAF4);
|
|
[self.passwordTextField addRoundedCornersWithRadius:22];
|
|
[self.view addSubview:self.passwordTextField];
|
|
|
|
self.repasswordTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(self.accountTextField.left, self.passwordTextField.bottom+16, SCREEN_WIDTH-32, 44) type:(LoginTextTypeRepassword)];
|
|
self.repasswordTextField.backgroundColor = RGB16(0xECEAF4);
|
|
[self.repasswordTextField addRoundedCornersWithRadius:22];
|
|
[self.view addSubview:self.repasswordTextField];
|
|
|
|
// self.firstCommitBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.codeTextField.bottom+20, SCREEN_WIDTH-38*2, 42)];
|
|
// [self.firstCommitBtn setTitle:QXText(@"下一步") forState:(UIControlStateNormal)];
|
|
// self.firstCommitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
// self.firstCommitBtn.backgroundColor = QXConfig.themeColor;
|
|
// [self.firstCommitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
// [self.firstCommitBtn addRoundedCornersWithRadius:21];
|
|
// [self.firstCommitBtn addTarget:self action:@selector(nextAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
// [self.scrollView addSubview:self.firstCommitBtn];
|
|
|
|
self.secondCommitBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.repasswordTextField.bottom+20, SCREEN_WIDTH-38*2, 42)];
|
|
[self.secondCommitBtn setTitle:QXText(@"提交") forState:(UIControlStateNormal)];
|
|
self.secondCommitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
self.secondCommitBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.secondCommitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
[self.secondCommitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.secondCommitBtn addRoundedCornersWithRadius:21];
|
|
[self.view addSubview:self.secondCommitBtn];
|
|
}
|
|
|
|
//-(void)nextAction{
|
|
// self.firstBtn.selected = NO;
|
|
// self.secondBtn.selected = YES;
|
|
// [self.scrollView setContentOffset:CGPointMake(SCREEN_WIDTH, 0) animated:YES];
|
|
//}
|
|
-(void)didClickSendCode:(UIButton *)sender{
|
|
if (self.accountTextField.textField.text.length < 11) {
|
|
showToast(QXText(@"请输入正确的手机号码"));
|
|
return;
|
|
}
|
|
MJWeakSelf
|
|
[QXLoginNetwork getSmscodeWithMobile:self.accountTextField.textField.text
|
|
type:(GetSmscodeTypeFindPassword)
|
|
successBlock:^(id _Nonnull responseObject) {
|
|
[weakSelf.codeTextField startTimeDown];
|
|
}
|
|
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
-(void)commitAction{
|
|
if (self.accountTextField.textField.text.length < 11) {
|
|
showToast(QXText(@"请输入正确的手机号码"));
|
|
return;
|
|
}
|
|
if (self.codeTextField.textField.text.length == 0) {
|
|
showToast(QXText(@"请输入验证码"));
|
|
return;
|
|
}
|
|
if (self.passwordTextField.textField.text.length == 0) {
|
|
showToast(QXText(@"请输入密码"));
|
|
return;
|
|
}
|
|
if (![self.passwordTextField.textField.text isEqualToString:self.repasswordTextField.textField.text]) {
|
|
showToast(QXText(@"两次密码输入不一致"));
|
|
return;
|
|
}
|
|
showLoadingInView(self.view);
|
|
[QXLoginNetwork changPasswordWithMobile:self.accountTextField.textField.text
|
|
new_password:self.passwordTextField.textField.text
|
|
sms_code:self.codeTextField.textField.text
|
|
user_id:[QXGlobal shareGlobal].loginModel.user_id
|
|
successBlock:^(id _Nonnull responseObject) {
|
|
hideLoadingInView(self.view);
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
hideLoadingInView(self.view);
|
|
}];
|
|
|
|
}
|
|
-(void)backAction{
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
@end
|