// // YXYoungSetPwViewController.m // romantic // // Created by MAC on 2022/12/15. // Copyright © 2022 romantic. All rights reserved. // #import "YXYoungSetPwViewController.h" #import "YXYoungSetPwView.h" @interface YXYoungSetPwViewController () @property (nonatomic,strong) YXYoungSetPwView *loginView; @property (nonatomic,copy) NSString *password; @property (nonatomic,copy) NSString *again_password; @end @implementation YXYoungSetPwViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIImageView *bgImg = [ControlCreator createImageView:self.view rect:CGRectMake(0, 0, APPW, APPH) imageName:@"party_bg" backguoundColor:nil]; bgImg.contentMode = UIViewContentModeScaleToFill; [self initNavBar]; [self.view addSubview:self.loginView]; } - (void)initNavBar { self.navTitle = @"青少年模式"; [self.customNavBar styleClear]; [self.customNavBar.left0Btn setImage:ImageNamed(@"blackBack") forState:UIControlStateNormal]; } - (YXYoungSetPwView *)loginView { if (_loginView == nil) { WEAK_SELF _loginView = [[YXYoungSetPwView alloc] initWithFrame:CGRectMake(0, 0, APPW, APPH)]; [self.view addSubview:_loginView]; if (self.type == 1) { _loginView.shensuLabel.hidden = YES; _loginView.descLabel.text = @"开启青少年模式请输入密码"; _loginView.nameLabel.text = @"请设置密码开启"; _loginView.boxInputView.textDidChangeblock = ^(NSString * _Nullable text, BOOL isFinished) { if (isFinished == YES) { weakSelf.loginView.nameLabel.text = @"确认密码"; weakSelf.loginView.boxInputView.hidden = YES; weakSelf.loginView.boxInputViewTwo.hidden = NO; weakSelf.password = text; } }; _loginView.boxInputViewTwo.textDidChangeblock = ^(NSString * _Nullable text, BOOL isFinished) { if (isFinished == YES) { weakSelf.again_password = text; if ([weakSelf.again_password isEqualToString:weakSelf.password] == NO) { [HelpPageDefine showMessage:@"输入密码不一致,请重新输入"]; weakSelf.loginView.descLabel.text = @"开启青少年模式时,需输入该密码"; weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = NO; weakSelf.loginView.boxInputViewTwo.hidden = YES; [weakSelf.loginView.boxInputView clearAll]; [weakSelf.loginView.boxInputViewTwo clearAll]; weakSelf.password = @""; } else { NSDictionary *parms = @{ @"type":@"1", @"password":weakSelf.password, @"again_password":weakSelf.again_password }; [AFNetworkRequset.shared postRequestWithParams:parms Path:@"api/mode/open_teen_mode" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { [HelpPageDefine showMessage:@"青少年模式已开启"]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.navigationController popToRootViewControllerAnimated:YES]; }); } Failure:^(id _Nonnull errorData) { weakSelf.password = @""; weakSelf.again_password = @""; weakSelf.loginView.descLabel.text = @"开启青少年模式时,需输入该密码"; weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = NO; weakSelf.loginView.boxInputViewTwo.hidden = YES; [weakSelf.loginView.boxInputView clearAll]; [weakSelf.loginView.boxInputViewTwo clearAll]; }]; } } }; } else if (_type == 2) { _loginView.shensuLabel.hidden = NO; _loginView.descLabel.text = @"关闭青少年模式请输入密码"; _loginView.boxInputViewTwo.hidden = YES; _loginView.boxInputView.textDidChangeblock = ^(NSString * _Nullable text, BOOL isFinished) { if (isFinished == YES) { weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = YES; weakSelf.loginView.boxInputViewTwo.hidden = NO; weakSelf.password = text; NSDictionary *parms = @{ @"type":@"1", @"password":weakSelf.password, }; [AFNetworkRequset.shared postRequestWithParams:parms Path:@"api/mode/close_teen_mode" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { [HelpPageDefine showMessage:@"青少年模式已关闭"]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.navigationController popToRootViewControllerAnimated:YES]; }); } Failure:^(id _Nonnull errorData) { weakSelf.password = @""; weakSelf.again_password = @""; weakSelf.loginView.descLabel.text = @"关闭青少年模式,请输入开启时设置的密码"; weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = NO; weakSelf.loginView.boxInputViewTwo.hidden = YES; [weakSelf.loginView.boxInputView clearAll]; [weakSelf.loginView.boxInputViewTwo clearAll]; }]; } else { } }; }else if (_type == 3){ _loginView.shensuLabel.hidden = YES; _loginView.descLabel.text = @"关闭青少年模式请输入密码"; _loginView.boxInputView.textDidChangeblock = ^(NSString * _Nullable text, BOOL isFinished) { if (isFinished == YES) { weakSelf.loginView.nameLabel.text = @"确认密码"; weakSelf.loginView.boxInputView.hidden = YES; weakSelf.loginView.boxInputViewTwo.hidden = NO; weakSelf.password = text; } }; _loginView.boxInputViewTwo.textDidChangeblock = ^(NSString * _Nullable text, BOOL isFinished) { if (isFinished == YES) { weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = YES; weakSelf.loginView.boxInputViewTwo.hidden = NO; weakSelf.password = text; NSDictionary *parms = @{ @"type":@"1", @"password":weakSelf.password, }; [AFNetworkRequset.shared postRequestWithParams:parms Path:@"api/mode/close_teen_mode" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { [HelpPageDefine showMessage:@"青少年模式已关闭"]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.navigationController popToRootViewControllerAnimated:YES]; }); } Failure:^(id _Nonnull errorData) { weakSelf.password = @""; weakSelf.again_password = @""; weakSelf.loginView.descLabel.text = @"关闭青少年模式,请输入开启时设置的密码"; weakSelf.loginView.nameLabel.text = @"输入密码"; weakSelf.loginView.boxInputView.hidden = NO; weakSelf.loginView.boxInputViewTwo.hidden = YES; [weakSelf.loginView.boxInputView clearAll]; [weakSelf.loginView.boxInputViewTwo clearAll]; }]; } else { } }; } } return _loginView; } @end