BogoYoungModeBlindPhoneVC.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // BogoYoungModeBlindPhoneVC.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/9/13.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoYoungModeBlindPhoneVC.h"
  9. #import "BogoYouthModePassWordViewController.h"
  10. #import "BogoNetworkKit.h"
  11. #import "AccSecModel.h"
  12. #import "AccSecModel.h"
  13. @interface BogoYoungModeBlindPhoneVC ()
  14. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  15. @property (weak, nonatomic) IBOutlet QMUIButton *mobileBtn;
  16. @property (weak, nonatomic) IBOutlet UITextField *blindT;
  17. @property (weak, nonatomic) IBOutlet UIButton *nextBtn;
  18. @property (weak, nonatomic) IBOutlet UIView *codeView;
  19. @property (weak, nonatomic) IBOutlet UIButton *codeBtn;
  20. @property (weak, nonatomic) IBOutlet UITextField *codeT;
  21. @end
  22. @implementation BogoYoungModeBlindPhoneVC{
  23. NSTimer *_timer; //定时器
  24. int _timeCount; //定时器时间
  25. }
  26. - (instancetype)initWithBlindType:(BOGO_YOUNTH_BLIND_TYPE)type{
  27. BogoYoungModeBlindPhoneVC *vc = [BogoYoungModeBlindPhoneVC new];
  28. vc.type = type;
  29. return vc;
  30. }
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. // Do any additional setup after loading the view from its nib.
  34. // [self.navigationItem setHidesBackButton:YES animated:YES];
  35. //
  36. //  self.navigationItem.leftBarButtonItem = nil;
  37. _timeCount = 60;
  38. [self setupBackBtnWithBlock:nil];
  39. [self replaceChangeType];
  40. if (StrValid(self.phoneNum)) {
  41. [self clickCodeBtn:self.codeBtn];
  42. }
  43. }
  44. - (void)setPhoneNum:(NSString *)phoneNum{
  45. _phoneNum = phoneNum;
  46. [self replaceChangeType];
  47. }
  48. -(void)replaceChangeType{
  49. NSString *contentStr = ASLocalizedString(@"启动青少年模式需要先设置独立密码,修改或者关闭青少年模式都需要此密码。");
  50. if (self.type == BOGO_YOUNTH_BLIND_TYPE_PHONE) {
  51. self.navigationItem.title = ASLocalizedString(@"验证手机号");
  52. contentStr = ASLocalizedString(@"请输入绑定的手机号,通过验证码验证后,即可关闭青少年模式。");
  53. [self.nextBtn setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  54. self.codeView.hidden = YES;
  55. }else if (self.type == BOGO_YOUNTH_BLIND_TYPE_CODE) {
  56. self.navigationItem.title = ASLocalizedString(@"输入验证码");
  57. contentStr = [NSString stringWithFormat:@"%@%@",ASLocalizedString(@"验证码已发送至"),self.phoneNum];
  58. [self.nextBtn setTitle:ASLocalizedString(@"确定") forState:UIControlStateNormal];
  59. self.codeView.hidden = NO;
  60. }
  61. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  62. paragraphStyle.lineSpacing = 4; //设置行间距
  63. paragraphStyle.lineBreakMode = _titleLabel.lineBreakMode;
  64. paragraphStyle.alignment = NSTextAlignmentLeft;
  65. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:contentStr];
  66. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14.0],
  67. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#333333"],
  68. NSParagraphStyleAttributeName:paragraphStyle};
  69. [attributedString setAttributes:attributes range:NSMakeRange(0, attributedString.length)];
  70. _titleLabel.attributedText = attributedString;
  71. }
  72. #pragma mark 获取验证码的倒计时
  73. - (void)timego
  74. {
  75. [self timerDec:_timeCount];
  76. }
  77. - (void)timerDec:(NSInteger)time
  78. {
  79. if(time > 0)
  80. {
  81. [self.codeBtn setTitle:[NSString stringWithFormat:@"%@(%lds)",ASLocalizedString(@"重新获取"), (long)time] forState:UIControlStateDisabled];
  82. // [self.loginView.codeBtn setTitleColor:kAppGrayColor1 forState:UIControlStateDisabled];
  83. _timeCount --;
  84. }else if(time == 0)
  85. {
  86. self.codeBtn.enabled = YES;
  87. [self.codeBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"获取验证码")] forState:UIControlStateNormal];
  88. [_timer invalidate];
  89. _timeCount = 60;
  90. }
  91. }
  92. - (IBAction)clickCodeBtn:(UIButton *)sender {
  93. _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timego) userInfo:nil repeats:YES];
  94. [self timego];
  95. self.codeBtn.enabled = NO;
  96. FWWeakify(self)
  97. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  98. [parmDict setObject:@"login" forKey:@"ctl"];
  99. [parmDict setObject:@"send_mobile_verify_international" forKey:@"act"];
  100. // [parmDict setObject:@"1" forKey:@"wx_binding"];
  101. [parmDict setObject:self.phoneNum forKey:@"mobile"];
  102. [self showMyHud];
  103. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  104. {
  105. FWStrongify(self)
  106. [self hideMyHud];
  107. [GlobalVariables sharedInstance].otp_message_id = [NSString stringWithFormat:@"%@",[responseJson toString:@"otp_message_id"]];
  108. if ([responseJson toInt:@"status"] != 1)
  109. {
  110. self.codeBtn.enabled = YES;
  111. [self.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
  112. [_timer invalidate];
  113. _timer = nil;
  114. }
  115. } FailureBlock:^(NSError *error) {
  116. FWStrongify(self)
  117. [self hideMyHud];
  118. [self.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
  119. [FanweMessage alert:ASLocalizedString(@"发送失败")];
  120. self.codeBtn.enabled = YES;
  121. }];
  122. }
  123. - (IBAction)clickNextBtn:(UIButton *)sender {
  124. if (self.type == BOGO_YOUNTH_BLIND_TYPE_PHONE) {
  125. if (self.blindT.text.length < 1) {
  126. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
  127. return;
  128. }
  129. NSMutableDictionary *dict = [NSMutableDictionary new];
  130. [dict setValue:@"settings" forKey:@"ctl"];
  131. [dict setValue:@"security" forKey:@"act"];
  132. [dict setObject:[IMAPlatform sharedInstance].host.imUserId forKey:@"to_user_id"];
  133. [self.httpsManager POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  134. AccSecModel *model = [AccSecModel mj_objectWithKeyValues:responseJson];
  135. if ([model.mobile isEqualToString:self.blindT.text]) {
  136. BogoYoungModeBlindPhoneVC *vc = [[BogoYoungModeBlindPhoneVC alloc]initWithBlindType:BOGO_YOUNTH_BLIND_TYPE_CODE];
  137. vc.phoneNum = self.blindT.text;
  138. [self.navigationController pushViewController:vc animated:YES];
  139. }else{
  140. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"输入的手机号与绑定的手机号不一致")];
  141. }
  142. } FailureBlock:^(NSError *error) {
  143. }];
  144. }else if (self.type == BOGO_YOUNTH_BLIND_TYPE_CODE){
  145. // /shopapi/young/forgetPass?token=499bf32dd443dbbb57156d295057e5c7&phone=15053896991&code=8966
  146. NSMutableDictionary *paramDic = [NSMutableDictionary dictionary];
  147. [paramDic setObject:self.phoneNum forKey:@"phone"];
  148. [paramDic setObject:self.codeT.text forKey:@"code"];
  149. [[BogoNetwork shareInstance]GET:@"young/forgetPass" param:paramDic success:^(BogoNetworkResponseModel * _Nonnull result) {
  150. [GlobalVariables sharedInstance].isShutDownYoung = YES;
  151. [self.navigationController popToRootViewControllerAnimated:YES];
  152. } failure:^(NSString * _Nonnull error) {
  153. [[FDHUDManager defaultManager] show:error ToView:self.view];
  154. }];
  155. }
  156. }
  157. /*
  158. #pragma mark - Navigation
  159. // In a storyboard-based application, you will often want to do a little preparation before navigation
  160. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  161. // Get the new view controller using [segue destinationViewController].
  162. // Pass the selected object to the new view controller.
  163. }
  164. */
  165. @end