758 lines
31 KiB
Objective-C
758 lines
31 KiB
Objective-C
//
|
||
// IFISHHttpTool.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 15/12/24.
|
||
// Copyright © 2015年 imac. All rights reserved.
|
||
//
|
||
|
||
#import "IFISHHttpTool.h"
|
||
#import "AFHttpTool.h"
|
||
#import "AFNOHeaderHttpTool.h"
|
||
#import "MyMD5.h"
|
||
|
||
#import "IfishDataUnity.h"
|
||
#import "NetManager.h"
|
||
#import "AccountResult.h"
|
||
#import "LoginResult.h"
|
||
#import "UDManager.h"
|
||
//
|
||
#import "CertificationShopModel.h"
|
||
#import "IfishUserDefaultHelper.h"
|
||
#import "IfishUserDataUnity.h"
|
||
@implementation IFISHHttpTool
|
||
{
|
||
dispatch_source_t _timer1;
|
||
}
|
||
+(IFISHHttpTool*)shareInstance
|
||
{
|
||
static IFISHHttpTool*instance=nil;
|
||
static dispatch_once_t predicate;
|
||
dispatch_once(&predicate, ^{
|
||
instance=[[[self class]alloc]init];
|
||
|
||
|
||
});
|
||
return instance;
|
||
}
|
||
|
||
-(void)ifishLogindismissvc:(DisconnectNetController*)disconnectVC{
|
||
|
||
|
||
UIApplication*app=[UIApplication sharedApplication];
|
||
AppDelegate*app1=(AppDelegate*)app.delegate;
|
||
|
||
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
|
||
NSString*name=[userDefsult objectForKey:@"name"];
|
||
|
||
NSString*pasword=[userDefsult objectForKey:@"password"];
|
||
|
||
NSString*address=[userDefsult objectForKey:@"address"];
|
||
NSString*unionId=[userDefsult objectForKey:@"unionId"];
|
||
NSDictionary*para=nil;
|
||
if (!pasword.length&&unionId.length)
|
||
{
|
||
para=@{@"unionId":unionId};
|
||
}
|
||
double userlongitude=[userDefsult doubleForKey:@"userlongitude"];
|
||
double userlatitude=[userDefsult doubleForKey:@"userlatitude"];
|
||
|
||
if (!address) {
|
||
address = @"暂未获取地址信息";
|
||
}
|
||
if (!userlongitude) {
|
||
|
||
userlongitude = 0;
|
||
}
|
||
if (!userlatitude) {
|
||
|
||
userlongitude = 0;
|
||
}
|
||
//是否退出登陆
|
||
|
||
[userDefsult setObject:@"0" forKey:@"isExit"];
|
||
|
||
NSString*passWordStr;
|
||
if (pasword.length)
|
||
{
|
||
passWordStr=[MyMD5 md5:pasword];
|
||
}
|
||
|
||
//__weak typeof (self) weakSelf=self;
|
||
[AFHttpTool userLogInWithPhoneNumber:name password:passWordStr phoneType:@"ios" address:address
|
||
longitude:userlongitude
|
||
latitude:userlatitude success:^(id response) {
|
||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSLog(@"%@",dict);
|
||
NSString *result=dict[@"result"];
|
||
if ([result isEqualToString:@"100"]) {
|
||
// 登录成功
|
||
if (disconnectVC) {
|
||
|
||
[disconnectVC dismissViewControllerAnimated:YES completion:nil];
|
||
}
|
||
|
||
// 存储数据
|
||
NSDictionary *datadic = dict[@"data"];
|
||
[[IfishUserDataUnity shareDataInstance] userAutologinSuccsess:datadic];
|
||
|
||
}else if ([result isEqualToString:@"101"]){
|
||
[app1.window makeToast:@"登录失败"];
|
||
|
||
//登录失败
|
||
}else if ([result isEqualToString:@"204"]){
|
||
// 验证失败,密码不正确
|
||
|
||
LogInViewController*logvc=[[LogInViewController alloc]init];
|
||
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:logvc];
|
||
[nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||
app1.window.rootViewController=nav;
|
||
[app1.window makeToast:@"验证失败,密码不正确"];
|
||
|
||
}else if ([result isEqualToString:@"202"]){
|
||
[app1.window makeToast:@"用户未注册"];
|
||
|
||
}else if ([result isEqualToString:@"400"]){
|
||
|
||
[app1.window makeToast:@"安全校验失败"];
|
||
DisconnectNetController *connectVC =[[DisconnectNetController alloc] init];
|
||
|
||
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:connectVC];
|
||
[nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||
app1.window.rootViewController=nav;
|
||
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
|
||
DisconnectNetController *connectVC =[[DisconnectNetController alloc] init];
|
||
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:connectVC];
|
||
[nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||
app1.window.rootViewController=nav;
|
||
NSString *errstr = [NSString stringWithFormat:@"%@",err];
|
||
BLYLog(BuglyLogLevelWarn, errstr);
|
||
|
||
} expara:para];
|
||
|
||
}
|
||
|
||
|
||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||
NSTimeInterval dismissSeconds=1.0;
|
||
[alert show];
|
||
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:dismissSeconds];
|
||
|
||
}
|
||
|
||
-(void)dismissAlert:(UIAlertView*)alertView{
|
||
|
||
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
||
}
|
||
|
||
- (void)showLableAction:(NSString *)str{
|
||
AppDelegate*app=(AppDelegate*)[UIApplication sharedApplication].delegate;
|
||
UILabel *laberAction =[[UILabel alloc]init];
|
||
laberAction.frame =CGRectMake(kScreenSize.width/2 - 75, kScreenSize.height/2 , 200, 40);
|
||
laberAction.clipsToBounds =YES;
|
||
laberAction.layer.cornerRadius =5;
|
||
laberAction.alpha =1;
|
||
laberAction.text =str;
|
||
laberAction.textAlignment =NSTextAlignmentCenter;
|
||
laberAction.backgroundColor =IndicatorBack_COLOR;
|
||
laberAction.textColor=[UIColor blackColor];
|
||
|
||
[UIView animateWithDuration:2.0 animations:^{
|
||
laberAction.alpha =0;
|
||
}completion:^(BOOL finished) {
|
||
[laberAction removeFromSuperview];
|
||
}];
|
||
|
||
[app.window addSubview:laberAction];
|
||
}
|
||
|
||
-(void)makeTostView:(NSString*)str{
|
||
|
||
AppDelegate*app=(AppDelegate*)[UIApplication sharedApplication].delegate;
|
||
|
||
[app.window makeToast:str];
|
||
|
||
}
|
||
|
||
#pragma mark 获取验证码
|
||
-(void)getVerifyCodeWithTimerButton:(UIButton*)timeBtn
|
||
addPhoneNumber:(NSString*)phoneNumber
|
||
addSendType:(NSString*)sendType
|
||
backData:(backVerifyCode)backVerifyCodeblock{
|
||
[self timerFireWithTimerButton:timeBtn addPhoneNumber:phoneNumber timeBtnFinalTitle:@"语音验证码"];
|
||
[self getverifyWithTimerButton:timeBtn addphoneNumber:phoneNumber AddSendType:sendType backData:backVerifyCodeblock];
|
||
|
||
}
|
||
#pragma mark 倒计时
|
||
-(void)timerFireWithTimerButton:(UIButton*)timeBtn addPhoneNumber:(NSString*)phoneNumber timeBtnFinalTitle:(NSString *)title{
|
||
|
||
__block int timeout=60; //倒计时时间
|
||
|
||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||
_timer1 = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
|
||
dispatch_source_set_timer(_timer1,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
|
||
dispatch_source_set_event_handler(_timer1, ^{
|
||
if(timeout<=0){ //倒计时结束,关闭
|
||
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];
|
||
|
||
|
||
});
|
||
}else{
|
||
// int minutes = timeout / 60;
|
||
int seconds = timeout % 60;
|
||
NSString *strTime=@"";
|
||
if (seconds==0) {
|
||
strTime=@"60";
|
||
}else{
|
||
strTime = [NSString stringWithFormat:@"%.2d", seconds];
|
||
}
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
//设置界面的按钮显示 根据自己需求设置
|
||
// NSLog(@"____%@",strTime);
|
||
|
||
[timeBtn setTitle:[NSString stringWithFormat:@"%@秒",strTime] forState:UIControlStateNormal];
|
||
//timeBtn.backgroundColor=[UIColor lightGrayColor];
|
||
|
||
[timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation_ws"] forState:UIControlStateNormal];
|
||
timeBtn.userInteractionEnabled = NO;
|
||
|
||
});
|
||
timeout--;
|
||
|
||
}
|
||
});
|
||
dispatch_resume(_timer1);
|
||
if ([phoneNumber isEqualToString:@""]){
|
||
[self showTitle:@"" messsage:@"手机号不能为空"];
|
||
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];
|
||
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark - ali
|
||
|
||
|
||
-(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber AddSendType:(NSString*)sendType backData:(backVerifyCode)backVerifyCodeblock{
|
||
|
||
BOOL isMacth=[dataContorl valiMobile:phoneNumber];
|
||
if (isMacth==YES) {
|
||
[AFHttpTool getSecurityCodeWithPhoneNumber:phoneNumber sendType:sendType success:^(id response) {
|
||
|
||
if (response) {
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
// self.verifyTextField.text=reDic[@"data"];
|
||
NSString* verifyData=reDic[@"data"];
|
||
NSLog(@"_verifyData%@",verifyData);
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
backVerifyCodeblock(verifyData);
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
dispatch_source_cancel(_timer1);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
//设置界面的按钮显示 根据自己需求设置
|
||
[timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal];
|
||
timeBtn.userInteractionEnabled = YES;
|
||
//timeBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||
[timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
|
||
|
||
});
|
||
[self showTitle:@"" messsage:@"获取验证失败"];
|
||
// 获取验证失败
|
||
}else if ([reDic[@"result"] isEqualToString:@"201"]){
|
||
dispatch_source_cancel(_timer1);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
//设置界面的按钮显示 根据自己需求设置
|
||
[timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal];
|
||
timeBtn.userInteractionEnabled = YES;
|
||
//timeBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||
[timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
|
||
|
||
});
|
||
[self showTitle:@"" messsage:@"手机已经注册过"];
|
||
}else{
|
||
|
||
}
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请求异常" delegate:self cancelButtonTitle:@"好" otherButtonTitles: nil];
|
||
[alter show];
|
||
NSLog(@"失败");
|
||
}];
|
||
|
||
}else{
|
||
dispatch_source_cancel(_timer1);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
//设置界面的按钮显示 根据自己需求设置
|
||
[timeBtn setTitle:@"语音验证码" forState:UIControlStateNormal];
|
||
timeBtn.userInteractionEnabled = YES;
|
||
//timeBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||
[timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
|
||
|
||
});
|
||
[self showTitle:@"" messsage:@"请输入正确手机号"];
|
||
}
|
||
}
|
||
|
||
#pragma mark - SMS 新
|
||
|
||
-(void)getverifyWithTimerButton:(UIButton*)timeBtn addphoneNumber:(NSString*)phoneNumber zone:
|
||
(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 timeBtnFinalTitle:@"语音验证码"];
|
||
|
||
[SMSSDK getVerificationCodeByMethod: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:@"语音验证码" forState:UIControlStateNormal];
|
||
timeBtn.userInteractionEnabled = YES;
|
||
//timeBtn.backgroundColor=COLOR_LABEL_TITLE;
|
||
[timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
|
||
|
||
});
|
||
[self showTitle:@"" messsage:@"获取验证失败"];
|
||
|
||
}
|
||
|
||
}];
|
||
}
|
||
|
||
#pragma mark 注册
|
||
|
||
-(void)ifishRegistWithPhoneNumber:(NSString *)phoneNumber addWithPasswd:(NSString *)passwd addwithPhonetype:(NSString *)phoneType addAddress:(NSString *)address longitude:(double)longitude
|
||
latitude:(double)latitude{
|
||
|
||
NSString*passStr=[MyMD5 md5:passwd];
|
||
|
||
|
||
[AFHttpTool addUserWithPhoneNumber:phoneNumber password:passStr phoneType:phoneType address:address longitude:longitude
|
||
latitude:latitude success:^(id response) {
|
||
if (response) {
|
||
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSLog(@"result:%@",resultDic[@"result"]);
|
||
NSLog(@"resultDic:%@",resultDic);
|
||
if ([resultDic[@"result"] isEqualToString:@"100"])
|
||
{
|
||
UserModel *model=[[UserModel alloc]init];
|
||
model.phoneNumber=phoneNumber;
|
||
NSDictionary*DataDic=resultDic[@"data"];
|
||
model.userId=DataDic[@"userId"];
|
||
model.nickName=DataDic[@"nickName"];
|
||
|
||
// 保存在本地
|
||
[[DataCenter defaultDtacenter]setValue:model forKey:@"UserRegist"];
|
||
|
||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||
NSString*userName=phoneNumber;
|
||
NSString*password=passwd;
|
||
|
||
[userdefult setObject:password forKey:@"password"];
|
||
[userdefult setObject:userName forKey:@"name"];
|
||
[userdefult setObject:model.userId forKey:@"userId"];
|
||
[userdefult setObject:model.userSex forKey:@"userSex"];
|
||
[userdefult synchronize];
|
||
// 设置别名
|
||
// NSString*userID=[NSString stringWithFormat:@"%@",model.userId];
|
||
// [JPUSHService setTags:nil alias:userID callbackSelector:@selector(tagAliasCallback:tags:alias:) object:self];
|
||
//
|
||
|
||
}else{
|
||
[self showTitle:@"" messsage:@"注册失败"];
|
||
}
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请检查您的网络" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
|
||
[alter show];
|
||
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)tagAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
|
||
|
||
NSLog(@"rescode: %d, \ntags: %@, \nalias: %@\n", iResCode, tags , alias);
|
||
if (iResCode!=0) {
|
||
|
||
//NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||
//NSString*userID=[userdefult objectForKey:@"userId"];
|
||
//[JPUSHService setTags:nil alias: userID callbackSelector:@selector(tagAliasCallback:tags:alias:) object:self];
|
||
}
|
||
}
|
||
|
||
#pragma mark 保存自定义图片
|
||
-(void)saveCustomIconwith:(NSNumber*)userId customIconName:(NSString*)customIconName addDeviceId:(NSString*)deviceId addcustomShowName:(NSString*)customShowName{
|
||
|
||
[AFNOHeaderHttpTool saveCustomIconWith:userId deviceId:deviceId customIconName:customIconName customShowName:customShowName success:^(id response) {
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
|
||
}else if ([reDic[@"result"] isEqualToString:@"101"]){
|
||
|
||
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
}];
|
||
|
||
}
|
||
#pragma mark 设置换水提醒
|
||
|
||
-(void)setRemindWaterInfWith:(NSString*)deviceId
|
||
waterRemind:(NSString*)waterRemind
|
||
remindCycle:(NSString*)remindCycle
|
||
huishuiShiJian:(nexChangeWaterTime)reminDate{
|
||
|
||
[_indcView startAnimating];
|
||
[AFNOHeaderHttpTool setRemindWaterInfWith:deviceId waterRemind:waterRemind remindCycle:remindCycle success:^(id response) {
|
||
|
||
if (response) {
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSDictionary*dataDic=reDic[@"data"];
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
//setRemindWaterModel*model=[[setRemindWaterModel alloc]init];
|
||
[_indcView stopAnimating];
|
||
|
||
setRemindWaterModel*model=[[setRemindWaterModel alloc]init];
|
||
|
||
model.remindDate= dataDic[@"remindDate"];
|
||
model.todayremind=dataDic[@"todayRemind"];
|
||
model.waterremind=dataDic[@"waterRemind"];
|
||
|
||
NSNumber *cle = (NSNumber *)dataDic[@"remindCycle"];
|
||
|
||
model.remindcycle= [cle integerValue];
|
||
|
||
reminDate(model);
|
||
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
[_indcView stopAnimating];
|
||
|
||
[[UIApplication sharedApplication].keyWindow makeToast:@"设置失败"];
|
||
}
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
[_indcView stopAnimating];
|
||
}];
|
||
|
||
}
|
||
|
||
#pragma mark 获取换水提醒信息
|
||
|
||
-(void)getRemindWaterInfWith:(NSString*)deviceId
|
||
huishuiInfo:(changeWaterInf)waterinfo{
|
||
[_indcView startAnimating];
|
||
[AFNOHeaderHttpTool getRemindWaterInfwith:deviceId success:^(id response) {
|
||
|
||
if (response) {
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSDictionary*dataDic=reDic[@"data"];
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
[_indcView stopAnimating];
|
||
|
||
setRemindWaterModel*model=[[setRemindWaterModel alloc]init];
|
||
|
||
model.remindDate= dataDic[@"remindDate"];
|
||
model.todayremind=dataDic[@"todayRemind"];
|
||
model.waterremind=dataDic[@"waterRemind"];
|
||
|
||
NSNumber *cle = (NSNumber *)dataDic[@"remindCycle"];
|
||
|
||
model.remindcycle= [cle integerValue];
|
||
|
||
|
||
waterinfo(model);
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
[_indcView stopAnimating];
|
||
|
||
[[UIApplication sharedApplication].keyWindow makeToast:@"设置失败"];
|
||
}
|
||
}
|
||
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
[_indcView stopAnimating];
|
||
|
||
} ];
|
||
|
||
}
|
||
-(void)creatIndicatorView{
|
||
|
||
_indcView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||
// _indicatorView.center=CGPointMake(kScreenSize.width/2, kScreenSize.height/2+100);
|
||
_indcView.frame=CGRectMake(kScreenSize.width/2-50,kScreenSize.height/2-100,100, 100);
|
||
_indcView.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
|
||
_indcView.layer.masksToBounds=YES;
|
||
_indcView.layer.cornerRadius=5;
|
||
AppDelegate*delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
|
||
[delegate.window addSubview:_indcView];
|
||
|
||
}
|
||
|
||
|
||
-(void)scanCamerawith:(NSString *)cameraId
|
||
andeviceId:(NSString *)deviceId
|
||
backInfo:(cameraIsActive)cameraActive
|
||
success:(void (^)(id response))success
|
||
failure:(void (^)(NSError* err))failure{
|
||
|
||
[AFNOHeaderHttpTool scanCodeActiveCamea:cameraId deiviceId:deviceId success:success failure:failure];
|
||
|
||
}
|
||
|
||
//查询审核后状态(old)
|
||
-(void)shopCertifyStausWith:(NSString*)shopId
|
||
huishuiShiJian:(ShopCertifyStaus)ShopCertify
|
||
{
|
||
|
||
[AFNOHeaderHttpTool getShopsStatus:shopId success:^(id response) {
|
||
|
||
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSDictionary*dataDic=reDic[@"data"];
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
ShopCertifyStausModel*shopCertifyd=[[ShopCertifyStausModel alloc] init];
|
||
|
||
shopCertifyd.shopsId= dataDic[@"shopsId"];
|
||
shopCertifyd.userId= dataDic[@"userId"];
|
||
shopCertifyd.userName= dataDic[@"userName"];
|
||
shopCertifyd.shopsPhone= dataDic[@"shopsPhone"];
|
||
shopCertifyd.shopsName= dataDic[@"shopsName"];
|
||
shopCertifyd.shopsProvince= dataDic[@"shopsProvince"];
|
||
shopCertifyd.shopsCity= dataDic[@"shopsCity"];
|
||
shopCertifyd.shopsArea= dataDic[@"shopsArea"];
|
||
shopCertifyd.shopsAddress= dataDic[@"shopsAddress"];
|
||
shopCertifyd.picture1= dataDic[@"picture1"];
|
||
shopCertifyd.picture2= dataDic[@"picture2"];
|
||
shopCertifyd.picture3= dataDic[@"picture3"];
|
||
shopCertifyd.picture4= dataDic[@"picture4"];
|
||
shopCertifyd.status= dataDic[@"status"];
|
||
shopCertifyd.reason= dataDic[@"reason"];
|
||
|
||
CertificationShopModel *ShopsInfo= [[CertificationShopModel alloc] init];
|
||
|
||
ShopsInfo.shopsId= dataDic[@"shopsId"];
|
||
ShopsInfo.userId= dataDic[@"userId"];
|
||
ShopsInfo.userName= dataDic[@"userName"];
|
||
ShopsInfo.shopsPhone= dataDic[@"shopsPhone"];
|
||
ShopsInfo.shopsName= dataDic[@"shopsName"];
|
||
ShopsInfo.shopsProvince= dataDic[@"shopsProvince"];
|
||
ShopsInfo.shopsCity= dataDic[@"shopsCity"];
|
||
ShopsInfo.shopsArea= dataDic[@"shopsArea"];
|
||
ShopsInfo.shopsAddress= dataDic[@"shopsAddress"];
|
||
ShopsInfo.picture1= dataDic[@"picture1"];
|
||
ShopsInfo.picture2= dataDic[@"picture2"];
|
||
ShopsInfo.picture3= dataDic[@"picture3"];
|
||
ShopsInfo.picture4= dataDic[@"picture4"];
|
||
ShopsInfo.status= dataDic[@"status"];
|
||
ShopsInfo.reason= dataDic[@"reason"];
|
||
|
||
[[DataCenter defaultDtacenter] setValue:ShopsInfo forKey:@"ShopsInfo"];
|
||
|
||
ShopCertify(shopCertifyd);
|
||
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
|
||
[self makeTostView:@"查询失败101"];
|
||
}
|
||
|
||
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
|
||
|
||
}];
|
||
}
|
||
//查询审核后状态(最新)
|
||
-(void)newshopCertifyStausWith:(NSString*)shopId
|
||
huishuiShiJian:(ShopCertifyStaus)ShopCertify
|
||
{
|
||
[AFHttpTool getShopsStatus:shopId success:^(id response) {
|
||
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSDictionary*dataDic=reDic[@"data"];
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
ShopCertifyStausModel*shopCertifyd=[[ShopCertifyStausModel alloc] init];
|
||
|
||
shopCertifyd.shopsId= dataDic[@"shopsId"];
|
||
shopCertifyd.userId= dataDic[@"userId"];
|
||
shopCertifyd.userName= dataDic[@"userName"];
|
||
shopCertifyd.shopsPhone= dataDic[@"shopsPhone"];
|
||
shopCertifyd.shopsName= dataDic[@"shopsName"];
|
||
shopCertifyd.shopsProvince= dataDic[@"shopsProvince"];
|
||
shopCertifyd.shopsCity= dataDic[@"shopsCity"];
|
||
shopCertifyd.shopsArea= dataDic[@"shopsArea"];
|
||
shopCertifyd.shopsAddress= dataDic[@"shopsAddress"];
|
||
shopCertifyd.picture1= dataDic[@"picture1"];
|
||
shopCertifyd.picture2= dataDic[@"picture2"];
|
||
shopCertifyd.picture3= dataDic[@"picture3"];
|
||
shopCertifyd.picture4= dataDic[@"picture4"];
|
||
shopCertifyd.status= dataDic[@"status"];
|
||
shopCertifyd.reason= dataDic[@"reason"];
|
||
shopCertifyd.weixinCode= dataDic[@"weixinCode"];
|
||
shopCertifyd.shopLink= dataDic[@"shopLink"];
|
||
|
||
CertificationShopModel *ShopsInfo= [[CertificationShopModel alloc] init];
|
||
|
||
ShopsInfo.shopsId= dataDic[@"shopsId"];
|
||
ShopsInfo.userId= dataDic[@"userId"];
|
||
ShopsInfo.userName= dataDic[@"userName"];
|
||
ShopsInfo.shopsPhone= dataDic[@"shopsPhone"];
|
||
ShopsInfo.shopsName= dataDic[@"shopsName"];
|
||
ShopsInfo.shopsProvince= dataDic[@"shopsProvince"];
|
||
ShopsInfo.shopsCity= dataDic[@"shopsCity"];
|
||
ShopsInfo.shopsArea= dataDic[@"shopsArea"];
|
||
ShopsInfo.shopsAddress= dataDic[@"shopsAddress"];
|
||
ShopsInfo.picture1= dataDic[@"picture1"];
|
||
ShopsInfo.picture2= dataDic[@"picture2"];
|
||
ShopsInfo.picture3= dataDic[@"picture3"];
|
||
ShopsInfo.picture4= dataDic[@"picture4"];
|
||
ShopsInfo.status= dataDic[@"status"];
|
||
ShopsInfo.reason= dataDic[@"reason"];
|
||
ShopsInfo.wechat= dataDic[@"weixinCode"];
|
||
ShopsInfo.shoplink= dataDic[@"shopLink"];
|
||
|
||
[[DataCenter defaultDtacenter] setValue:ShopsInfo forKey:@"ShopsInfo"];
|
||
ShopCertify(shopCertifyd);
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
|
||
[self makeTostView:@"查询失败101"];
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
}];
|
||
|
||
}
|
||
|
||
-(void)xuanZeKanHuShnagJiaWith:(NSString *)shopsPhone
|
||
UserId :(NSNumber *)userId
|
||
xuaZeShangJia:(kanHuShangJia)kanHuShangJia
|
||
{
|
||
[AFNOHeaderHttpTool xuanZeKanHuShangJia:shopsPhone yongHuId:userId success:^(id response) {
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
NSDictionary*dataDic=reDic[@"data"];
|
||
|
||
if ([reDic[@"result"] isEqualToString:@"100"]) {
|
||
|
||
CertificationShopModel*kanHuShangJiaXinXi=[[CertificationShopModel alloc] init];
|
||
|
||
kanHuShangJiaXinXi.userId= dataDic[@"userId"];
|
||
kanHuShangJiaXinXi.userName= dataDic[@"userName"];
|
||
kanHuShangJiaXinXi.userImg = dataDic[@"userImg"];
|
||
kanHuShangJiaXinXi.shopsPhone= dataDic[@"shopsPhone"];
|
||
kanHuShangJiaXinXi.shopsName= dataDic[@"shopsName"];
|
||
kanHuShangJiaXinXi.shopsProvince= dataDic[@"shopsProvince"];
|
||
kanHuShangJiaXinXi.shopsCity= dataDic[@"shopsCity"];
|
||
kanHuShangJiaXinXi.shopsArea= dataDic[@"shopsArea"];
|
||
kanHuShangJiaXinXi.shopsAddress= dataDic[@"shopsAddress"];
|
||
kanHuShangJiaXinXi.shopsId = dataDic[@"shopsId"];
|
||
kanHuShangJiaXinXi.picture1 = dataDic[@"picture1"];
|
||
kanHuShangJiaXinXi.picture2 = dataDic[@"picture2"];
|
||
kanHuShangJiaXinXi.picture3 = dataDic[@"picture3"];
|
||
kanHuShangJiaXinXi.picture4 = dataDic[@"picture4"];
|
||
kanHuShangJiaXinXi.reason = dataDic[@"reason"];
|
||
kanHuShangJiaXinXi.status = dataDic[@"status"];
|
||
//存储
|
||
[[DataCenter defaultDtacenter]setValue:kanHuShangJiaXinXi forKey:@"ShopsInfo2"];
|
||
kanHuShangJia(kanHuShangJiaXinXi);
|
||
|
||
|
||
}else if([reDic[@"result"] isEqualToString:@"101"]){
|
||
|
||
[self makeTostView:@"失败101"];
|
||
}else if([reDic[@"result"] isEqualToString:@"212"]){
|
||
|
||
[self makeTostView:@"请填写正确的已通过爱鱼奇认证的商家手机号"];
|
||
}
|
||
|
||
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
[self makeTostView:@"出现未知领域问题"];
|
||
}];
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
@end
|