99 lines
4.0 KiB
Mathematica
99 lines
4.0 KiB
Mathematica
|
|
//
|
||
|
|
// QXBindMobileViewController.m
|
||
|
|
// QXLive
|
||
|
|
//
|
||
|
|
// Created by 启星 on 2025/5/12.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "QXBindMobileViewController.h"
|
||
|
|
#import "QXLoginTextField.h"
|
||
|
|
#import "QXMineNetwork.h"
|
||
|
|
#import "QXLoginNetwork.h"
|
||
|
|
|
||
|
|
@interface QXBindMobileViewController ()<QXLoginTextFieldDelegate>
|
||
|
|
@property (nonatomic,strong)QXLoginTextField *accountTextField;
|
||
|
|
@property (nonatomic,strong)QXLoginTextField *codeTextField;
|
||
|
|
@property (nonatomic,strong)UIButton *commitBtn;
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation QXBindMobileViewController
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
// Do any additional setup after loading the view.
|
||
|
|
}
|
||
|
|
-(void)setNavgationItems{
|
||
|
|
[super setNavgationItems];
|
||
|
|
self.navigationItem.title = QXText(@"手机绑定");
|
||
|
|
}
|
||
|
|
-(void)initSubViews{
|
||
|
|
self.accountTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(16, NavContentHeight+12, SCREEN_WIDTH-32, 44) type:(LoginTextTypeAccount)];
|
||
|
|
self.accountTextField.backgroundColor = RGB16(0xEFF2F8);
|
||
|
|
[self.accountTextField addRoundedCornersWithRadius:11];
|
||
|
|
[self.view addSubview:self.accountTextField];
|
||
|
|
|
||
|
|
self.codeTextField = [[QXLoginTextField alloc] initWithFrame:CGRectMake(16, self.accountTextField.bottom+12, SCREEN_WIDTH-32, 44) type:(LoginTextTypeCode)];
|
||
|
|
self.codeTextField.backgroundColor = RGB16(0xEFF2F8);
|
||
|
|
[self.codeTextField addRoundedCornersWithRadius:11];
|
||
|
|
self.codeTextField.delegate = self;
|
||
|
|
[self.view addSubview:self.codeTextField];
|
||
|
|
|
||
|
|
self.commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.codeTextField.bottom+16, SCREEN_WIDTH-38*2, 42)];
|
||
|
|
self.commitBtn.needEventInterval = 1;
|
||
|
|
[self.commitBtn setTitle:QXText(@"立即绑定") forState:(UIControlStateNormal)];
|
||
|
|
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||
|
|
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||
|
|
[self.commitBtn addRoundedCornersWithRadius:21];
|
||
|
|
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||
|
|
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
||
|
|
[self.view addSubview:self.commitBtn];
|
||
|
|
}
|
||
|
|
-(void)didClickSendCode:(UIButton *)sender{
|
||
|
|
if (self.accountTextField.textField.text.length < 11) {
|
||
|
|
showToast(QXText(@"请输入正确的手机号码"));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
GetSmscodeType type = GetSmscodeTypeFindBindMobile;
|
||
|
|
NSString *oldMobile = [QXGlobal shareGlobal].loginModel.mobile;
|
||
|
|
if (oldMobile.length > 0) {
|
||
|
|
type = GetSmscodeTypeFindChangeMobile;
|
||
|
|
}
|
||
|
|
MJWeakSelf
|
||
|
|
[QXLoginNetwork getSmscodeWithMobile:self.accountTextField.textField.text
|
||
|
|
type:type
|
||
|
|
successBlock:^(id _Nonnull responseObject) {
|
||
|
|
[weakSelf.codeTextField startTimeDown];
|
||
|
|
}
|
||
|
|
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
-(void)commitAction{
|
||
|
|
NSString *oldMobile = [QXGlobal shareGlobal].loginModel.mobile;
|
||
|
|
NSString *mobile = self.accountTextField.textField.text;
|
||
|
|
NSString *sms_code = self.codeTextField.textField.text;
|
||
|
|
[QXMineNetwork changeMobileWithOldMobile:oldMobile
|
||
|
|
new_mobile:mobile
|
||
|
|
sms_code:sms_code
|
||
|
|
successBlock:^(NSDictionary * _Nonnull dict) {
|
||
|
|
showToast(QXText(@"绑定成功"));
|
||
|
|
[QXGlobal shareGlobal].loginModel.mobile = mobile;
|
||
|
|
[[QXGlobal shareGlobal]updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||
|
|
[self.navigationController popViewControllerAnimated:YES];
|
||
|
|
}
|
||
|
|
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||
|
|
showToast(msg)
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
/*
|
||
|
|
#pragma mark - Navigation
|
||
|
|
|
||
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||
|
|
// Get the new view controller using [segue destinationViewController].
|
||
|
|
// Pass the selected object to the new view controller.
|
||
|
|
}
|
||
|
|
*/
|
||
|
|
|
||
|
|
@end
|