| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- //
- // MOSetPasswordSMS.m
- // MiMoLive
- //
- // Created by SuperC on 2023/10/31.
- //
- #import "MOSetPasswordSMS.h"
- #import "MOCountDownButton.h"
- #import "MOSetPasswordVC.h"
- #import "MOBingMobileVC.h"
- #import "MOSuccessfulVC.h"
- #import "MOBindingEmailVC.h"
- #import "NSString+YYAdd.h"
- #import "MOInputCodeView.h"
- #import "MOSMSInputView.h"
- #define kCountDownTime 120
- @interface MOSetPasswordSMS ()
- @property (weak, nonatomic) IBOutlet UILabel *titleTipLab;
- @property (weak, nonatomic) IBOutlet UILabel *contentTipLab;
- @property (weak, nonatomic) IBOutlet UILabel *phoneLab;
- @property (nonatomic, strong) MOInputCodeView *smsInputView;
- @property (nonatomic, strong) MOSMSInputView *oldSmsInputView;
- @property (nonatomic, strong) MOCountDownButton *smsBtn;
- @property (nonatomic, strong) UIButton *finishBtn;
- @property (nonatomic, strong) UILabel *countdownLabel;
- @property (nonatomic, strong) UIButton *resendButton;
- @property (nonatomic, strong) NSTimer *countdownTimer;
- @property (nonatomic, assign) NSInteger countdownSeconds;
- @property (nonatomic, copy) NSString *smsCode;
- @end
- @implementation MOSetPasswordSMS
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- [self stopTimer];
- }
- - (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)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-
- [self startTimer];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self setupUI];
-
- if(self.vcType == MOEnterCodeBindPhoneType){
- //绑定手机
- self.navigationItem.title = NSLocalString(@"mimo_setting_mobile");
- if(!self.isHaveSendCode){
- [self toGetSMSCodeWithBindPhoneAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- }
- else if (self.vcType == MOEnterChangeOldPhoneCode){
- self.navigationItem.title = NSLocalString(@"mimo_mine_phone_change");
- if(!self.isHaveSendCode){
- [self toGetOldPhoneCodeAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- }
- else if (self.vcType == MOEnterChangeNewPhoneCode){
- self.navigationItem.title = NSLocalString(@"mimo_mine_phone_change");
- if(!self.isHaveSendCode){
- [self toGetNewPhoneCodeAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- }
- else if (self.vcType == MOEnterCodeBindEmail){
- //第一次绑定邮箱
- self.navigationItem.title = NSLocalString(@"mimo_mine_binding_email");
- if(!self.isHaveSendCode){
- [self firstBindTheEmailAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_send_tip")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_one");
- self.contentTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_two");
- }
- else if (self.vcType == MOEnterCodeBindNewEmailOne){
- self.navigationItem.title = NSLocalString(@"mimo_mine_email_change");
- if(!self.isHaveSendCode){
- [self emailChangeToGetOldEmailCodeAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_one");
- self.contentTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_two");
- }
- else if (self.vcType == MOEnterCodeChangeEmailAndNewEmailCode){
- self.navigationItem.title = NSLocalString(@"mimo_mine_email_change");
-
- if(!self.isHaveSendCode){
- [self emailChangeAndGetTheNewEmailCodeAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_one");
- self.contentTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_two");
- }
- else if (self.vcType == MOEnterCodeSetPsw2Type){
- self.navigationItem.title = NSLocalString(@"mimo_mine_password2_guild");
-
- if(!self.isHaveSendCode){
- [self thePassword2SettingSendCodeAndBlock:nil];
- }
- else{
- if(self.psw2Type == 1){
- //手机
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- //邮箱
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- }
-
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
-
- if(self.psw2Type == 2){
- self.titleTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_one");
- self.contentTipLab.text = NSLocalString(@"mimo_mine_binding_email_code_tip_two");
- }
-
- if(self.isForgetPsw2){
- self.navigationItem.title = NSLocalString(@"mimo_mine_password2_forget_title");
- }
- }
- else if (self.vcType == MOSetPsw2NumType){
- self.navigationItem.title = NSLocalString(@"mimo_mine_password2_guild");
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_password2_enter_tip");
- self.contentTipLab.hidden = YES;
- self.phoneLab.hidden = YES;
- self.smsBtn.hidden = YES;
- }
- else if (self.vcType == MOChangePsw2EnterOldPsw){
- //修改密码2 - 输入旧密码
- self.navigationItem.title = NSLocalString(@"mimo_mine_password2_change_title");
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_password2_change_vc_tip_one");
- self.contentTipLab.hidden = YES;
- self.phoneLab.hidden = YES;
- self.smsBtn.hidden = YES;
- }
- else if (self.vcType == MOChangePsw2EnterNewPsw){
- //修改密码2 - 输入新密码
- self.navigationItem.title = NSLocalString(@"mimo_mine_password2_change_title");
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- self.titleTipLab.text = NSLocalString(@"mimo_mine_password2_change_vc_tip_two");
- self.contentTipLab.hidden = YES;
- self.phoneLab.hidden = YES;
- self.smsBtn.hidden = YES;
- } else if (self.vcType == MOEnterCodeReSetPasswordType) {
- //重置密码
- self.navigationItem.title = NSLocalString(@"mimo_reset_psw_title");
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- }
- else{
- //设置密码
- self.navigationItem.title = NSLocalString(@"mimo_set_psw_title");
- if(!self.isHaveSendCode){
- [self toGetSMSCodeAndBlock:nil];
- }
- else{
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- [self.finishBtn setTitle:NSLocalString(@"mimo_login_next_step") forState:UIControlStateNormal];
- }
-
- [self performSelector:@selector(theSearchTexBecomeFirst) withObject:nil afterDelay:1.0];
- }
- - (void)theSearchTexBecomeFirst{
- [self.smsInputView showKeyboard];
- }
- - (void)setupUI{
-
- self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
-
- self.titleTipLab.font = [MOTextTools regularFont:14];
- self.titleTipLab.textColor = kBaseTextColor_1;
- self.titleTipLab.text = NSLocalString(@"mimo_login_input_code");
-
- self.contentTipLab.font = [MOTextTools regularFont:14];
- self.contentTipLab.textColor = kBaseTextColor_3;
- self.contentTipLab.text = NSLocalString(@"mimo_login_send_code");
-
- self.phoneLab.font = [MOTextTools regularFont:14];
- self.phoneLab.textColor = kBaseTextColor_3;
-
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- NSString *phoneNumStr = userInfoData.userMobile.num;
- if([phoneNumStr rangeOfString:@"*"].location == NSNotFound){
- phoneNumStr = [MOTools maskPhoneNumber:phoneNumStr];
- }
-
- self.phoneLab.text = [NSString stringWithFormat:@"%@ %@",userInfoData.userMobile.code,phoneNumStr];
-
- if(self.code.length != 0 && self.num.length != 0){
-
- NSString *phoneNumStr = self.num;
- if (self.vcType != MOEnterCodeReSetPasswordType && self.vcType != MOEnterChangeNewPhoneCode) {//如果是v2.0的忘记密码重置密码 && 更换手机号码场景,是自己输入手机号,不需要显示*
- if([phoneNumStr rangeOfString:@"*"].location == NSNotFound){
- phoneNumStr = [MOTools maskPhoneNumber:phoneNumStr];
- }
- }
- self.phoneLab.text = [NSString stringWithFormat:@"%@ %@",self.code,phoneNumStr];
- }
- else if (self.email.length != 0){
- self.phoneLab.text = self.email;
- } else {
- self.titleTipLab.text = NSLocalString(@"mimo_set_psw_first_tip");
- }
-
- if(self.vcType == MOSetPsw2NumType ||
- self.vcType == MOChangePsw2EnterOldPsw ||
- self.vcType == MOChangePsw2EnterNewPsw){
-
- CGFloat spacing = (SCREENWIDTH - 46.0 * 4 - 61 * 2.0 - 16.0 * 2.0) / (4 - 1);
- CGFloat width = 46.0 * 4.0 + spacing * 3.0 + 16.0 * 2.0;
- if(self.vcType == MOSetPsw2NumType ||
- self.vcType == MOChangePsw2EnterOldPsw ||
- self.vcType == MOChangePsw2EnterNewPsw){
- spacing = (SCREENWIDTH - 36.0 * 7 - 30.0 * 2.0 - 16.0 * 2.0) / (7 - 1);
- width = 36.0 * 7.0 + spacing * 6.0 + 16.0 * 2.0;
- }
- [self.view addSubview:self.oldSmsInputView];
- [self.oldSmsInputView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.phoneLab.mas_bottom).offset(17.0);
- make.width.equalTo(@(width));
- make.height.equalTo(@(kPOSMSInputBoxHeight));
- make.centerX.equalTo(self.view.mas_centerX);
- }];
-
- self.countdownLabel.hidden = YES;
-
- } else {
-
- [self.view addSubview:self.smsInputView];
- [self.smsInputView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.phoneLab.mas_bottom).offset(24);
- make.left.mas_equalTo(24);
- make.right.mas_equalTo(-24);
- make.height.mas_equalTo(kScaleWidth(64));
- }];
- }
-
- // [self smsBtn];
-
- [self.view addSubview:self.finishBtn];
- [self.finishBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.height.mas_equalTo(48);
- if(self.vcType == MOSetPsw2NumType ||
- self.vcType == MOChangePsw2EnterOldPsw ||
- self.vcType == MOChangePsw2EnterNewPsw){
- make.top.equalTo(self.oldSmsInputView.mas_bottom).offset(49);
- } else {
- make.top.equalTo(self.smsInputView.mas_bottom).offset(49);
- }
- }];
-
- [self.view addSubview:self.countdownLabel];
- [self.countdownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.finishBtn.mas_bottom).offset(12);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-24);
- }];
-
- [self.view addSubview:self.resendButton];
- [self.resendButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.countdownLabel);
- make.left.mas_equalTo(20);
- }];
- }
- - (void)startTimer {
-
- if(self.vcType == MOSetPsw2NumType ||
- self.vcType == MOChangePsw2EnterOldPsw ||
- self.vcType == MOChangePsw2EnterNewPsw) {
- return;
- }
- self.countdownSeconds = kCountDownTime;
- self.resendButton.hidden = YES;
- self.countdownLabel.hidden = NO;
- self.countdownLabel.text = [NSString stringWithFormat:@"%@ %zds", NSLocalString(@"mimo_login_resend_code_countdown"), self.countdownSeconds];
- self.countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateCountdown) userInfo:nil repeats:YES];
- }
- - (void)updateCountdown {
- self.countdownSeconds--;
- if (self.countdownSeconds <= 0) {
- [self stopTimer];
- self.countdownLabel.hidden = YES;
- self.resendButton.hidden = NO;
- } else {
- self.countdownLabel.text = [NSString stringWithFormat:@"%@ %zds", NSLocalString(@"mimo_login_resend_code_countdown"), self.countdownSeconds];
- }
- }
- - (void)stopTimer {
- [self.countdownTimer invalidate];
- self.countdownTimer = nil;
- }
- - (void)resendButtonAction {
- if(self.vcType == MOEnterCodeBindPhoneType){
- [self toGetSMSCodeWithBindPhoneAndBlock:nil];
- } else if (self.vcType == MOEnterChangeOldPhoneCode){
- [self toGetOldPhoneCodeAndBlock:nil];
- } else if (self.vcType == MOEnterChangeNewPhoneCode){
- [self toGetNewPhoneCodeAndBlock:nil];
- } else if (self.vcType == MOEnterCodeBindEmail){
- [self firstBindTheEmailAndBlock:nil];
- } else if (self.vcType == MOEnterCodeBindNewEmailOne){
- [self emailChangeToGetOldEmailCodeAndBlock:nil];
- } else if (self.vcType == MOEnterCodeChangeEmailAndNewEmailCode){
- [self emailChangeAndGetTheNewEmailCodeAndBlock:nil];
- } else if (self.vcType == MOEnterCodeSetPsw2Type){
- [self thePassword2SettingSendCodeAndBlock:nil];
- } else {
- [self toGetSMSCodeAndBlock:nil];
- }
- [self startTimer];
- }
- #pragma mark - Lazy
- - (MOInputCodeView *)smsInputView {
- if (!_smsInputView) {
- _smsInputView = [[MOInputCodeView alloc] init];
- WEAKSELF
- _smsInputView.inputCompleted = ^(NSString *code) {
- weakSelf.smsCode = code;
- weakSelf.finishBtn.alpha = 1.0;
- };
- }
- return _smsInputView;
- }
- - (MOSMSInputView *)oldSmsInputView {
- if (!_oldSmsInputView) {
- WEAKSELF
- if(self.vcType == MOSetPsw2NumType ||
- self.vcType == MOChangePsw2EnterOldPsw ||
- self.vcType == MOChangePsw2EnterNewPsw){
- CGFloat spacing = (SCREENWIDTH - 36.0 * 7 - 30.0 * 2.0 - 16.0 * 2.0) / (7 - 1);
- _oldSmsInputView = [[MOSMSInputView alloc] initWithFrame:CGRectMake(0, (KIsiPhoneX?302:282), (36.0 * 7.0 + spacing * 3.0 + 16.0 * 2.0), kPOSMSInputBoxHeight) AndBoxSize:CGSizeMake(36.0, 60.0) AndBoxNum:6 AndBoxSpace:spacing];
- _oldSmsInputView.isCiphertext = YES;
- }
-
- _oldSmsInputView.finishSMSCodeCallBack = ^(NSString * _Nonnull code) {
- weakSelf.smsCode = code;
- weakSelf.finishBtn.alpha = 1.0;
- };
- }
- return _oldSmsInputView;
- }
- - (UIButton *)finishBtn{
- if(!_finishBtn){
- _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _finishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_finishBtn setTitle:NSLocalString(@"mimo_Finish") forState:UIControlStateNormal];
- NSArray *loginColorArr = @[kBaseColorLeft,kBaseColorRight];
- UIImage *loginImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 20.0 * 2), 48.0) Colors:loginColorArr GradientType:0];
- [_finishBtn setBackgroundImage:loginImage forState:UIControlStateNormal];
- _finishBtn.layer.cornerRadius = 12;
- _finishBtn.layer.masksToBounds = YES;
- _finishBtn.titleLabel.font = [MOTextTools mediumFont:16];
- [_finishBtn setTitleColor:[MOTools colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
- [_finishBtn addTarget:self action:@selector(finishBtnClick) forControlEvents:UIControlEventTouchUpInside];
- _finishBtn.alpha = 0.5;
- }
- return _finishBtn;
- }
- - (UILabel *)countdownLabel {
- if (!_countdownLabel) {
- _countdownLabel = [[UILabel alloc] init];
- _countdownLabel.textColor = [MOTools colorWithHexString:@"#999999"];
- _countdownLabel.font = [MOTextTools regularFont:14];
- _countdownLabel.text = NSLocalString(@"mimo_login_resend_code_countdown");
- _countdownLabel.numberOfLines = 0;
- }
- return _countdownLabel;
- }
- - (UIButton *)resendButton {
- if (!_resendButton) {
- _resendButton = [[UIButton alloc] init];
- _resendButton.titleLabel.font = [MOTextTools regularFont:14];
- [_resendButton setTitleColor:[MOTools colorWithHexString:@"#999999"] forState:UIControlStateNormal];
- [_resendButton setTitle:NSLocalString(@"mimo_login_resend_code") forState:UIControlStateNormal];
- [_resendButton addTarget:self action:@selector(resendButtonAction) forControlEvents:UIControlEventTouchUpInside];
- _resendButton.hidden = YES;
- }
- return _resendButton;
- }
- - (void)finishBtnClick{
-
- if(self.smsCode.length == 0){
- [MBProgressHUD showTipMessageInWindow:@"Please Enter"];
- return;
- }
-
- if(self.vcType == MOEnterCodeBindPhoneType){
- [self toBindPhoenAction];
- return;
- }
- else if (self.vcType == MOEnterChangeOldPhoneCode){
- //旧手机校验
- [self toCheckTheOldPhoneCode];
- return;
- }
- else if (self.vcType == MOEnterChangeNewPhoneCode){
- //新手机验证
- [self toCheckTheNewPhoneCode];
- return;
- }
- else if (self.vcType == MOEnterCodeBindEmail){
- //第一次绑定邮箱
- [self toCheckTheFirstEmailBind];
- return;
- }
- else if (self.vcType == MOEnterCodeBindNewEmailOne){
- //校验老的邮箱
- [self toCheckTheOldEmailCode];
- return;
- }
- else if (self.vcType == MOEnterCodeChangeEmailAndNewEmailCode){
- //校验新的邮箱
- [self toCheckTheNewEmailCode];
- return;
- }
- else if (self.vcType == MOEnterCodeSetPsw2Type){
- [self thePassword2SettingCheck];
- return;
- }
- else if (self.vcType == MOSetPsw2NumType){
- [self toSubmitThePassword2];
- return;
- }
- else if (self.vcType == MOChangePsw2EnterOldPsw){
- [self changePsw2AndCheckTheOldPsw];
- return;
- }
- else if (self.vcType == MOChangePsw2EnterNewPsw){
- [self changePsw2AndCheckTheNewPsw];
- return;
- }
-
- if(self.smsCode.length == 0){
- return;
- }
-
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- NSString *code;
- NSString *num;
-
- //如果外部有传入, 就使用外部的
- if(self.code.length > 0){
- code = self.code;
- num = self.num;
- }
- else
- {
- code = userInfoData.userMobile.code;
- num = userInfoData.userMobile.num;
- }
-
- if(code.length == 0 ||
- num.length == 0){
- return;
- }
-
- //前置界面有做判空, 这里就不做判空了
- NSDictionary *mobileDict = @{@"code":code,
- @"num":num};
-
- //TODO: 请求参数需要修改
- WEAKSELF
- NSDictionary *dict = @{@"code":self.smsCode,
- @"mobile":mobileDict};
-
- [kHttpManager toVerifyTheSmsCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
-
- NSString *result = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
-
- MOSetPasswordVC *vc = [[MOSetPasswordVC alloc] init];
- vc.code = code;
- vc.num = num;
- vc.codeString = result;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- #pragma mark - Mothed
- - (void)toBindPhoenAction{
-
- if(self.smsCode.length == 0){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_first_tip")];
- return;
- }
-
- [MBProgressHUD showActivityMessageInView:@""];
- WEAKSELF
- NSDictionary *mobileDict = @{@"code":self.code,
- @"num":self.num};
-
- NSDictionary *dict = @{@"mobile":mobileDict,
- @"code":self.smsCode};
-
- [kHttpManager toBingAndSubmitWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_common_success")];
-
- //更新个人信息缓存
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- userInfoData.userStatusInfo.mobile = YES;
- userInfoData.userMobile.code = weakSelf.code;
- userInfoData.userMobile.num = weakSelf.num;
-
- [[MODataCache sharedYYCache] setObject:userInfoData forKey:kMineUserInfo];
-
- [[MORefreshViewManage shareManager] setNeedRefreshWithCode:@"MOMineVC"];
-
- [weakSelf performSelector:@selector(toPopVC) withObject:nil afterDelay:1.0];
-
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)toPopVC{
-
- //查找扫码页面的索引
- NSInteger index = 0;
- for (UIViewController *subVC in self.navigationController.viewControllers)
- {
- if([subVC isKindOfClass:NSClassFromString(@"MOMineSetUpVC")])
- {
- index = [self.navigationController.viewControllers indexOfObject:subVC];
- break;
- }
- }
-
- if(index > 0){
- //返回到扫一扫的上一个界面
- UIViewController *vc = self.navigationController.viewControllers[index-1];
- [self.navigationController popToViewController:vc animated:YES];
- }
- else{
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- - (void)toGetSMSCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- NSString *code;
- NSString *num;
-
- //如果外部有传入, 就使用外部的
- if(self.code.length > 0){
- code = self.code;
- num = self.num;
- }
- else
- {
- code = userInfoData.userMobile.code;
- num = userInfoData.userMobile.num;
- }
-
- if(code.length == 0 ||
- num.length == 0){
- return;
- }
-
- NSDictionary *dic = @{@"code":code,
- @"num":num};
-
- [kHttpManager toGetPasswordCode2WithParams:dic andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- ///绑定手机
- - (void)toGetSMSCodeWithBindPhoneAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
-
- if(self.code.length == 0 ||
- self.num.length == 0){
- return;
- }
-
- WEAKSELF
- NSDictionary *dic = @{@"code":self.code,
- @"num":self.num};
- [kHttpManager firstToBingCodeWithParams:dic andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- - (void)toGetOldPhoneCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
-
- [kHttpManager toSendTheUserOldMobileChangeCodleWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- kShowNetError(data)
- }
- block ? block(data,error) : nil;
- }];
- }
- - (void)toCheckTheOldPhoneCode{
- WEAKSELF
- if(self.smsCode.length == 0){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_first_tip")];
- return;
- }
-
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"data":self.smsCode};
- [kHttpManager toCheckTheOldMobileCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- MOBingMobileVC *vc = [[MOBingMobileVC alloc] init];
- vc.isBingNewPhone = YES;
- NSString *credentialsStr = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
- vc.credentials = credentialsStr;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)toGetNewPhoneCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
-
- NSDictionary *mobileDict = @{@"code":self.code,@"num":self.num};
- NSDictionary *dict = @{@"credentials":self.credentials,@"mobile":mobileDict};
-
- [kHttpManager toSendTheNewMobileCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- - (void)toCheckTheNewPhoneCode{
- [MBProgressHUD showActivityMessageInView:@""];
-
- WEAKSELF
- NSDictionary *mobileDict = @{@"code":self.code,@"num":self.num};
- NSDictionary *dict = @{@"credentials":self.credentials,@"mobile":mobileDict,@"code":self.smsCode};
-
- [kHttpManager toBingTheNewMobileWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //跳转绑定成功界面
- MOSuccessfulVC *vc = [[MOSuccessfulVC alloc] init];
- vc.code = weakSelf.code;
- vc.num = weakSelf.num;
- vc.isBingPhone = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
-
- }];
- }
- - (void)firstBindTheEmailAndBlock:(void (^)(id data, NSError *error))block{
- if(self.email.length == 0){
- return;
- }
-
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"email":self.email};
- WEAKSELF
- [kHttpManager toBindEmailAndGetCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_send_tip")];
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- - (void)toCheckTheFirstEmailBind{
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"email":self.email,
- @"code":self.smsCode};
- WEAKSELF
- [kHttpManager toSubmitTheEmailWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //绑定成功
- MOSuccessfulVC *vc = [[MOSuccessfulVC alloc] init];
- vc.email = weakSelf.email;
- vc.vcType = MOSuccessfulTypeBindEmail;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)emailChangeToGetOldEmailCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
- WEAKSELF
- [kHttpManager getTheOldEmailCodeWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- else{
- kShowNetError(data)
- }
- block ? block(data,error) : nil;
- }];
- }
- - (void)toCheckTheOldEmailCode{
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"data":self.smsCode};
- WEAKSELF
- [kHttpManager toCheckTheOldEmailCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //输入新的邮箱
- NSString *credentials = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
- MOBindingEmailVC *vc = [[MOBindingEmailVC alloc] init];
- vc.isBindNewEmail = YES;
- vc.credentials = credentials;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)emailChangeAndGetTheNewEmailCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"credentials":self.credentials,@"email":self.email};
- WEAKSELF
- [kHttpManager getTheNewEmailCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //验证码已经发送
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- - (void)toCheckTheNewEmailCode{
- [MBProgressHUD showActivityMessageInView:@""];
-
- NSDictionary *dict = @{@"email":self.email,
- @"credentials":self.credentials,
- @"code":self.smsCode};
- WEAKSELF
- [kHttpManager toBindTheNewEmailWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //换绑成功
- MOSuccessfulVC *vc = [[MOSuccessfulVC alloc] init];
- vc.vcType = MOSuccessfulTypeChangeEmail;
- vc.email = weakSelf.email;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)thePassword2SettingSendCodeAndBlock:(void (^)(id data, NSError *error))block{
- [MBProgressHUD showActivityMessageInView:@""];
- WEAKSELF
- NSDictionary *dict = @{@"type":@(self.psw2Type)};
- [kHttpManager thePassword2SettingSendCodeWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
-
- if(weakSelf.psw2Type == 1){
- //手机
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_set_psw_content_tip")];
- }
- else{
- //邮箱
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_mine_binding_email_code_tip_two")];
- }
- }
- else{
- kShowNetError(data)
- }
-
- block ? block(data,error) : nil;
- }];
- }
- - (void)thePassword2SettingCheck{
- [MBProgressHUD showActivityMessageInView:@""];
- NSDictionary *dict = @{@"type":@(self.psw2Type),
- @"code":self.smsCode};
- WEAKSELF
- [kHttpManager thePassword2SettingVerifyWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
-
- if(kCode_Success){
- //设置密码2
- NSString *credentials = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
- MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
- vc.credentials = credentials;
- vc.psw2Type = weakSelf.psw2Type;
- vc.vcType = MOSetPsw2NumType;
- vc.password2 = weakSelf.smsCode;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)toSubmitThePassword2{
- //设置Password2
- [MBProgressHUD showActivityMessageInView:@""];
- NSString *thePsw2Str = [self.smsCode md5String];
- NSDictionary *dict = @{@"type":@(self.psw2Type),
- @"password":thePsw2Str,
- @"credentials":self.credentials};
- WEAKSELF
- [kHttpManager thePassword2SettingSubmitWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- //提交密码2
- MOSuccessfulVC *vc = [[MOSuccessfulVC alloc] init];
- vc.vcType = MOSuccessfulTypePsw2Submit;
- [weakSelf.navigationController pushViewController:vc animated:YES];
-
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)changePsw2AndCheckTheOldPsw{
- //校验旧密码2
- [MBProgressHUD showActivityMessageInView:@""];
- NSString *thePsw2Str = [self.smsCode md5String];
- NSDictionary *dict = @{@"data":thePsw2Str};
- WEAKSELF
- [kHttpManager thePassword2ChangeVerifyWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- NSString *credentials = [MODataManager objectOrNilForKey:@"result" fromDictionary:data[@"data"]];
- MOSetPasswordSMS *vc = [[MOSetPasswordSMS alloc] init];
- vc.vcType = MOChangePsw2EnterNewPsw;
- vc.credentials = credentials;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)changePsw2AndCheckTheNewPsw{
- //输入新密码2
- [MBProgressHUD showActivityMessageInView:@""];
- NSString *thePsw2Str = [self.smsCode md5String];
- NSDictionary *dict = @{@"password":thePsw2Str,
- @"credentials":self.credentials};
- WEAKSELF
- [kHttpManager thePassword2ChangeSubmitWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- [MBProgressHUD hideHUD];
- if(kCode_Success){
- MOSuccessfulVC *vc = [[MOSuccessfulVC alloc] init];
- vc.vcType = MOSuccessfulTypePsw2Change;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }
- else{
- kShowNetError(data)
- }
- }];
-
- }
- @end
|