|
@@ -0,0 +1,258 @@
|
|
|
+//
|
|
|
+// LoginForgotC.m
|
|
|
+// westkissMob
|
|
|
+//
|
|
|
+// Created by 王猛 on 2022/9/6.
|
|
|
+//
|
|
|
+
|
|
|
+#import "LoginForgotC.h"
|
|
|
+#import "APPassForgetCodeV.h"
|
|
|
+#import "APPassForgetEmailV.h"
|
|
|
+#import "APPassForgetNewPassV.h"
|
|
|
+
|
|
|
+@interface LoginForgotC ()
|
|
|
+
|
|
|
+@property (nonatomic, copy) NSString *email;
|
|
|
+@property (nonatomic, copy) NSString *code;
|
|
|
+@property (nonatomic, copy) NSString *pass;
|
|
|
+
|
|
|
+// 0:emailV 1:codeV 2:passV
|
|
|
+@property (nonatomic, assign) NSInteger showType;
|
|
|
+
|
|
|
+@property (nonatomic , strong) UIScrollView *scrollview;
|
|
|
+
|
|
|
+@property (nonatomic, strong) APPassForgetEmailV *emailV;
|
|
|
+@property (nonatomic, strong) APPassForgetCodeV *codeV;
|
|
|
+@property (nonatomic, strong) APPassForgetNewPassV *passV;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation LoginForgotC
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+ [self addSubV];
|
|
|
+ [self setVAction];
|
|
|
+ self.showType = 0;
|
|
|
+ [self setShowViewState];
|
|
|
+ self.view.backgroundColor = _FFF8F9;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setVAction {
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ self.emailV.btnClick = ^(NSString *emailAddr){
|
|
|
+ [weakSelf.view endEditing:true];
|
|
|
+ weakSelf.email = emailAddr;
|
|
|
+
|
|
|
+ [weakSelf showEmailTipAlert];
|
|
|
+ };
|
|
|
+ self.codeV.resendBtnClick = ^{
|
|
|
+ [weakSelf.view endEditing:true];
|
|
|
+ [weakSelf reqNet_forgotPassWord];
|
|
|
+ };
|
|
|
+ self.codeV.noReceiveClick = ^{
|
|
|
+ [weakSelf.view endEditing:true];
|
|
|
+ weakSelf.showType = 0;
|
|
|
+ [weakSelf setShowViewState];
|
|
|
+ };
|
|
|
+ self.codeV.subBtnClick = ^(NSString *codeStr){
|
|
|
+ [weakSelf.view endEditing:true];
|
|
|
+ weakSelf.code = codeStr;
|
|
|
+ weakSelf.showType = 2;
|
|
|
+ [weakSelf setShowViewState];
|
|
|
+ };
|
|
|
+
|
|
|
+ self.passV.btnClick = ^(NSString * _Nonnull passStr) {
|
|
|
+ [weakSelf.view endEditing:true];
|
|
|
+ weakSelf.pass = passStr;
|
|
|
+ [weakSelf reqNet_reSetPassWord];
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+- (void)addSubV{
|
|
|
+ self.customNavBar.hidden = true;
|
|
|
+ self.navigationController.navigationBar.hidden = YES;
|
|
|
+ [self.view addSubview:self.scrollview];
|
|
|
+ UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [closeBtn setImage:[UIImage imageNamed:@"login_close_black"] forState:UIControlStateNormal];
|
|
|
+ [closeBtn addTarget:self action:@selector(action_back) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:closeBtn];
|
|
|
+ [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(@(IPHONEX ? 44 : 20));
|
|
|
+ make.centerX.equalTo(self.view);
|
|
|
+ make.width.height.equalTo(@50);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ UIImage *logoImg = [UIImage imageNamed:@"name_icon"];
|
|
|
+ UIImageView *bottomImgV = [[UIImageView alloc]initWithImage:logoImg];
|
|
|
+ [self.view addSubview:bottomImgV];
|
|
|
+ [bottomImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-25);
|
|
|
+ make.centerX.equalTo(self.view);
|
|
|
+ make.width.equalTo(@104);
|
|
|
+ make.height.equalTo(@32);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.scrollview mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(closeBtn.mas_bottom);
|
|
|
+ make.leading.trailing.equalTo(self.view);
|
|
|
+ make.bottom.equalTo(bottomImgV.mas_top);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.scrollview addSubview:self.emailV];
|
|
|
+ [self.scrollview addSubview:self.passV];
|
|
|
+ [self.scrollview addSubview:self.codeV];
|
|
|
+ [self.emailV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.scrollview);
|
|
|
+ make.width.equalTo(self.view);
|
|
|
+ }];
|
|
|
+ [self.passV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.scrollview);
|
|
|
+ make.width.equalTo(self.view);
|
|
|
+ }];
|
|
|
+ [self.codeV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.scrollview);
|
|
|
+ make.width.equalTo(self.view);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showEmailTipAlert {
|
|
|
+ NSString *tipStr = [NSString stringWithFormat:@"Please check the verification code by %@.", self.email];
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:tipStr preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ UIAlertAction *sureAc = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ [alert dismissViewControllerAnimated:true completion:nil];
|
|
|
+ [weakSelf reqNet_forgotPassWord];
|
|
|
+ }];
|
|
|
+ [alert addAction:sureAc];
|
|
|
+ [self presentViewController:alert animated:true completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)setShowViewState {
|
|
|
+ switch (self.showType) {
|
|
|
+ case 1:
|
|
|
+ self.passV.hidden = true;
|
|
|
+ self.codeV.hidden = false;
|
|
|
+ self.emailV.hidden = true;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ self.passV.hidden = false;
|
|
|
+ self.codeV.hidden = true;
|
|
|
+ self.emailV.hidden = true;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ self.passV.hidden = true;
|
|
|
+ self.codeV.hidden = true;
|
|
|
+ self.emailV.hidden = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)action_back{
|
|
|
+ if (self.showType == 1) {
|
|
|
+ self.showType = 0;
|
|
|
+ [self setShowViewState];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (self.showType == 2) {
|
|
|
+ self.showType = 1;
|
|
|
+ [self setShowViewState];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+-(void)action_submitClick{
|
|
|
+ if (![Current_normalTool xxx_isValidateEmail:self.email]) {
|
|
|
+ [self.view makeToast:@"Please prvide an email address." duration:2 position:CSToastPositionCenter];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [self reqNet_forgotPassWord];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - **************** reqNet ****************
|
|
|
+
|
|
|
+-(void)reqNet_forgotPassWord{
|
|
|
+ if (self.email == nil || self.email.isEmpty) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ [ASNetTools.shared postWithPath:postEmailCode param:@{@"email":self.email} success:^(id _Nonnull json) {
|
|
|
+ if (weakSelf.showType != 1) {
|
|
|
+ weakSelf.codeV.emailAddr = self.email;
|
|
|
+ weakSelf.showType = 1;
|
|
|
+ [weakSelf setShowViewState];
|
|
|
+ }
|
|
|
+ } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
+ [self.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+-(void)reqNet_reSetPassWord{
|
|
|
+ if (self.email == nil || self.email.isEmpty) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ NSMutableDictionary *param = [NSMutableDictionary dictionary];
|
|
|
+ [param setValue:self.email forKey:@"email"];
|
|
|
+ [param setValue:self.code forKey:@"code"];
|
|
|
+ [param setValue:self.pass forKey:@"newPassword"];
|
|
|
+ [ASNetTools.shared postWithPath:postResetPass param:param success:^(id _Nonnull json) {
|
|
|
+ [[UIApplication sharedApplication].windows.firstObject makeToast:@"Success"];
|
|
|
+ [weakSelf.navigationController popViewControllerAnimated:YES];
|
|
|
+ } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
+ [weakSelf.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
|
+ if ([code isEqualToString:@"100"]) {
|
|
|
+ weakSelf.showType = 1;
|
|
|
+ weakSelf.pass = @"";
|
|
|
+ [weakSelf.passV clearPass];
|
|
|
+ [weakSelf setShowViewState];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (UIScrollView *)scrollview {
|
|
|
+ if (!_scrollview) {
|
|
|
+ _scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
|
+ }
|
|
|
+ return _scrollview;
|
|
|
+}
|
|
|
+
|
|
|
+- (APPassForgetCodeV *)codeV {
|
|
|
+ if (!_codeV) {
|
|
|
+ APPassForgetCodeV *v = [[APPassForgetCodeV alloc] initWithFrame:self.scrollview.bounds];
|
|
|
+ _codeV = v;
|
|
|
+ }
|
|
|
+ return _codeV;
|
|
|
+}
|
|
|
+
|
|
|
+- (APPassForgetEmailV *)emailV {
|
|
|
+ if (!_emailV) {
|
|
|
+ APPassForgetEmailV *v = [[APPassForgetEmailV alloc] initWithFrame:self.scrollview.bounds];
|
|
|
+ _emailV = v;
|
|
|
+ }
|
|
|
+ return _emailV;
|
|
|
+}
|
|
|
+
|
|
|
+- (APPassForgetNewPassV *)passV {
|
|
|
+ if (!_passV) {
|
|
|
+ APPassForgetNewPassV *v = [[APPassForgetNewPassV alloc] initWithFrame:self.scrollview.bounds];
|
|
|
+ _passV = v;
|
|
|
+ }
|
|
|
+ return _passV;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@end
|