diff --git a/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.h b/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.h index f159279..9b7e3c9 100644 --- a/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.h +++ b/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.h @@ -90,6 +90,17 @@ typedef void(^kanHuShangJia)(CertificationShopModel*kanHuShangJia); -(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber zone: (NSString*)areaCode result:(void (^)(NSError *err))result; +/** + * 获取验证码 SMS + * + * @param timeBtn 验证码按钮 + * @param zone 区域号,不要加"+"号(Area code) + * @param isTextCode 是否为短信验证码 + */ + +-(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber zone: +(NSString*)areaCode isTextCode:(BOOL)isTextCode result:(void (^)(NSError *err))result; + /** * 注册 diff --git a/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.m b/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.m index a12c4d3..376c047 100644 --- a/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.m +++ b/Ifish/Utinitys/IfishHttpRequest/IFISHHttpTool.m @@ -177,12 +177,12 @@ addPhoneNumber:(NSString*)phoneNumber addSendType:(NSString*)sendType backData:(backVerifyCode)backVerifyCodeblock{ - [self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber]; + [self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber timeBtnFinalTitle:@"语音验证码"]; [self getverifyWithTimerButton:timeBtn addphoneNumber:phoneNumber AddSendType:sendType backData:backVerifyCodeblock]; } #pragma mark 倒计时 --(void)timerFireWithTimerButton:(UIButton*)timeBtn addPhoneNumber:(NSString*)phoneNumber{ +-(void)timerFireWithTimerButton:(UIButton*)timeBtn addPhoneNumber:(NSString*)phoneNumber timeBtnFinalTitle:(NSString *)title{ __block int timeout=60; //倒计时时间 @@ -195,7 +195,7 @@ dispatch_async(dispatch_get_main_queue(), ^{ //设置界面的按钮显示 根据自己需求设置 - [timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal]; + [timeBtn setTitle:title forState:UIControlStateNormal]; timeBtn.userInteractionEnabled = YES; //timeBtn.backgroundColor=COLOR_LABEL_TITLE; [timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal]; @@ -232,7 +232,7 @@ dispatch_source_cancel(_timer1); dispatch_async(dispatch_get_main_queue(), ^{ //设置界面的按钮显示 根据自己需求设置 - [timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal]; + [timeBtn setTitle:title forState:UIControlStateNormal]; timeBtn.userInteractionEnabled = YES; //timeBtn.backgroundColor=COLOR_LABEL_TITLE; [timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal]; @@ -311,11 +311,42 @@ #pragma mark - SMS 新 -(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber zone: -(NSString*)areaCode result:(void (^)(NSError *err))result +(NSString*)areaCode isTextCode:(BOOL)isTextCode result:(void (^)(NSError *))result + +{ + NSString *title = isTextCode ? @"短信验证码" : @"语音验证码"; + + [self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber timeBtnFinalTitle:title]; + + [SMSSDK getVerificationCodeByMethod:isTextCode ? SMSGetCodeMethodSMS : SMSGetCodeMethodVoice phoneNumber:phoneNumber zone:areaCode customIdentifier:nil result:^(NSError *error) { + + if (!error) { + NSLog(@"获取验证码成功"); + + } else { + NSLog(@"错误信息:%@",error); + dispatch_source_cancel(_timer1); + dispatch_async(dispatch_get_main_queue(), ^{ + //设置界面的按钮显示 根据自己需求设置 + [timeBtn setTitle:title forState:UIControlStateNormal]; + timeBtn.userInteractionEnabled = YES; + //timeBtn.backgroundColor=COLOR_LABEL_TITLE; + [timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal]; + + }); + [self showTitle:@"" messsage:@"获取验证失败"]; + + } + + }]; +} + +-(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber zone: +(NSString*)areaCode result:(void (^)(NSError *))result { - [self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber]; + [self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber timeBtnFinalTitle:@"语音验证码"]; [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodVoice phoneNumber:phoneNumber zone:areaCode customIdentifier:nil result:^(NSError *error) { diff --git a/Ifish/controllers/logAddRegistController/RegistViewController.mm b/Ifish/controllers/logAddRegistController/RegistViewController.mm index ea851d2..bd9b198 100644 --- a/Ifish/controllers/logAddRegistController/RegistViewController.mm +++ b/Ifish/controllers/logAddRegistController/RegistViewController.mm @@ -60,6 +60,8 @@ @property(nonatomic) double latitude; @property(nonatomic,copy) NSString *adderss; +@property (weak, nonatomic) IBOutlet UILabel *qrcodeSwitchLbl; + @end extern BOOL formLogIn; @@ -133,12 +135,21 @@ extern BOOL formLogIn; //NSString *zone = [dataContorl areaCode:self.phoneNumberTextField.text]; //self.areaCode = zone; - - [IFISHHTTPTOOL getverifyWithTimerButton:_timeBtn addphoneNumber:self.phoneNumberTextField.text zone:self.areaCode result:^(NSError *err) { + BOOL isTextCode = [[self.timeBtn titleForState:UIControlStateNormal] isEqualToString:@"短信验证码"]; + [IFISHHTTPTOOL getverifyWithTimerButton:_timeBtn addphoneNumber:self.phoneNumberTextField.text zone:self.areaCode isTextCode:isTextCode result:^(NSError *err) { }]; } +- (IBAction)qrcodeSwithBtnClicked:(UIButton *)sender { + if ([[self.timeBtn titleForState:UIControlStateNormal] isEqualToString:@"语音验证码"]) { + [self.timeBtn setTitle:@"短信验证码" forState:UIControlStateNormal]; + self.qrcodeSwitchLbl.text = @"语音验证码"; + } else if ([[self.timeBtn titleForState:UIControlStateNormal] isEqualToString:@"短信验证码"]) { + [self.timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal]; + self.qrcodeSwitchLbl.text = @"短信验证码"; + } +} #pragma mark-设置键盘样式 -(void)setTextkeyboadType{ diff --git a/Ifish/controllers/logAddRegistController/RegistViewController.xib b/Ifish/controllers/logAddRegistController/RegistViewController.xib index 570b807..102f191 100644 --- a/Ifish/controllers/logAddRegistController/RegistViewController.xib +++ b/Ifish/controllers/logAddRegistController/RegistViewController.xib @@ -1,11 +1,11 @@ - + - + @@ -16,6 +16,7 @@ + @@ -118,7 +119,7 @@ - @@ -173,20 +187,25 @@ + + + + + @@ -195,6 +214,7 @@ +