From aff0f33ec68bee9fd5de25eecd0f5c862dc82ae4 Mon Sep 17 00:00:00 2001 From: kai60 Date: Sat, 16 May 2020 17:17:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E5=92=8C=E4=BA=8C=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish/Utinitys/Define.h | 2 +- .../IfishHttpRequest/IfishDataUnity.m | 59 +++++++++++-- .../XuTo/Xuanduo2SettingController.m | 2 +- .../IfishP2PMonitorController.m | 4 +- .../erweima/CreatErWeiMaController.m | 10 ++- .../controllers/erweima/ScanViewController.m | 82 ++++++++++++++++--- 6 files changed, 136 insertions(+), 23 deletions(-) diff --git a/Ifish/Utinitys/Define.h b/Ifish/Utinitys/Define.h index 479295b..3a532ab 100644 --- a/Ifish/Utinitys/Define.h +++ b/Ifish/Utinitys/Define.h @@ -220,7 +220,7 @@ alpha:1.0] #define kShareDevice [NSString stringWithFormat:@"app.ifish7.com/api/user/shareDevice.do",JIEKOUPORT] // 扫一扫分享设备 已最新 -#define kshareDeviceByQrCode [NSString stringWithFormat:@"%@/api/users/sharingDevice/",JIEKOUPORT] +#define kshareDeviceByQrCode [NSString stringWithFormat:@"%@/api/user/shareDeviceByQrCode.do",JIEKOUPORT] // 解除分享的设备 #define kdeleteShareDevice [NSString stringWithFormat:@"%@/api/user/deleteShareDevice.do",JIEKOUPORT] diff --git a/Ifish/Utinitys/IfishHttpRequest/IfishDataUnity.m b/Ifish/Utinitys/IfishHttpRequest/IfishDataUnity.m index 406f019..571b095 100644 --- a/Ifish/Utinitys/IfishHttpRequest/IfishDataUnity.m +++ b/Ifish/Utinitys/IfishHttpRequest/IfishDataUnity.m @@ -12,6 +12,7 @@ #import "IfishNewsModel.h" #import "IfishHotBarVc.h" #import "Xuanduo2fController.h" +#import "IfishP2PMonitorController.h" @implementation IfishDataUnity @@ -48,15 +49,57 @@ { + if (dataDic[@"cameraId"]) + { + IfishCameraModel *camera=[[IfishCameraModel alloc] initWithDict:dataDic]; + [deviceArry insertObject:camera atIndex:0]; + [[DataCenter defaultDtacenter]setValue:deviceArry forKey:@"cameraArr"]; + if (scanVC) + { + [scanVC dismissViewControllerAnimated:YES completion:^{ + IfishP2PMonitorController *p2pVC=[[IfishP2PMonitorController alloc] init]; + p2pVC.contact = camera; + UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:p2pVC]; + UIApplication*app=[UIApplication sharedApplication]; + AppDelegate*app1=(AppDelegate*)app.delegate; + app1.window.rootViewController=nav; + }]; + } + else + { + IfishP2PMonitorController *p2pVC=[[IfishP2PMonitorController alloc] init]; + p2pVC.contact = camera; + UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:p2pVC]; + UIApplication*app=[UIApplication sharedApplication]; + AppDelegate*app1=(AppDelegate*)app.delegate; + app1.window.rootViewController=nav; + } + } + else + { + DeviceModel*devicemodel=[[DeviceModel alloc]initWithDict:dataDic]; + //设备 + [deviceArry insertObject:devicemodel atIndex:0]; + + [[DataCenter defaultDtacenter]setValue:deviceArry forKey:@"deviceInfo"]; + + if ([devicemodel.type isEqualToString:DECICE_TYPE_XUANDUO3F]) { + NSMutableDictionary*petStores=[[DataCenter defaultDtacenter] valueForKey:@"petStores"]; + for (NSMutableArray*array in petStores.allValues) { + + + [array insertObject:devicemodel atIndex:0]; + break; + } + + [[DataCenter defaultDtacenter]setValue:petStores forKey:@"petStores"]; + [[DataCenter defaultDtacenter].cache setString:devicemodel.macAddress forKey:@"currentPetDevice"]; + + } + + [self initAppCenterVcWith:devicemodel addWithdissMisVc:scanVC]; + } - DeviceModel*devicemodel=[[DeviceModel alloc]initWithDict:dataDic]; - //设备 - [deviceArry insertObject:devicemodel atIndex:0]; - - [[DataCenter defaultDtacenter]setValue:deviceArry forKey:@"deviceInfo"]; - - - [self initAppCenterVcWith:devicemodel addWithdissMisVc:scanVC]; } diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.m index 1082dbe..0c05b49 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.m @@ -337,7 +337,7 @@ static NSString *setTimerflag = @"SetTimerCell"; - [cell configTitleLabel:@"循环开关" timer:[NSString stringWithFormat:@" %d分钟",[dataContorl hexToTen:model.lastTime]] switchStatus:isOn]; + [cell configTitleLabel:@"循环开关" timer:[NSString stringWithFormat:@"持续时长 %d分钟",[dataContorl hexToTen:model.lastTime]] switchStatus:isOn]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m index 4455520..5b4db33 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m @@ -622,7 +622,7 @@ Strong UIImage *screenShotImage;//截图 } else { - title=@"水族城"; + title=@"水族箱"; } [seg initleftTitle:@"摄像头" addRightTitle:title isSelectStyle:YES]; @@ -1060,7 +1060,7 @@ Strong UIImage *screenShotImage;//截图 NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:12]; [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [title length])]; - [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(9,4)]; + [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(13,4)]; [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,13)]; [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange([title length]-1,1)]; [notbindBtn setAttributedTitle:attributedString forState:UIControlStateNormal]; diff --git a/Ifish/controllers/erweima/CreatErWeiMaController.m b/Ifish/controllers/erweima/CreatErWeiMaController.m index 10e3ee4..5030cb1 100644 --- a/Ifish/controllers/erweima/CreatErWeiMaController.m +++ b/Ifish/controllers/erweima/CreatErWeiMaController.m @@ -46,7 +46,15 @@ if ([self.erdevicemodel.deviceId isKindOfClass:[NSNumber class]]) { self.erdevicemodel.deviceId=[NSString stringWithFormat:@"%ld",self.erdevicemodel.deviceId.integerValue]; } - NSString*str=[NSString stringWithFormat:@"deviceId=%@",self.erdevicemodel.deviceId.length?self.erdevicemodel.deviceId:[CommonUtils getNotNilStr:self.deviceid]]; + NSString*type=@"deviceId"; + if ([_erdevicemodel.type isEqualToString:DECICE_TYPE_XUANDUO3F]) { + type=@"petdeviceId"; + } + else if (self.deviceid.length) + { + type=@"cameraId"; + } + NSString*str=[NSString stringWithFormat:@"%@=%@",type,self.erdevicemodel.deviceId.length?self.erdevicemodel.deviceId:[CommonUtils getNotNilStr:self.deviceid]]; self.erWeiMaView.image=[QRCodeGenerator qrImageForString:str imageSize:self.erWeiMaView.bounds.size.width]; if ([self.erdevicemodel.type isEqualToString:DECICE_TYPE_XUANDUO3F]) { diff --git a/Ifish/controllers/erweima/ScanViewController.m b/Ifish/controllers/erweima/ScanViewController.m index d77dd25..a7dba5c 100644 --- a/Ifish/controllers/erweima/ScanViewController.m +++ b/Ifish/controllers/erweima/ScanViewController.m @@ -225,16 +225,24 @@ //deviceId= 水族箱设备标识 NSString*formatSting=[NSString stringWithFormat:@"%@",str]; - NSString*headstring=[formatSting substringWithRange:NSMakeRange(0,9)]; - NSString*deviceIdString=[str substringFromIndex:9]; - if ([headstring isEqualToString:@"deviceId="]){ + NSArray*array=[formatSting componentsSeparatedByString:@"="]; + NSString*headstring=@""; + NSString*deviceIdString=@""; + if (array.count==2) + { + headstring=array[0]; + deviceIdString=array[1]; + } + + //宠物笼 鱼缸 + if ([headstring isEqualToString:@"deviceId"]||[headstring isEqualToString:@"petdeviceId"]){ UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"]; NSArray*arry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"]; NSMutableArray*deviceIdArr=[[NSMutableArray alloc]init]; DeviceModel*deviceModel=[[DeviceModel alloc]init]; if ([arry count]==0) { - [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString]; + [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString type:headstring]; }else{ @@ -256,11 +264,47 @@ }]; }else{ - [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString]; + [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString type:headstring]; } } - }else{ + }//摄像头 + else if ([headstring isEqualToString:@"cameraId"]){ + + UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"]; + NSArray*arry=[dataContorl getallCameras]; +; + NSMutableArray*deviceIdArr=[[NSMutableArray alloc]init]; + + if ([arry count]==0) { + [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString type:headstring]; + + }else{ + + + for (IfishCameraModel* cama in arry) { + NSString*string=[NSString stringWithFormat:@"%@",cama.cameraId]; + [deviceIdArr addObject:string]; + + } + + + + BOOL isExst=[deviceIdArr containsObject:deviceIdString]; + if (isExst) { + + [self.view makeToast:@"设备已经存在"]; + [self dismissViewControllerAnimated:YES completion:^{ + + }]; + + }else{ + [self shareDeviceWithUserId:model.userId addDeviceId:deviceIdString type:headstring]; + } + } + + } + else{ if ([str hasPrefix:@"iFishCamera:"]) { @@ -294,21 +338,39 @@ #pragma mark - 扫一扫 绑定水族箱 //老版本扫一扫 绑定 接口中无请求头 已换新接口 --(void)shareDeviceWithUserId:(NSNumber*)userId addDeviceId:(NSString*)deviceId{ +-(void)shareDeviceWithUserId:(NSNumber*)userId addDeviceId:(NSString*)deviceId type:(NSString*)type{ NSString *userID =[NSString stringWithFormat:@"%@",userId]; - NSString *url = [NSString stringWithFormat:@"%@%@",kshareDeviceByQrCode,userID]; + NSString *url = [NSString stringWithFormat:@"%@",kshareDeviceByQrCode]; NSDictionary*para=@{ - @"deviceId":deviceId - }; + @"deviceId":deviceId,@"userId":userID + }; + if ([type isEqualToString:@"petdeviceId"]) + { + url=[NSString stringWithFormat:@"%@/api/user/sharePetDeviceByQrCode.do",JIEKOUPORT]; + para=@{ + @"deviceId":deviceId,@"userId":userID + }; + } + else if ([type isEqualToString:@"cameraId"]) + { + url=[NSString stringWithFormat:@"%@/api/user/shareCamaraDeviceByQrCode.do",JIEKOUPORT]; + para=@{ + @"deviceId":deviceId,@"userId":userID + }; + } [AFHttpTool requestWihtMethod:RequestMethodTypePost url:url params:para success:^(id response) { NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; NSLog(@"result:%@",resultDic[@"result"]); if ([resultDic[@"result"] isEqualToString:@"100"]) { NSMutableArray*deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"]; + if ([type isEqualToString:@"cameraId"]) + { + deviceArry=[dataContorl getallCameras]; + } [[IfishDataUnity shareDataInstance] addDeviceByQRCodeWithDic:resultDic addWith:deviceArry dismiss:self]; }else if ([resultDic[@"result"] isEqualToString:@"101"]){ [self.view makeToast:@"分享失败"];