BogoLogoutViewController.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. //
  2. // BogoLogoutViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/9/29.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoLogoutViewController.h"
  9. #import "BogoChoiceAreaModel.h"
  10. @interface BogoLogoutViewController ()<UITextFieldDelegate,UITextViewDelegate>
  11. @property (weak, nonatomic) IBOutlet UITextField *phoneT;
  12. @property (weak, nonatomic) IBOutlet QMUIButton *areaBtn;
  13. @property (weak, nonatomic) IBOutlet UITextField *codeT;
  14. @property (weak, nonatomic) IBOutlet QMUIButton *codeBtn;
  15. @property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
  16. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraint;
  17. @property(nonatomic, strong) BogoChoiceAreaModel *areaModel;
  18. @end
  19. @implementation BogoLogoutViewController{
  20. NSTimer *_timer; //定时器
  21. int _timeCount; //定时器时间
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. // Do any additional setup after loading the view from its nib.
  26. self.phoneT.delegate = self;
  27. [self.phoneT addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  28. self.phoneT.keyboardType = UIKeyboardTypeNumberPad;
  29. self.codeT.delegate = self;
  30. [self.codeT addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  31. self.codeT.keyboardType = UIKeyboardTypeNumberPad;
  32. self.areaBtn.imagePosition = QMUIButtonImagePositionRight;
  33. self.areaBtn.spacingBetweenImageAndTitle = 3;
  34. self.topConstraint.constant = kStatusBarHeight;
  35. self.confirmBtn.enabled = NO;
  36. _timeCount = 60;
  37. }
  38. -(void)textFieldDidChange:(UITextField *)textField{
  39. if (self.phoneT.text.length > 11) {
  40. self.phoneT.text = [textField.text substringToIndex:11];
  41. [FanweMessage alertHUD:ASLocalizedString(@"手机号限制11位数!")];
  42. }
  43. if (self.phoneT.text.length == 11 && self.codeT.text.length > 3) {
  44. self.confirmBtn.enabled = YES;
  45. }else{
  46. self.confirmBtn.enabled = NO;
  47. }
  48. }
  49. - (IBAction)clickCancleBtn:(QMUIButton *)sender {
  50. [self.navigationController popViewControllerAnimated:YES];
  51. }
  52. - (IBAction)clickAreaBtn:(QMUIButton *)sender {
  53. }
  54. - (IBAction)clickCodeBtn:(QMUIButton *)sender {
  55. if (self.phoneT.text.length == 0)
  56. {
  57. [FanweMessage alertHUD:ASLocalizedString(@"请输入手机号!")];
  58. return;
  59. }
  60. if (self.phoneT.text.length < 1)
  61. {
  62. [FanweMessage alertHUD:ASLocalizedString(@"手机号限制11位数!")];
  63. return;
  64. }
  65. if (![self.phoneT.text isEqualToString:_phoneNum]) {
  66. [FanweMessage alertHUD:ASLocalizedString(@"您输入的手机号与当前账号不符!")];
  67. return;
  68. }
  69. self.codeBtn.enabled = NO;
  70. _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timego) userInfo:nil repeats:YES];
  71. [self timego];
  72. FWWeakify(self)
  73. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  74. [parmDict setObject:@"login" forKey:@"ctl"];
  75. [parmDict setObject:@"send_mobile_verify_international" forKey:@"act"];
  76. // [parmDict setObject:@"1" forKey:@"wx_binding"];
  77. [parmDict setObject:self.phoneT.text forKey:@"mobile"];
  78. [self showMyHud];
  79. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  80. {
  81. FWStrongify(self)
  82. [self hideMyHud];
  83. [GlobalVariables sharedInstance].otp_message_id = [NSString stringWithFormat:@"%@",[responseJson toString:@"otp_message_id"]];
  84. if ([responseJson toInt:@"status"] != 1)
  85. {
  86. self.codeBtn.enabled = YES;
  87. [self.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
  88. [_timer invalidate];
  89. _timer = nil;
  90. }else{
  91. }
  92. } FailureBlock:^(NSError *error) {
  93. FWStrongify(self)
  94. [self hideMyHud];
  95. [self.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
  96. [FanweMessage alert:ASLocalizedString(@"发送失败")];
  97. self.codeBtn.enabled = YES;
  98. }];
  99. }
  100. //注销
  101. -(void)phoneUnsubscribe{
  102. if (![self.phoneT.text isEqualToString:_phoneNum]) {
  103. [FanweMessage alertHUD:ASLocalizedString(@"您输入的手机号与当前账号不符!")];
  104. return;
  105. }
  106. FWWeakify(self)
  107. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  108. [parmDict setObject:@"login" forKey:@"ctl"];
  109. [parmDict setObject:@"unsubscribe" forKey:@"act"];
  110. [parmDict setObject:self.phoneT.text forKey:@"mobile"];
  111. [parmDict setObject:self.codeT.text forKey:@"code"];
  112. [self showMyHud];
  113. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  114. {
  115. FWStrongify(self)
  116. [self hideMyHud];
  117. if ([responseJson toInt:@"status"] == 1)
  118. {
  119. [self.navigationController popToRootViewControllerAnimated:NO];
  120. [[AppDelegate sharedAppDelegate] enterLoginUI];
  121. }else{
  122. }
  123. [FanweMessage alertHUD:[responseJson toString:@"error"]];
  124. } FailureBlock:^(NSError *error) {
  125. FWStrongify(self)
  126. [FanweMessage alertHUD:error.description];
  127. [self hideMyHud];
  128. }];
  129. }
  130. #pragma mark 获取验证码的倒计时
  131. - (void)timego
  132. {
  133. [self timerDec:_timeCount];
  134. }
  135. - (void)timerDec:(NSInteger)time
  136. {
  137. if(time > 0)
  138. {
  139. [self.codeBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"重新获取(%lds)"),(long)time] forState:UIControlStateNormal];
  140. // [self.loginView.codeBtn setTitleColor:kAppGrayColor1 forState:UIControlStateDisabled];
  141. _timeCount --;
  142. }else if(time == 0)
  143. {
  144. self.codeBtn.enabled = YES;
  145. [self.codeBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"重新获取验证码")] forState:UIControlStateNormal];
  146. [_timer invalidate];
  147. _timeCount = 60;
  148. }
  149. }
  150. - (IBAction)clickConfrimBtn:(id)sender {
  151. if (self.phoneT.text.length == 0)
  152. {
  153. [FanweMessage alertHUD:ASLocalizedString(@"请输入手机号!")];
  154. return;
  155. }
  156. if (self.phoneT.text.length < 1)
  157. {
  158. [FanweMessage alertHUD:ASLocalizedString(@"手机号限制11位数!")];
  159. return;
  160. }
  161. [FanweMessage alert:@"" message:ASLocalizedString(@"确认注销该账户?") destructiveAction:^{
  162. [self phoneUnsubscribe];
  163. } cancelAction:^{
  164. }];
  165. }
  166. /*
  167. #pragma mark - Navigation
  168. // In a storyboard-based application, you will often want to do a little preparation before navigation
  169. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  170. // Get the new view controller using [segue destinationViewController].
  171. // Pass the selected object to the new view controller.
  172. }
  173. */
  174. @end