PasswordViewController.mm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // PasswordViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/17.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "PasswordViewController.h"
  9. #import "NSString+Extention.h"
  10. #import <Masonry/Masonry.h>
  11. #import "PasswordView.h"
  12. #import "PasswordConfig.h"
  13. #import "Header.h"
  14. @interface PasswordViewController () <ChangePasswordConfigDelegate>
  15. {
  16. PasswordView *changePwdView;
  17. PasswordConfig *config;
  18. }
  19. @end
  20. @implementation PasswordViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. //设置导航栏
  24. [self setNaviStyle];
  25. [self creteView];
  26. [self createConfig];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated{
  29. //有加载状态、则取消加载
  30. if ([SVProgressHUD isVisible]){
  31. [SVProgressHUD dismiss];
  32. }
  33. }
  34. #pragma mark - 修改保存设备密码
  35. - (void)changePassWord:(NSString*)oldPsw newPwd1:(NSString*)newPsw1 newPsw2:(NSString*)newPsw2{
  36. // //判断新密码是否为空
  37. // if (newPsw1.length == 0 ) {
  38. // [SVProgressHUD showErrorWithStatus:TS("set_new_psd")];
  39. // return;
  40. // }
  41. //判断2次新密码是否相同
  42. if ( ![newPsw1 isEqualToString:newPsw2]) {
  43. [SVProgressHUD showErrorWithStatus:TS("pass_notsame")];
  44. return;
  45. }
  46. [SVProgressHUD show];
  47. [config changePassword:oldPsw newpassword:newPsw1];
  48. }
  49. #pragma mark - 修改设备密码代理回调
  50. - (void)changePasswordConfigResult:(NSInteger)result {
  51. if (result >0) {
  52. //成功
  53. [SVProgressHUD dismissWithSuccess:TS("Success")];
  54. }else{
  55. [MessageUI ShowErrorInt:(int)result];
  56. }
  57. }
  58. - (void)setNaviStyle {
  59. self.navigationItem.title = TS("Modify_pwd");
  60. }
  61. - (void)creteView {
  62. //修改账号密码视图初始化
  63. changePwdView = [[PasswordView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
  64. self.view = changePwdView;
  65. __weak typeof(self) weakSelf = self;
  66. //修改密码按钮点击处理
  67. changePwdView.changePwdClicked = ^(NSString * _Nonnull pwdOld, NSString * _Nonnull pwdNew1, NSString * _Nonnull pwdNew2) {
  68. [weakSelf changePassWord:pwdOld newPwd1:pwdNew1 newPsw2:pwdNew2];
  69. };
  70. }
  71. #pragma mark - 初始化设备密码配置
  72. - (void)createConfig {
  73. if (config == nil) {
  74. config = [[PasswordConfig alloc] init];
  75. config.delegate = self;
  76. }
  77. }
  78. - (void)didReceiveMemoryWarning {
  79. [super didReceiveMemoryWarning];
  80. }
  81. @end