MOGuildSMSVC.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // MOGuildSMSVC.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/26.
  6. //
  7. #import "MOGuildSMSVC.h"
  8. #import "MOSelectPartitionVC.h"
  9. #import "MOGuildApplyVC.h"
  10. @interface MOGuildSMSVC ()
  11. /** 返回按钮距离顶部的距离 */
  12. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *backBtnTop;
  13. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  14. @property (weak, nonatomic) IBOutlet UIView *phoneBgView;
  15. @property (weak, nonatomic) IBOutlet UIView *codeBgView;
  16. @property (weak, nonatomic) IBOutlet UIView *countryNumBgView;
  17. @property (weak, nonatomic) IBOutlet UIImageView *countryImg;
  18. @property (weak, nonatomic) IBOutlet BigBtn *countryBtn;
  19. @property (weak, nonatomic) IBOutlet UITextField *mobileTxf;
  20. @property (weak, nonatomic) IBOutlet UITextField *codeTxf;
  21. @property (weak, nonatomic) IBOutlet UIButton *nextBtn;
  22. /** 最终校验的结果 */
  23. @property (nonatomic, copy) NSString *resultString;
  24. @end
  25. @implementation MOGuildSMSVC
  26. - (void)viewWillAppear:(BOOL)animated{
  27. [super viewWillAppear:animated];
  28. [self.navigationController setNavigationBarHidden:YES animated:animated];
  29. }
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. // Do any additional setup after loading the view from its nib.
  33. [self setupUI];
  34. }
  35. - (IBAction)backBtnClick:(id)sender {
  36. [self.navigationController popViewControllerAnimated:YES];
  37. }
  38. - (IBAction)countryChangeBtnClick:(id)sender {
  39. WEAKSELF
  40. MOSelectPartitionVC *vc = [[MOSelectPartitionVC alloc] init];
  41. vc.selectCellBlock = ^(MOCountryList * _Nonnull model) {
  42. __strong typeof(weakSelf) self = weakSelf;
  43. [self.countryBtn setTitle:model.num forState:UIControlStateNormal];
  44. };
  45. [self.navigationController pushViewController:vc animated:YES];
  46. }
  47. //获取验证码
  48. - (IBAction)sendSmsBtnClick:(id)sender {
  49. if(self.mobileTxf.text.length == 0)
  50. {
  51. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_phone")];
  52. return;
  53. }
  54. [MBProgressHUD showActivityMessageInView:@""];
  55. WEAKSELF
  56. NSDictionary *dic = @{@"code":self.countryBtn.titleLabel.text,
  57. @"num":self.mobileTxf.text};
  58. [kHttpManager toGetGuildMobileCodeWithParams:dic andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  59. [MBProgressHUD hideHUD];
  60. if(kCode_Success){
  61. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_verify_code")];
  62. [weakSelf.codeTxf becomeFirstResponder];
  63. }
  64. else{
  65. kShowNetError(data)
  66. }
  67. }];
  68. }
  69. //校验手机验证码
  70. - (IBAction)nextBtnClick:(id)sender {
  71. //验证码登录
  72. if(self.mobileTxf.text.length == 0)
  73. {
  74. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_phone")];
  75. return;
  76. }
  77. if(self.codeTxf.text.length == 0){
  78. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_verify_code")];
  79. return;
  80. }
  81. [MBProgressHUD showActivityMessageInView:@""];
  82. WEAKSELF
  83. NSDictionary *mobileDict = @{@"code":self.countryBtn.titleLabel.text,
  84. @"num":self.mobileTxf.text};
  85. NSDictionary *dict = @{@"mobile":mobileDict,
  86. @"code":self.codeTxf.text};
  87. [kHttpManager toGetGuildApplyVerifyMobileWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  88. [MBProgressHUD hideHUD];
  89. if(kCode_Success){
  90. weakSelf.resultString = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
  91. MOGuildApplyVC *vc = [[MOGuildApplyVC alloc] init];
  92. vc.resultString = weakSelf.resultString;
  93. [weakSelf.navigationController pushViewController:vc animated:YES];
  94. }
  95. else{
  96. kShowNetError(data)
  97. }
  98. }];
  99. }
  100. - (void)setupUI{
  101. self.titleLab.text = NSLocalString(@"mimo_guild_apply_to_settle_in_title");
  102. self.mobileTxf.placeholder = NSLocalString(@"mimo_login_hint_phone");
  103. self.codeTxf.placeholder = NSLocalString(@"mimo_login_hint_verify_code");
  104. [self.nextBtn setTitle:NSLocalString(@"mimo_anchor_next") forState:UIControlStateNormal];
  105. CGFloat statusBarHeight = STATUS_BAR_HEIGHT;
  106. self.backBtnTop.constant = statusBarHeight + 12.0;
  107. self.phoneBgView.layer.cornerRadius = 12.0;
  108. self.phoneBgView.layer.masksToBounds = YES;
  109. self.countryNumBgView.layer.cornerRadius = 6.0;
  110. self.countryNumBgView.layer.masksToBounds = YES;
  111. //右图左文
  112. self.countryBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
  113. self.countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  114. self.codeBgView.layer.cornerRadius = 12.0;
  115. self.codeBgView.layer.masksToBounds = YES;
  116. NSArray *colorArr = @[[MOTools colorWithHexString:@"#FF62EE" alpha:1.0],[MOTools colorWithHexString:@"#9923FF" alpha:1.0]];
  117. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 36.0 * 2), 50.0) Colors:colorArr GradientType:0];
  118. [self.nextBtn setBackgroundImage:image forState:UIControlStateNormal];
  119. self.nextBtn.layer.cornerRadius = 50.0 / 2.0;
  120. self.nextBtn.layer.masksToBounds = YES;
  121. }
  122. @end