MOBingMobileVC.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //
  2. // MOBingMobileVC.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/31.
  6. //
  7. #import "MOBingMobileVC.h"
  8. #import "MOSelectPartitionVC.h"
  9. #import "MOSetPasswordSMS.h"
  10. #import "MOLoginManager.h"
  11. #import "UITextField+CustomClearButton.h"
  12. @interface MOBingMobileVC ()
  13. @property (weak, nonatomic) IBOutlet UILabel *topTipLab;
  14. @property (weak, nonatomic) IBOutlet UIView *phoneBgView;
  15. @property (weak, nonatomic) IBOutlet UIView *countryNumBgView;
  16. @property (weak, nonatomic) IBOutlet BigBtn *countryBtn;
  17. @property (weak, nonatomic) IBOutlet UITextField *mobileTxf;
  18. @property (weak, nonatomic) IBOutlet UIButton *nextBtn;
  19. @end
  20. @implementation MOBingMobileVC
  21. - (void)viewWillAppear:(BOOL)animated{
  22. [super viewWillAppear:animated];
  23. [self.navigationController setNavigationBarHidden:NO animated:animated];
  24. [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
  25. }
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. if (self.forgetPwd) {
  29. self.navigationItem.title = NSLocalString(@"mimo_reset_psw_title");
  30. } else {
  31. self.navigationItem.title = NSLocalString(@"mimo_setting_mobile");
  32. }
  33. [self setupUI];
  34. }
  35. - (IBAction)countryChangeBtnClick:(id)sender {
  36. WEAKSELF
  37. MOSelectPartitionVC *vc = [[MOSelectPartitionVC alloc] init];
  38. vc.selectCellBlock = ^(MOCountryList * _Nonnull model) {
  39. [weakSelf.countryBtn setTitle:model.num forState:UIControlStateNormal];
  40. };
  41. [self.navigationController pushViewController:vc animated:YES];
  42. }
  43. - (BOOL)isStringNumeric:(NSString *)string {
  44. NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
  45. NSRange range = [string rangeOfCharacterFromSet:nonDigitCharacterSet];
  46. return range.location == NSNotFound;
  47. }
  48. - (IBAction)nextBtnClick:(id)sender {
  49. [self.view endEditing:YES];
  50. //验证码登录
  51. if(self.mobileTxf.text.length == 0)
  52. {
  53. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_phone")];
  54. return;
  55. }
  56. //手机号必须全数字
  57. if([self isStringNumeric:self.mobileTxf.text] == NO){
  58. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_check_phone_num_tip")];
  59. return;
  60. }
  61. typeof(self) __weak weakSelf = self;
  62. if(self.isBingNewPhone){
  63. MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
  64. vc.vcType = MOEnterChangeNewPhoneCode;
  65. vc.code = self.countryBtn.titleLabel.text;
  66. vc.num = self.mobileTxf.text;
  67. vc.credentials = self.credentials;
  68. vc.isHaveSendCode = YES;
  69. [vc toGetNewPhoneCodeAndBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  70. __strong typeof(weakSelf) self = weakSelf;
  71. if(kCode_Success){
  72. if(self){
  73. [self.navigationController pushViewController:vc animated:YES];
  74. }
  75. }
  76. else{
  77. kShowNetError(data)
  78. }
  79. }];
  80. return;
  81. }
  82. if (self.forgetPwd) {
  83. MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
  84. vc.code = self.countryBtn.titleLabel.text;
  85. vc.num = self.mobileTxf.text;
  86. vc.vcType = MOEnterCodeReSetPasswordType;
  87. vc.isHaveSendCode = YES;
  88. NSDictionary *dic = @{@"code":self.countryBtn.titleLabel.text,
  89. @"num":self.mobileTxf.text};
  90. [kHttpManager toGetPasswordCode2WithParams:dic andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  91. [MBProgressHUD hideHUD];
  92. if(kCode_Success){
  93. [self.navigationController pushViewController:vc animated:YES];
  94. }
  95. else{
  96. kShowNetError(data)
  97. }
  98. }];
  99. return;
  100. }
  101. MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
  102. vc.vcType = MOEnterCodeBindPhoneType;
  103. vc.code = self.countryBtn.titleLabel.text;
  104. vc.num = self.mobileTxf.text;
  105. vc.isHaveSendCode = YES;
  106. [vc toGetSMSCodeWithBindPhoneAndBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  107. __strong typeof(weakSelf) self = weakSelf;
  108. if(kCode_Success){
  109. if(self){
  110. [self.navigationController pushViewController:vc animated:YES];
  111. }
  112. }
  113. else{
  114. kShowNetError(data)
  115. }
  116. }];
  117. }
  118. - (void)toPopVC{
  119. [self.navigationController popViewControllerAnimated:YES];
  120. }
  121. - (void)viewWillLayoutSubviews {
  122. [super viewWillLayoutSubviews];
  123. [self.phoneBgView setupGradientLayerWithView:self.phoneBgView
  124. startColor:[MOTools colorWithHexString:@"#FFFFFF"]
  125. endColor:[MOTools colorWithHexString:@"#FFFFFF"]
  126. layerName:@"gradientLayer"
  127. startPoint:(CGPoint) { 0.5, 0 }
  128. endPoint:(CGPoint){0.5, 1}];
  129. }
  130. - (void)setupUI {
  131. self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
  132. if (self.forgetPwd) {
  133. self.topTipLab.text = NSLocalString(@"mimo_login_hint_phone");
  134. } else {
  135. self.topTipLab.text = NSLocalString(@"mimo_setting_mobile_sub_title");
  136. }
  137. self.topTipLab.font = [MOTextTools regularFont:14];
  138. self.topTipLab.textColor = kBaseTextColor_1;
  139. self.mobileTxf.keyboardType = UIKeyboardTypeNumberPad;
  140. [self.mobileTxf setFont:[MOTextTools poppinsMediumFont:18]];
  141. self.mobileTxf.textColor = [MOTools colorWithHexString:@"#111111"];
  142. // self.mobileTxf.clearButtonMode = UITextFieldViewModeWhileEditing;
  143. self.mobileTxf.clearButtonMode = UITextFieldViewModeNever;
  144. UIImage *clearIcon = [UIImage imageNamed:@"icon_textfield_clear"];
  145. [self.mobileTxf enableCustomClearButtonWithImage:clearIcon];
  146. NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:NSLocalString(@"mimo_login_hint_phone") attributes:@{
  147. NSForegroundColorAttributeName : [MOTools colorWithHexString:@"#DADCE6"],
  148. NSFontAttributeName : [MOTextTools poppinsRegularFont:16]
  149. }];
  150. self.mobileTxf.attributedPlaceholder = placeholderString;
  151. [self.mobileTxf addTarget:self action:@selector(mobileFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  152. [self.countryBtn setFont:[MOTextTools poppinsMediumFont:18]];
  153. [self.countryBtn setTitleColor:[MOTools colorWithHexString:@"#111111"] forState:UIControlStateNormal];
  154. [self.nextBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
  155. NSArray *loginColorArr = @[kBaseColorLeft,kBaseColorRight];
  156. UIImage *loginImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 20.0 * 2), 48.0) Colors:loginColorArr GradientType:0];
  157. [self.nextBtn setBackgroundImage:loginImage forState:UIControlStateNormal];
  158. self.nextBtn.layer.cornerRadius = 12;
  159. self.nextBtn.layer.masksToBounds = YES;
  160. self.nextBtn.titleLabel.font = [MOTextTools mediumFont:16];
  161. [self.nextBtn setTitleColor:[MOTools colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
  162. self.nextBtn.alpha = 0.5;
  163. self.phoneBgView.layer.cornerRadius = 12.0;
  164. self.phoneBgView.layer.masksToBounds = YES;
  165. self.phoneBgView.layer.borderColor = [MOTools colorWithHexString:@"#FFFFFF"].CGColor;
  166. self.phoneBgView.layer.borderWidth = 1;
  167. self.countryNumBgView.layer.cornerRadius = 6.0;
  168. self.countryNumBgView.layer.masksToBounds = YES;
  169. //右图左文
  170. self.countryBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
  171. self.countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  172. [self setupCountryCode];
  173. }
  174. - (void)setupCountryCode {
  175. WEAKSELF
  176. [[MOLoginManager shareManager] getCountryIpComplete:^(NSString * _Nonnull ip) {
  177. [weakSelf.countryBtn setTitle:ip forState:UIControlStateNormal];
  178. }];
  179. }
  180. - (void)mobileFieldDidChange:(UITextField *)textField {
  181. self.nextBtn.alpha = textField.text.length > 0 ? 1.0 : 0.5;
  182. }
  183. @end