123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // UserRestPassword2ViewController.m
- // XenonSDK
- //
- // Created by SAGESSE on 2019/5/30.
- // Copyright © 2019 SAGESSE. All rights reserved.
- //
- #import "XenonSDK.h"
- #import "RootViewController.h"
- #import "UserRestPassword2ViewController.h"
- @interface UserRestPassword2ViewController () <UITextFieldDelegate>
- @end
- @implementation UserRestPassword2ViewController
- - (void)setNewPasswordTextField:(id)sender {
- self.passwordTextField = sender;
- }
- - (void)sdk_dismissViewController:(id)sender {
- if (self.navigationController.viewControllers.count > 2) {
- // if viewControllers[1] is UserRestPasswordViewController {
- // navigationController?.popToViewController(viewControllers[0], animated: true)
- // return
- // }
- }
- return [super sdk_dismissViewController:sender];
- }
- - (void)displayModeForPassword:(UIButton*)sender {
- // Toggle password display mode.
- sender.selected = !sender.selected;
- if (self.passwordTextField.tag == sender.tag) {
- self.passwordTextField.secureTextEntry = sender.selected;
- }
- if (self.confirmPasswordTextField.tag == sender.tag) {
- self.confirmPasswordTextField.secureTextEntry = sender.selected;
- }
- }
- - (void)securityCodeForReset:(id)sender {
- [self.view endEditing:YES];
-
- NSString* phone = self.phone;
- NSString* code = self.code;
-
- NSString* newPassword = self.passwordTextField.text;
- NSString* confirmPassword = self.confirmPasswordTextField.text;
-
- if (newPassword.length == 0) {
- [XSNetwork showHudFailure:@"请输入新的密码"];
- return;
- }
- if (confirmPassword.length == 0) {
- [XSNetwork showHudFailure:@"请再次输入新的密码"];
- return;
- }
- if (![newPassword isEqual:confirmPassword]) {
- [XSNetwork showHudFailure:@"两次输入的密码不一致"];
- return;
- }
-
- [XSNetwork showHudLoading];
- [XSNetwork resetWithPhone:phone code:code password:newPassword complete:^(id object, NSError *error) {
-
- if (error != nil) {
- [XSNetwork showHudFailure:error];
- return;
- }
-
- [XSNetwork showHudSuccess:@"密码修改成功"];
-
- if (self.navigationController.viewControllers.count <= 2) {
- [self.navigationController popViewControllerAnimated:YES];
- return ;
- }
-
- UIViewController* pop = self.navigationController.viewControllers[self.navigationController.viewControllers.count - 2 - 1];
- [self.navigationController popToViewController:pop animated:YES];
- }];
- }
- - (BOOL)textFieldShouldReturn:(UITextField*)textField {
- if (textField.returnKeyType == UIReturnKeyDone) {
- return NO;
- }
- if (textField == self.passwordTextField) {
- [self.confirmPasswordTextField becomeFirstResponder];
- return YES;
- }
- return YES;
- }
- @end
|