摄像头分享和二维码生成规则修改

This commit is contained in:
kai60
2020-05-16 17:17:21 +08:00
parent 9b266aea7b
commit aff0f33ec6
6 changed files with 136 additions and 23 deletions
@@ -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])
{
+72 -10
View File
@@ -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:@"分享失败"];