| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- //
- // MOBingMobileVC.m
- // MiMoLive
- //
- // Created by SuperC on 2023/10/31.
- //
- #import "MOBingMobileVC.h"
- #import "MOSelectPartitionVC.h"
- #import "MOSetPasswordSMS.h"
- #import "MOLoginManager.h"
- #import "UITextField+CustomClearButton.h"
- @interface MOBingMobileVC ()
- @property (weak, nonatomic) IBOutlet UILabel *topTipLab;
- @property (weak, nonatomic) IBOutlet UIView *phoneBgView;
- @property (weak, nonatomic) IBOutlet UIView *countryNumBgView;
- @property (weak, nonatomic) IBOutlet BigBtn *countryBtn;
- @property (weak, nonatomic) IBOutlet UITextField *mobileTxf;
- @property (weak, nonatomic) IBOutlet UIButton *nextBtn;
- @end
- @implementation MOBingMobileVC
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- if (self.forgetPwd) {
- self.navigationItem.title = NSLocalString(@"mimo_reset_psw_title");
- } else {
- self.navigationItem.title = NSLocalString(@"mimo_setting_mobile");
- }
-
- [self setupUI];
- }
- - (IBAction)countryChangeBtnClick:(id)sender {
- WEAKSELF
- MOSelectPartitionVC *vc = [[MOSelectPartitionVC alloc] init];
- vc.selectCellBlock = ^(MOCountryList * _Nonnull model) {
- [weakSelf.countryBtn setTitle:model.num forState:UIControlStateNormal];
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (BOOL)isStringNumeric:(NSString *)string {
- NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
- NSRange range = [string rangeOfCharacterFromSet:nonDigitCharacterSet];
- return range.location == NSNotFound;
- }
- - (IBAction)nextBtnClick:(id)sender {
-
- [self.view endEditing:YES];
-
- //验证码登录
- if(self.mobileTxf.text.length == 0)
- {
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_login_hint_phone")];
- return;
- }
-
- //手机号必须全数字
- if([self isStringNumeric:self.mobileTxf.text] == NO){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_check_phone_num_tip")];
- return;
- }
-
- typeof(self) __weak weakSelf = self;
- if(self.isBingNewPhone){
- MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
- vc.vcType = MOEnterChangeNewPhoneCode;
- vc.code = self.countryBtn.titleLabel.text;
- vc.num = self.mobileTxf.text;
- vc.credentials = self.credentials;
- vc.isHaveSendCode = YES;
- [vc toGetNewPhoneCodeAndBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- if(kCode_Success){
- if(self){
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- else{
- kShowNetError(data)
- }
- }];
- return;
- }
-
- if (self.forgetPwd) {
- MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
- vc.code = self.countryBtn.titleLabel.text;
- vc.num = self.mobileTxf.text;
- vc.vcType = MOEnterCodeReSetPasswordType;
- vc.isHaveSendCode = YES;
-
- NSDictionary *dic = @{@"code":self.countryBtn.titleLabel.text,
- @"num":self.mobileTxf.text};
-
- [kHttpManager toGetPasswordCode2WithParams:dic andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- [self.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
-
- return;
- }
-
- MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
- vc.vcType = MOEnterCodeBindPhoneType;
- vc.code = self.countryBtn.titleLabel.text;
- vc.num = self.mobileTxf.text;
- vc.isHaveSendCode = YES;
- [vc toGetSMSCodeWithBindPhoneAndBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- if(kCode_Success){
- if(self){
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)toPopVC{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)viewWillLayoutSubviews {
- [super viewWillLayoutSubviews];
-
- [self.phoneBgView setupGradientLayerWithView:self.phoneBgView
- startColor:[MOTools colorWithHexString:@"#FFFFFF"]
- endColor:[MOTools colorWithHexString:@"#FFFFFF"]
- layerName:@"gradientLayer"
- startPoint:(CGPoint) { 0.5, 0 }
- endPoint:(CGPoint){0.5, 1}];
- }
- - (void)setupUI {
-
- self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
-
- if (self.forgetPwd) {
- self.topTipLab.text = NSLocalString(@"mimo_login_hint_phone");
- } else {
- self.topTipLab.text = NSLocalString(@"mimo_setting_mobile_sub_title");
- }
-
- self.topTipLab.font = [MOTextTools regularFont:14];
- self.topTipLab.textColor = kBaseTextColor_1;
-
- self.mobileTxf.keyboardType = UIKeyboardTypeNumberPad;
- [self.mobileTxf setFont:[MOTextTools poppinsMediumFont:18]];
- self.mobileTxf.textColor = [MOTools colorWithHexString:@"#111111"];
- // self.mobileTxf.clearButtonMode = UITextFieldViewModeWhileEditing;
- self.mobileTxf.clearButtonMode = UITextFieldViewModeNever;
- UIImage *clearIcon = [UIImage imageNamed:@"icon_textfield_clear"];
- [self.mobileTxf enableCustomClearButtonWithImage:clearIcon];
- NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:NSLocalString(@"mimo_login_hint_phone") attributes:@{
- NSForegroundColorAttributeName : [MOTools colorWithHexString:@"#DADCE6"],
- NSFontAttributeName : [MOTextTools poppinsRegularFont:16]
- }];
- self.mobileTxf.attributedPlaceholder = placeholderString;
- [self.mobileTxf addTarget:self action:@selector(mobileFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-
- [self.countryBtn setFont:[MOTextTools poppinsMediumFont:18]];
- [self.countryBtn setTitleColor:[MOTools colorWithHexString:@"#111111"] forState:UIControlStateNormal];
-
- [self.nextBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- NSArray *loginColorArr = @[kBaseColorLeft,kBaseColorRight];
- UIImage *loginImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 20.0 * 2), 48.0) Colors:loginColorArr GradientType:0];
- [self.nextBtn setBackgroundImage:loginImage forState:UIControlStateNormal];
- self.nextBtn.layer.cornerRadius = 12;
- self.nextBtn.layer.masksToBounds = YES;
- self.nextBtn.titleLabel.font = [MOTextTools mediumFont:16];
- [self.nextBtn setTitleColor:[MOTools colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
- self.nextBtn.alpha = 0.5;
-
- self.phoneBgView.layer.cornerRadius = 12.0;
- self.phoneBgView.layer.masksToBounds = YES;
- self.phoneBgView.layer.borderColor = [MOTools colorWithHexString:@"#FFFFFF"].CGColor;
- self.phoneBgView.layer.borderWidth = 1;
-
- self.countryNumBgView.layer.cornerRadius = 6.0;
- self.countryNumBgView.layer.masksToBounds = YES;
-
- //右图左文
- self.countryBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
- self.countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
-
- [self setupCountryCode];
- }
- - (void)setupCountryCode {
- WEAKSELF
- [[MOLoginManager shareManager] getCountryIpComplete:^(NSString * _Nonnull ip) {
- [weakSelf.countryBtn setTitle:ip forState:UIControlStateNormal];
- }];
- }
- - (void)mobileFieldDidChange:(UITextField *)textField {
- self.nextBtn.alpha = textField.text.length > 0 ? 1.0 : 0.5;
- }
- @end
|