YBYoungModifyVC.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // YBYoungModifyVC.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2022/6/2.
  6. // Copyright © 2022 cat. All rights reserved.
  7. //
  8. #import "YBYoungModifyVC.h"
  9. #import "RKCodeInputView.h"
  10. @interface YBYoungModifyVC ()
  11. @property(nonatomic,strong)RKCodeInputView *civOld; //旧密码
  12. @property(nonatomic,strong)RKCodeInputView *civNew; //新密码
  13. @property(nonatomic,strong)RKCodeInputView *civSure; //确认密码
  14. @property(nonatomic,strong)YBButton *modifyBtn;
  15. @end
  16. @implementation YBYoungModifyVC
  17. - (UIStatusBarStyle)preferredStatusBarStyle {
  18. if (@available(iOS 13.0,*)) {
  19. return UIStatusBarStyleDarkContent;
  20. }
  21. return UIStatusBarStyleDefault;
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.titleL.text = YZMsg(@"修改密码");
  26. self.titleL.textColor = RGB_COLOR(@"#323232", 1);
  27. [self.leftBtn setImage:[UIImage imageNamed:@"pubBlack_back"] forState:0];
  28. self.subNavi.backgroundColor = UIColor.whiteColor;
  29. self.view.backgroundColor = UIColor.whiteColor;
  30. YBWeakSelf;
  31. NSArray *titleA = @[@"请输入当前密码",@"请输入新的密码",@"请确定新的密码"];
  32. MASViewAttribute *mas_top = self.naviView.mas_bottom;
  33. for (int i =0 ; i<titleA.count; i++) {
  34. UIView *itemV = [[UIView alloc]init];
  35. itemV.backgroundColor = UIColor.clearColor;
  36. [self.view addSubview:itemV];
  37. [itemV mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.width.equalTo(self.view.mas_width).multipliedBy(0.8);
  39. make.left.equalTo(self.view.mas_left).offset(15);
  40. make.top.equalTo(mas_top).offset(20);
  41. }];
  42. mas_top = itemV.mas_bottom;
  43. UILabel *titL = [[UILabel alloc]init];
  44. titL.text = YZMsg(titleA[i]);
  45. titL.font = SYS_Font(15);
  46. titL.textColor = RGB_COLOR(@"#323232", 1);
  47. [itemV addSubview:titL];
  48. [titL mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.top.equalTo(itemV);
  50. make.height.mas_equalTo(20);
  51. }];
  52. RKCodeInputView *codeIV = [[RKCodeInputView alloc]init];
  53. codeIV.contentView.backgroundColor = UIColor.whiteColor;
  54. codeIV.secureTextEntry = YES;
  55. [itemV addSubview:codeIV];
  56. [codeIV mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.width.equalTo(itemV.mas_width).multipliedBy(0.8);
  58. make.left.equalTo(itemV);
  59. make.height.mas_equalTo(40);
  60. make.top.equalTo(titL.mas_bottom).offset(10);
  61. make.bottom.equalTo(itemV);
  62. }];
  63. [itemV layoutIfNeeded];
  64. [codeIV updateSubViews];
  65. if (i == 0) {
  66. _civOld = codeIV;
  67. _civOld.becomeFirstRes = YES;
  68. }else if(i == 1){
  69. _civNew = codeIV;
  70. }else{
  71. _civSure = codeIV;
  72. }
  73. codeIV.changeEvent = ^{
  74. [weakSelf changeEvent];
  75. };
  76. __block RKCodeInputView *weakCodeIV = codeIV;
  77. codeIV.finishEvent = ^{
  78. [weakSelf inputFinish:weakCodeIV];
  79. };
  80. }
  81. _modifyBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  82. _modifyBtn.titleLabel.font = SYS_Font(15);
  83. _modifyBtn.layer.cornerRadius = 5;
  84. _modifyBtn.layer.masksToBounds = YES;
  85. [_modifyBtn addTarget:self action:@selector(clickModifyBtn) forControlEvents:UIControlEventTouchUpInside];
  86. [_modifyBtn setTitleColor:RGB_COLOR(@"#7d7d7d", 1) forState:0];
  87. [_modifyBtn jk_setBackgroundColor:RGB_COLOR(@"#d9d9d9", 1) forState:0];
  88. [_modifyBtn setTitle:YZMsg(@"确定修改") forState:0];
  89. [_modifyBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:UIControlStateSelected];
  90. [_modifyBtn jk_setBackgroundColor:Pink_Cor forState:UIControlStateSelected];
  91. [_modifyBtn setTitle:YZMsg(@"确定修改") forState:UIControlStateSelected];
  92. _modifyBtn.enabled = NO;
  93. [self.view addSubview:_modifyBtn];
  94. [_modifyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.width.equalTo(self.view.mas_width).offset(-30);
  96. make.centerX.equalTo(self.view);
  97. make.height.mas_equalTo(46);
  98. make.bottom.equalTo(self.view.mas_bottom).offset(-60-ShowDiff);
  99. }];
  100. }
  101. -(void)changeEvent {
  102. if (_civOld.codeText.length>=4 &&
  103. _civNew.codeText.length>=4 &&
  104. _civSure.codeText.length>=4) {
  105. _modifyBtn.enabled = YES;
  106. _modifyBtn.selected = YES;
  107. }else{
  108. _modifyBtn.enabled = NO;
  109. _modifyBtn.selected = NO;
  110. }
  111. }
  112. -(void)inputFinish:(RKCodeInputView *)finishInput {
  113. if (finishInput == _civOld) {
  114. _civNew.becomeFirstRes = YES;
  115. }else if(finishInput == _civNew){
  116. _civSure.becomeFirstRes = YES;
  117. }
  118. }
  119. -(void)resetAll {
  120. [_civOld clearText];
  121. [_civNew clearText];
  122. [_civSure clearText];
  123. [_civNew cancelCursor];
  124. [_civSure cancelCursor];
  125. _civOld.becomeFirstRes = YES;
  126. [self changeEvent];
  127. }
  128. -(void)clickModifyBtn {
  129. /**
  130. * type(1设置密码并开启 2开启青少年模式 3关闭青少年模式 4修改密码 5重新设置密码)
  131. * pwd当前密码 newpwd 修改新密码 newspwd 确认新密码
  132. */
  133. NSDictionary *postDic = @{
  134. @"type":@"4",
  135. @"pwd":_civOld.codeText,
  136. @"newpwd":_civNew.codeText,
  137. @"newspwd":_civSure.codeText,
  138. };
  139. YBWeakSelf;
  140. [YBNetworking postWithUrl:@"User.setTeenagers" Dic:postDic Suc:^(int code, id info, NSString *msg) {
  141. [MBProgressHUD showError:msg];
  142. if (code == 0) {
  143. [[YBBaseAppDelegate sharedAppDelegate] popViewController:YES];
  144. }else{
  145. [weakSelf resetAll];
  146. }
  147. } Fail:^(id fail) {
  148. [weakSelf resetAll];
  149. }];
  150. }
  151. @end