NewModifyPasswordViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //
  2. // MMMessageVerificationVC.m
  3. // MingMen
  4. //
  5. // Created by 肖雨 on 2017/3/11.
  6. // Copyright © 2017年 肖雨. All rights reserved.
  7. //
  8. #import "NewModifyPasswordViewController.h"
  9. #import "NewRegistCell.h"
  10. #import "NewInterfaceReplacement.h"
  11. @interface NewModifyPasswordViewController ()
  12. {
  13. NSMutableArray *dataArray;
  14. NSString*yuanmima;
  15. NSString*xinmima;
  16. NSString*querenmima;
  17. }
  18. @end
  19. @implementation NewModifyPasswordViewController
  20. -(void)dealloc
  21. {
  22. NSLog(@"修改密码界面销毁");
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. [self setNavTitle:@"修改密码"];
  28. [self dataInitialization];
  29. [self loadsView];
  30. }
  31. #pragma mark - 数据初始化
  32. -(void)dataInitialization
  33. {
  34. // passWord1TextField = nil;
  35. // passWord2TextField = nil;
  36. yuanmima = @"";
  37. xinmima = @"";
  38. querenmima = @"";
  39. dataArray = NewMutableArrayInit;
  40. for (int i=0; i<3; i++) {
  41. NSDictionary *dataDic = [NSDictionary dictionary];
  42. switch (i) {
  43. case 0:
  44. dataDic = @{@"nameKey":@"原密码",@"imageKey":@"密码",@"placeholderKey":@"请输入原密码"};
  45. [dataArray addObject:dataDic];
  46. break;
  47. case 1:
  48. dataDic = @{@"nameKey":@"新密码",@"imageKey":@"密码",@"placeholderKey":@"请输入新密码"};
  49. [dataArray addObject:dataDic];
  50. break;
  51. case 2:
  52. dataDic = @{@"nameKey":@"确认密码",@"imageKey":@"密码",@"placeholderKey":@"再次输入新密码"};
  53. [dataArray addObject:dataDic];
  54. break;
  55. default:
  56. break;
  57. }
  58. }
  59. }
  60. #pragma mark - UI初始化
  61. -(void)loadsView
  62. {
  63. for (int i = 0; i<dataArray.count; i++) {
  64. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(15, i*45+ViewStartY, 80, 45)];
  65. title.text = [NSString stringWithFormat:@"%@",dataArray[i][@"nameKey"]];
  66. title.font = NewFont(15);
  67. title.textAlignment = NSTextAlignmentLeft;
  68. [self.view addSubview:title];
  69. UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, (i+1)*45+ViewStartY+1, SCREEN_WIDTH, 0.8)];
  70. line.backgroundColor = NewLineGrayColor;
  71. [self.view addSubview:line];
  72. UITextField *textField;
  73. [self.view addSubview:textField = [NewControlPackage textFieldInitWithFrame:CGRectMake(90, i*45+ViewStartY, 200, 45) backgroundImage:nil backgroundColor:NewClearColor textColor:NewGrayColor placeholder:dataArray[i][@"placeholderKey"] hidden:NO tag:100+i font:NewFont(14) textAlignment:NSTextAlignmentLeft clearButtonMode:NO clearsOnBeginEditing:NO adjustsFontSizeToFitWidth:NO secureTextEntry:YES keyboardType:UIKeyboardTypeDefault returnKeyType:UIReturnKeyDefault userInteractionEnabled:YES]];
  74. [textField addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  75. }
  76. UIButton *tijiaoPJ = [UIButton new];
  77. [tijiaoPJ setTitle:@"保存" forState:UIControlStateNormal];
  78. [tijiaoPJ setBackgroundColor:NewButtonColor];
  79. tijiaoPJ.titleLabel.font = NewFont(18);
  80. ViewRadius(tijiaoPJ, 6);
  81. NewTouchUpInside(tijiaoPJ, tijiaoPJclick:);
  82. [self.view addSubview:tijiaoPJ];
  83. tijiaoPJ.sd_layout
  84. .leftSpaceToView(self.view, 45)
  85. .rightSpaceToView(self.view, 45)
  86. .heightIs(45)
  87. .topSpaceToView(self.view, 178+ViewStartY);
  88. }
  89. - (void)tijiaoPJclick:(UIButton *)sender {
  90. NSLog(@"%@",@"保存");
  91. if (yuanmima.length<=0) {
  92. [self.view makeToast:@"请输入原密码" duration:1.0 position:CSToastPositionCenter];
  93. return;
  94. }else if (xinmima.length<=0){
  95. [self.view makeToast:@"请输入新密码" duration:1.0 position:CSToastPositionCenter];
  96. return;
  97. }else if (querenmima.length<=0){
  98. [self.view makeToast:@"请输入确认新密码" duration:1.0 position:CSToastPositionCenter];
  99. return;
  100. }else if (![xinmima isEqualToString:querenmima]){
  101. [self.view makeToast:@"您输入的新密码不同" duration:1.0 position:CSToastPositionCenter];
  102. return;
  103. }
  104. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  105. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  106. [parameters safeSetObject:yuanmima forKey:@"pwd"];//账号
  107. [parameters safeSetObject:xinmima forKey:@"newPwd"];//密码
  108. [NetworkRequestManager requestPostWithInterfacePrefix:JT_resetPwd parameters:parameters onSuccess:^(id requestData) {
  109. [MBProgressHUD hideHUDForView:self.view];
  110. if ([requestData[@"error"] count] !=0) {
  111. for (NSDictionary *dic in requestData[@"error"]) {
  112. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  113. }
  114. }else{
  115. [MBProgressHUD showSuccess:@"修改密码成功" toView:self.view];
  116. // [[NewInterfaceReplacement sharedInstance] replacementLogin];
  117. NewPopViewController;
  118. }
  119. } onFailure:^{
  120. [MBProgressHUD hideHUDForView:self.view];
  121. }];
  122. }
  123. #pragma mark - 作字符输入限制
  124. - (void)textFieldEditingChanged:(UITextField *)textField
  125. {
  126. if (textField.tag == 100) {
  127. if ([textField.text length]>20) {
  128. textField.text=[textField.text substringToIndex:20];//原密码最多20位
  129. yuanmima = textField.text;
  130. }else{
  131. yuanmima = textField.text;
  132. }
  133. }else if (textField.tag == 101) {
  134. if ([textField.text length]>20) {
  135. textField.text=[textField.text substringToIndex:20];//新密码最多20位
  136. xinmima = textField.text;
  137. }else{
  138. xinmima = textField.text;
  139. }
  140. }else if (textField.tag == 102) {
  141. if ([textField.text length]>20) {
  142. textField.text=[textField.text substringToIndex:20];//确认密码最多20位
  143. querenmima = textField.text;
  144. }else{
  145. querenmima = textField.text;
  146. }
  147. }
  148. }
  149. //#pragma mark - 获取验证码
  150. //- (void)touchVerificationCode:(UIButton *)sender
  151. //{
  152. // if (![self verification:nil]) {
  153. // return;
  154. // }
  155. //
  156. //}
  157. //- (void)verificationCode:(NSInteger)code sender:(UIButton *)sender{
  158. // NSString *str=[NSString stringWithFormat:@"%d秒后重新发送",(int)code];
  159. // [sender setTitle:str forState:UIControlStateNormal];
  160. // sender.enabled=NO;
  161. // if (code==0) {
  162. // sender.enabled=YES;
  163. // [sender setTitle:@"获取验证码" forState:UIControlStateNormal];
  164. // sender.frame = CGRectMake(sender.left, sender.top, 66, sender.height);
  165. // return;
  166. // }
  167. // code--;
  168. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  169. // [self verificationCode:code sender:sender];
  170. // });
  171. //}
  172. //
  173. //#pragma mark - 确定
  174. //- (void)touchConfirm
  175. //{
  176. // if ([self verification:@"已下发短信验证码"]) {
  177. //
  178. // }
  179. //};
  180. - (void)didReceiveMemoryWarning {
  181. [super didReceiveMemoryWarning];
  182. // Dispose of any resources that can be recreated.
  183. }
  184. /*
  185. #pragma mark - Navigation
  186. // In a storyboard-based application, you will often want to do a little preparation before navigation
  187. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  188. // Get the new view controller using [segue destinationViewController].
  189. // Pass the selected object to the new view controller.
  190. }
  191. */
  192. @end