SettingsPasswdSetViewController.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // SettingsPasswdSetViewController.m
  3. // OneCable
  4. //
  5. // Created by nComz on 2017. 4. 19..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "SettingsPasswdSetViewController.h"
  9. #import "CustomTextField.h"
  10. #import "CustomButton.h"
  11. #import "CustomLabel.h"
  12. #import "RequestHandler.h"
  13. #import "ValidateUtil.h"
  14. @interface SettingsPasswdSetViewController () <CustomTextFieldDelegate>
  15. @end
  16. @implementation SettingsPasswdSetViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self initUI];
  20. }
  21. - (void)initUI {
  22. UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
  23. statusBar.backgroundColor = [UIColor whiteColor];
  24. _btnSave.enabled = NO;
  25. [self.navigationController.navigationBar setHidden:YES];
  26. self.navigationController.interactivePopGestureRecognizer.enabled = NO;
  27. }
  28. #pragma mark - User Event
  29. - (IBAction)btnCancelTouched:(id)sender {
  30. [[self navigationController] popToRootViewControllerAnimated:YES];
  31. }
  32. - (IBAction)btnSaveTouched:(id)sender {
  33. if (![ValidateUtil validateTextfiled:_txtInputPasswd type:ValidateTypePassword title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
  34. return;
  35. }
  36. if (![_txtInputPasswd.text isEqualToString:_txtInputRePasswd.text]) {
  37. [[JDFacade facade] alert:NSLocalizedString(@"재입력된 비밀번호가 다릅니다.", @"재입력된 비밀번호가 다릅니다.")];
  38. return;
  39. }
  40. [self requestChangePass];
  41. }
  42. #pragma mark - text field delegate
  43. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  44. if ([textField isEqual:_txtInputRePasswd]) {
  45. [textField resignFirstResponder];
  46. }
  47. else {
  48. [_txtInputRePasswd becomeFirstResponder];
  49. }
  50. return YES;
  51. }
  52. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  53. NSString *text = [textField.text stringByReplacingCharactersInRange:range withString:string];
  54. _btnSave.enabled = text.length >= 8;
  55. return YES;
  56. }
  57. - (void)didReceiveMemoryWarning {
  58. [super didReceiveMemoryWarning];
  59. }
  60. //비번 바꾸기
  61. - (void)requestChangePass {
  62. //parameters
  63. NSDictionary *parameter = @{@"type": @"password" ,
  64. @"password": _txtInputPasswd.text.trim};
  65. NSString *path = [[JDFacade facade] getUrlWithCustGroupIDAndMemberID:API_PUT_MEMBER_UPDATE];
  66. //NSLog(@"path : %@ ", path);
  67. [[RequestHandler handler] sendAsyncPutRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  68. [[self navigationController] popToRootViewControllerAnimated:YES];
  69. } failure:^(id errorObject) {
  70. JDErrorModel *error = (JDErrorModel *)errorObject;
  71. [[JDFacade facade] alert:error.errorMessage];
  72. }];
  73. }
  74. @end