JXAccountPwd.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // JXAccountPwd.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/26.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXAccountPwd.h"
  9. #import "JXForgetPwdVc.h"
  10. #import "PSRegisterBaseVC.h"
  11. #import "forgetPwdVC.h"
  12. @interface JXAccountPwd ()
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topVIewH;
  14. @property (weak, nonatomic) IBOutlet UITextField *jixinNo;
  15. /**原密码*/
  16. @property (weak, nonatomic) IBOutlet UITextField *oPwdTF;
  17. @property (weak, nonatomic) IBOutlet UITextField *nPwdTF;
  18. @property (weak, nonatomic) IBOutlet UITextField *qrPwdTF;
  19. @end
  20. @implementation JXAccountPwd
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view from its nib.
  24. self.topVIewH.constant=JX_SCREEN_TOP;
  25. [self defineNavBarXXX:@"即信密码" andRinghtBtnImg:@"完成"];
  26. [self.rightBtn addTarget:self action:@selector(rightBtnCLick) forControlEvents:UIControlEventTouchUpInside];
  27. self.jixinNo.text=[NSString stringWithFormat:@"%@",g_server.myself.telephone];
  28. }
  29. /**
  30. * 完成。
  31. */
  32. - (void)rightBtnCLick{
  33. ///user/vip/info /user/vip/info
  34. // [g_server getact_act_userGradelistGrade:salt andToView:self];
  35. if([_oPwdTF.text length]<=0){
  36. [g_App showAlert:Localized(@"JX_InputPassWord")];
  37. return;
  38. }
  39. if([_qrPwdTF.text length]<=0){
  40. [g_App showAlert:Localized(@"JX_ConfirmPassWord")];
  41. return;
  42. }
  43. if(![_qrPwdTF.text isEqualToString:_nPwdTF.text]){
  44. [g_App showAlert:Localized(@"JX_PasswordFiled")];
  45. return;
  46. }
  47. [self.view endEditing:YES];
  48. [SVProgressHUD showWithStatus:@"正在修改"];
  49. NSString *areaCode = [@"86" stringByReplacingOccurrencesOfString:@"+" withString:@""];
  50. [g_server updatePwd:_jixinNo.text areaCode:areaCode oldPwd:_oPwdTF.text newPwd:_nPwdTF.text checkCode:nil toView:self];
  51. }
  52. - (IBAction)forGetPwdBtn:(id)sender {
  53. [self onSend];
  54. // JXForgetPwdVc *vc=[JXForgetPwdVc new];
  55. // [g_navigation pushViewController:vc animated:YES];
  56. }
  57. -(void)onSend{
  58. //[_nPwdTF resignFirstResponder];
  59. forgetPwdVC* vc = [[forgetPwdVC alloc] init];
  60. vc.isModify = NO;
  61. // [g_window addSubview:vc.view];
  62. [g_navigation pushViewController:vc animated:YES];
  63. // NSString *areaCode = [@"86" stringByReplacingOccurrencesOfString:@"+" withString:@""];
  64. // // _user = [JXUserObject sharedInstance];
  65. // [g_server sendSMS:[NSString stringWithFormat:@"%@",_jixinNo.text] areaCode:areaCode isRegister:NO imgCode:@"123" toView:self];
  66. }
  67. - (void)backGo{
  68. [g_server stopConnection:self];
  69. [g_window endEditing:YES];
  70. [g_notify removeObserver:self];
  71. [g_navigation dismissViewController:self animated:YES];
  72. }
  73. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  74. [SVProgressHUD dismiss];
  75. if([aDownload.action isEqualToString:act_SendSMS]){
  76. //_send.enabled = YES;
  77. //_send.selected = YES;
  78. //_send.userInteractionEnabled = NO;
  79. //_send.backgroundColor = [UIColor grayColor];
  80. //_smsCode = [[dict objectForKey:@"code"] copy];
  81. // [_send setTitle:@"60s" forState:UIControlStateSelected];
  82. //_seconds = 60;
  83. //timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showTime:) userInfo:_send repeats:YES];
  84. }
  85. if([aDownload.action isEqualToString:act_PwdUpdate] || [aDownload.action isEqualToString:act_PwdUpdateV1]){
  86. [g_App showAlert:Localized(@"JX_UpdatePassWordOK")];
  87. g_myself.password = [g_server getMD5String:_nPwdTF.text];
  88. [g_default setObject:[g_server getMD5String:_nPwdTF.text] forKey:kMY_USER_PASSWORD];
  89. [g_default synchronize];
  90. //[self actionQuit];
  91. [self performSelector:@selector(backGo)];
  92. //[self relogin];
  93. }
  94. if([aDownload.action isEqualToString:act_PwdReset] || [aDownload.action isEqualToString:act_PwdResetV1]){
  95. [g_App showAlert:Localized(@"JX_UpdatePassWordOK")];
  96. g_myself.password = [g_server getMD5String:_nPwdTF.text];
  97. [g_default setObject:[g_server getMD5String:_nPwdTF.text] forKey:kMY_USER_PASSWORD];
  98. [g_default synchronize];
  99. // [self actionQuit];
  100. }
  101. if ([aDownload.action isEqualToString:act_UserGetRandomStr]) {
  102. NSString *checkCode = nil;
  103. #ifdef IS_MsgEncrypt
  104. NSString *userRandomStr = [dict objectForKey:@"userRandomStr"];
  105. SecKeyRef privateKey = [g_securityUtil getRSAKeyWithBase64Str:g_msgUtil.rsaPrivateKey isPrivateKey:YES];
  106. NSData *randomData = [[NSData alloc] initWithBase64EncodedString:userRandomStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
  107. NSData *codeData = [g_securityUtil decryptMessageRSA:randomData withPrivateKey:privateKey];
  108. checkCode = [[NSString alloc] initWithData:codeData encoding:NSUTF8StringEncoding];
  109. #endif
  110. NSString *areaCode = [@"86" stringByReplacingOccurrencesOfString:@"+" withString:@""];
  111. [g_server updatePwd:_jixinNo.text areaCode:areaCode oldPwd:_oPwdTF.text newPwd:_nPwdTF.text checkCode:checkCode toView:self];
  112. }
  113. if ([aDownload.action isEqualToString:act_AuthkeysResetPayPassword]) {
  114. if ([self.delegate respondsToSelector:@selector(forgetPwdSuccess)]) {
  115. //[self actionQuit];
  116. [self.delegate forgetPwdSuccess];
  117. }
  118. }
  119. }
  120. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  121. if([aDownload.action isEqualToString:act_SendSMS]){
  122. //[_send setTitle:Localized(@"JX_SendAngin") forState:UIControlStateNormal];
  123. //_send.enabled = YES;
  124. }else if ([aDownload.action isEqualToString:act_PwdUpdate] || [aDownload.action isEqualToString:act_PwdUpdateV1]) {
  125. NSString *error = [dict objectForKey:@"resultMsg"];
  126. [g_App showAlert:[NSString stringWithFormat:@"%@",error]];
  127. return 1;
  128. }
  129. [SVProgressHUD dismiss];
  130. return 1;
  131. }
  132. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  133. [SVProgressHUD dismiss];
  134. // _send.enabled = YES;
  135. return show_error;
  136. }
  137. -(void) didServerConnectStart:(JXConnection*)aDownload{
  138. [SVProgressHUD dismiss];
  139. }
  140. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  141. [self.view endEditing:YES];
  142. }
  143. @end