|
|
|
//
|
|
|
|
// DeviceTabViewController.m
|
|
|
|
// tongxin
|
|
|
|
//
|
|
|
|
// Created by ecell on 2023/6/14.
|
|
|
|
// Copyright © 2023 xTT. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "DeviceTabViewController.h"
|
|
|
|
#import "DeviceMenuTableViewCell.h"
|
|
|
|
#import "DeviceTabHeaderView.h"
|
|
|
|
#import "DeviceSubmenuTableViewCell.h"
|
|
|
|
#import "MyMQTT.h"
|
|
|
|
|
|
|
|
#import "JCManager.h"
|
|
|
|
#import "BRManager.h"
|
|
|
|
#import "TihuManager.h"
|
|
|
|
#import "CallViewController.h"
|
|
|
|
|
|
|
|
#define ROWHH 40;
|
|
|
|
@interface DeviceTabViewController ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) UITableView *deviceTable;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) DeviceTabHeaderView *headerView;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *ImageArr;
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *TitleArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *senerTitleArr;
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *senerImageArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSNumber *unreadTotal;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation DeviceTabViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
self.zx_navLeftBtn.titleLabel.font = FontBold_(18);
|
|
|
|
[self.zx_navLeftBtn setTitleColor:KKWhiteColorColor forState:0];
|
|
|
|
self.view.backgroundColor = RGB(244, 250, 255);
|
|
|
|
|
|
|
|
|
|
|
|
[self zx_setRightBtnWithImg:ImageName_(@"icon_switch_devices") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
|
|
|
|
[self rightBtnTouch];
|
|
|
|
}];
|
|
|
|
[self.view addSubview:self.deviceTable];
|
|
|
|
|
|
|
|
//MARK : 收到新的聊天消息推送
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:PUSH_type_chatGroupMessage
|
|
|
|
object:nil
|
|
|
|
queue:[NSOperationQueue mainQueue]
|
|
|
|
usingBlock:^(NSNotification * _Nonnull note)
|
|
|
|
{
|
|
|
|
[self getChatMsgNum];
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
[self setDeviceMenu];
|
|
|
|
[self getChatMsgNum];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UITableView *)deviceTable
|
|
|
|
{
|
|
|
|
if (!_deviceTable)
|
|
|
|
{
|
|
|
|
_deviceTable = [[UITableView alloc] initWithFrame:CGRectMake(20, iPhoneX_NavHeight, ScreenWidth-40, ScreenHeight-iPhoneX_NavHeight-TabBarHeight) style:UITableViewStyleGrouped];
|
|
|
|
_deviceTable.delegate = self;
|
|
|
|
_deviceTable.dataSource = self;
|
|
|
|
//_disTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
_deviceTable.backgroundColor = KKClearColor;
|
|
|
|
_deviceTable.tableHeaderView = self.headerView;
|
|
|
|
_deviceTable.tableHeaderView.height = 155;
|
|
|
|
_deviceTable.showsHorizontalScrollIndicator = NO;
|
|
|
|
_deviceTable.showsVerticalScrollIndicator = NO;
|
|
|
|
_deviceTable.showsHorizontalScrollIndicator = NO;
|
|
|
|
_deviceTable.showsVerticalScrollIndicator = NO;
|
|
|
|
_deviceTable.separatorStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
[_deviceTable registerClass:DeviceMenuTableViewCell.class forCellReuseIdentifier:NSStringFromClass(DeviceMenuTableViewCell.class)];
|
|
|
|
[_deviceTable registerClass:DeviceSubmenuTableViewCell.class forCellReuseIdentifier:NSStringFromClass(DeviceSubmenuTableViewCell.class)];
|
|
|
|
}
|
|
|
|
return _deviceTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (DeviceTabHeaderView *)headerView
|
|
|
|
{
|
|
|
|
if (!_headerView)
|
|
|
|
{
|
|
|
|
_headerView = [[DeviceTabHeaderView alloc] initWithFrame:CGRectMake(0, 15, ScreenWidth-32, 155)];
|
|
|
|
}
|
|
|
|
return _headerView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
|
|
{
|
|
|
|
if (section == 0)
|
|
|
|
return self.ImageArr.count;
|
|
|
|
else
|
|
|
|
return self.senerTitleArr.count;
|
|
|
|
}
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if(indexPath.section == 0)
|
|
|
|
{
|
|
|
|
if (indexPath.row == 0)
|
|
|
|
return 120;
|
|
|
|
else if (indexPath.row == 1)
|
|
|
|
{
|
|
|
|
CGFloat hh = (ScreenWidth-40)/4.5;
|
|
|
|
NSInteger count = [self.TitleArr[indexPath.row] count];
|
|
|
|
if (count < 5) return hh+ROWHH;
|
|
|
|
if (count < 9) return hh*2+ROWHH;
|
|
|
|
if (count < 13) return hh*3+ROWHH;
|
|
|
|
if (count < 17) return hh*4+ROWHH;
|
|
|
|
if (count < 21) return hh*5+ROWHH;
|
|
|
|
if (count > 20) return hh*6+ROWHH;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 120;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 55;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if (indexPath.section == 0)
|
|
|
|
{
|
|
|
|
DeviceMenuTableViewCell *cell = [DeviceMenuTableViewCell cellWithTableView:tableView indexPath:indexPath];
|
|
|
|
cell.titleStr = indexPath.row == 0 ? @"快捷功能" : indexPath.row == 1 ? @"基础功能" : @"特色功能";
|
|
|
|
cell.ImageArr = self.ImageArr[indexPath.row];
|
|
|
|
cell.TitleArr = self.TitleArr[indexPath.row];
|
|
|
|
if (indexPath.row == 0 && self.unreadTotal)
|
|
|
|
cell.chatMsgNum = self.unreadTotal.integerValue;
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DeviceSubmenuTableViewCell *cell = [DeviceSubmenuTableViewCell cellWithTableView:tableView indexPath:indexPath];
|
|
|
|
NSString *title = self.senerTitleArr[indexPath.row];
|
|
|
|
cell.titleStr = title;
|
|
|
|
cell.imageStr = self.senerImageArr[indexPath.row];
|
|
|
|
[UICommon tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath cellCoutn:self.senerTitleArr.count sizeH:0];
|
|
|
|
cell.line.hidden = indexPath.row == self.senerTitleArr.count-1 ? YES : NO;
|
|
|
|
if ([title isEqualToString:@"定位模式"])
|
|
|
|
{
|
|
|
|
NSString *tempStr = @"";
|
|
|
|
if ([cUser.cDevice.opLocationMode integerValue] == [cUser.cDevice.location_interval1 integerValue]) {
|
|
|
|
tempStr = cUser.cDevice.location_model1; //@"省电模式";
|
|
|
|
}else if ([cUser.cDevice.opLocationMode integerValue] == [cUser.cDevice.location_interval2 integerValue]){
|
|
|
|
tempStr = cUser.cDevice.location_model2; //@"正常模式";
|
|
|
|
}else if ([cUser.cDevice.opLocationMode integerValue] == [cUser.cDevice.location_interval3 integerValue]){
|
|
|
|
tempStr = cUser.cDevice.location_model3;//@"高频模式";
|
|
|
|
} else {
|
|
|
|
tempStr = cUser.cDevice.location_model2;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell.textsLabel.text = tempStr;
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"拒绝陌生人来电"])
|
|
|
|
{
|
|
|
|
UISwitch *uiSwitch = cell.customSwitch;
|
|
|
|
uiSwitch.on = [cUser.cDevice.opRejectStrangeCall boolValue];
|
|
|
|
cell.cellBack = ^(UISwitch *uiSwitch, DeviceSubmenuTableViewCell *blockCell) {
|
|
|
|
|
|
|
|
// add by lsz 2021-06-10
|
|
|
|
UIAlertController *alert = nil;
|
|
|
|
NSString *tmp = title;
|
|
|
|
alert = [myHelper getAlertWithTitle:tmp
|
|
|
|
message:@"\n开启时,只有通讯录的联系人才能双向通话,防止陌生人骚扰"
|
|
|
|
actionTitles:@[@"确定"]
|
|
|
|
style:UIAlertControllerStyleAlert
|
|
|
|
block:^(UIAlertAction *action)
|
|
|
|
{
|
|
|
|
NSLog(@"%@ -- %d", action.title, uiSwitch.on);
|
|
|
|
if ([action.title isEqualToString:@"确定"]) {
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opRejectStrangeCall":@(uiSwitch.on)}
|
|
|
|
success:^(id responseObject) {
|
|
|
|
cUser.cDevice.opRejectStrangeCall = @(uiSwitch.on);
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
uiSwitch.on = !uiSwitch.on;
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
if([action.title isEqualToString:@"取消"]) {
|
|
|
|
uiSwitch.on = !uiSwitch.on;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"拨号盘开关"])
|
|
|
|
{
|
|
|
|
UISwitch *uiSwitch = cell.customSwitch;
|
|
|
|
uiSwitch.on = [cUser.cDevice.opDialSwitch boolValue];
|
|
|
|
cell.cellBack = ^(UISwitch *uiSwitch, DeviceSubmenuTableViewCell *blockCell) {
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opCallPhone":@(uiSwitch.on)}
|
|
|
|
success:^(id responseObject) {
|
|
|
|
cUser.cDevice.opDialSwitch = @(uiSwitch.on);
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
uiSwitch.on = !uiSwitch.on;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
|
|
|
|
|
|
|
return section == 0 ? 0.1 : 38.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
|
|
|
return section == 0 ? 0.1 : 140;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
|
|
|
{
|
|
|
|
if (section == 1)
|
|
|
|
{
|
|
|
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:FontBold_(14) textColor:KKTextColor text:@"设备设置" Radius:0];
|
|
|
|
titleLabel.frame = CGRectMake(20, 15, ScreenWidth-40, 13.5);
|
|
|
|
return titleLabel;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
|
|
|
{
|
|
|
|
WeakSelf
|
|
|
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
view.backgroundColor = KKClearColor;
|
|
|
|
if(section == 1)
|
|
|
|
{
|
|
|
|
UIButton *powerBtn = [UICommon ui_buttonSimple:CGRectZero font:FontBold_(18) normalColor:KKWhiteColorColor normalText:@"远程关机" click:^(id x) {
|
|
|
|
UIAlertController *alert = [myHelper getAlertWithTitle:@"远程关机"
|
|
|
|
message:@"\n设备将会远程关机,“是否”确认"
|
|
|
|
actionTitles:@[@"确定"]
|
|
|
|
style:UIAlertControllerStyleAlert
|
|
|
|
block:^(UIAlertAction *action)
|
|
|
|
{
|
|
|
|
if ([action.title isEqualToString:@"确定"]) {
|
|
|
|
[weakSelf performOperation];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
[weakSelf presentViewController:alert animated:YES completion:nil];
|
|
|
|
}];
|
|
|
|
powerBtn.backgroundColor = mainColor;
|
|
|
|
powerBtn.layer.cornerRadius = 25;
|
|
|
|
powerBtn.layer.masksToBounds = YES;
|
|
|
|
[view addSubview:powerBtn];
|
|
|
|
[powerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.equalTo(view);
|
|
|
|
make.top.equalTo(view).offset(20);
|
|
|
|
make.height.mas_equalTo(50);
|
|
|
|
}];
|
|
|
|
|
|
|
|
UIButton *untieBtn = [UICommon ui_buttonSimple:CGRectZero font:FontBold_(18) normalColor:mainColor normalText:@"解除与设备的绑定" click:^(id x) {
|
|
|
|
[weakSelf unbundlingBtn];
|
|
|
|
}];
|
|
|
|
untieBtn.backgroundColor = KKClearColor;
|
|
|
|
untieBtn.layer.borderWidth = 1;
|
|
|
|
untieBtn.layer.borderColor = mainColor.CGColor;
|
|
|
|
untieBtn.layer.cornerRadius = 25;
|
|
|
|
[view addSubview:untieBtn];
|
|
|
|
[untieBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.equalTo(view);
|
|
|
|
make.top.equalTo(powerBtn.mas_bottom).offset(15);
|
|
|
|
make.height.mas_equalTo(50);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if (indexPath.section == 1)
|
|
|
|
{
|
|
|
|
if (indexPath.row == 0)
|
|
|
|
{
|
|
|
|
[UICommon pusXibViewController:@"LocationModeViewController"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setDeviceMenu
|
|
|
|
{
|
|
|
|
self.ImageArr = [[NSMutableArray alloc] init];
|
|
|
|
self.TitleArr = [[NSMutableArray alloc] init];
|
|
|
|
self.senerTitleArr = [[NSMutableArray alloc] init];
|
|
|
|
self.senerImageArr = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
NSMutableArray *menuTitleArr1 = [[NSMutableArray alloc] init];
|
|
|
|
NSMutableArray *menuTitleArr2 = [[NSMutableArray alloc] init];
|
|
|
|
NSMutableArray *menuTitleArr3 = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
NSMutableArray *menuImageArr1 = [[NSMutableArray alloc] init];
|
|
|
|
NSMutableArray *menuImageArr2 = [[NSMutableArray alloc] init];
|
|
|
|
NSMutableArray *menuImageArr3 = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
[menuTitleArr1 addObject:@"家庭成员"];
|
|
|
|
[menuImageArr1 addObject:@"icon_member"];
|
|
|
|
//if (cUser.cDevice.support_whiteList && )
|
|
|
|
{
|
|
|
|
[menuTitleArr1 addObject:cUser.cDevice.support_whiteList.intValue == 0 ? @"电话本" : @"管理员"];
|
|
|
|
[menuImageArr1 addObject:@"icon_phonebook"];
|
|
|
|
}
|
|
|
|
// if(cUser.cDevice.support_video.intValue == 4 || cUser.cDevice.support_video.intValue == 5 || cUser.cDevice.support_video.intValue == 1)
|
|
|
|
if(cUser.cDevice.support_video)
|
|
|
|
{
|
|
|
|
[menuTitleArr1 addObject:@"视频通话"];
|
|
|
|
[menuImageArr1 addObject:@"icon_home_video_call"];
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (cUser.cDevice.support_chat && cUser.cDevice.support_chat.intValue == 0)
|
|
|
|
{
|
|
|
|
[menuTitleArr1 addObject:@"微聊"];
|
|
|
|
[menuImageArr1 addObject:@"icon_small_talk"];
|
|
|
|
}
|
|
|
|
/*********************** 第三个菜单 *************************/
|
|
|
|
// [menuTitleArr2 addObject:@"打电话"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_answer"];
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_alarm && cUser.cDevice.support_alarm.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"设备闹钟"];
|
|
|
|
[menuImageArr2 addObject:@"icon_alarm"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_disturb && cUser.cDevice.support_disturb.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"上课禁用"];
|
|
|
|
[menuImageArr2 addObject:@"icon_disabled"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_sos && cUser.cDevice.support_sos.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"SOS号码"];
|
|
|
|
[menuImageArr2 addObject:@"icon_sosnumber"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_timingSwitch && cUser.cDevice.support_timingSwitch.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"定时开关机"];
|
|
|
|
[menuImageArr2 addObject:@"icon_off"];
|
|
|
|
}
|
|
|
|
if(cUser.cDevice.support_find && cUser.cDevice.support_find.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"查找设备"];
|
|
|
|
[menuImageArr2 addObject:@"icon_find_devices"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_schedul && cUser.cDevice.support_schedul.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"课程表"];
|
|
|
|
[menuImageArr2 addObject:@"icon_fun_schedule"];
|
|
|
|
}
|
|
|
|
if(cUser.cDevice.support_family && cUser.cDevice.support_family.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"亲情号"];
|
|
|
|
[menuImageArr2 addObject:@"icon_family"];
|
|
|
|
}
|
|
|
|
if(cUser.cDevice.support_ppFriend && cUser.cDevice.support_ppFriend.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"好友列表"];
|
|
|
|
[menuImageArr2 addObject:@"icon_fun_friends"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_step && cUser.cDevice.support_step.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"计步"];
|
|
|
|
[menuImageArr2 addObject:@"icon_Pedometer"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.deviceType && cUser.cDevice.deviceType.intValue == 2)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"学生资料"];
|
|
|
|
[menuImageArr2 addObject:@"icon_more_watch_data"];
|
|
|
|
}
|
|
|
|
|
|
|
|
[menuTitleArr2 addObject:@"设备资料"];
|
|
|
|
[menuImageArr2 addObject:@"icon_watch_data"];
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_hht && cUser.cDevice.support_hht.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"VIP客服"];
|
|
|
|
[menuImageArr2 addObject:@"icon_vip_service"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_wifi && cUser.cDevice.support_wifi.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"设备WIFI"];
|
|
|
|
[menuImageArr2 addObject:@"icon_wifi"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_monitor && cUser.cDevice.support_monitor.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"设备监听"];
|
|
|
|
[menuImageArr2 addObject:@"icon_monitor"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_appControl && cUser.cDevice.support_appControl.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"应用管理"];
|
|
|
|
[menuImageArr2 addObject:@"icon_app_management"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(cUser.cDevice.support_blood && cUser.cDevice.support_blood.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [menuTitleArr2 addObject:@"血压检测"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_details_blood"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(cUser.cDevice.support_oxygen && cUser.cDevice.support_oxygen.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [menuTitleArr2 addObject:@"血氧检测"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_details_oxygen"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(cUser.cDevice.support_heartRate.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [menuTitleArr2 addObject:@"心率检测"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_heartrate"];
|
|
|
|
// }
|
|
|
|
// if(cUser.cDevice.support_temperature.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [menuTitleArr2 addObject:@"体温检测"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_temperature"];
|
|
|
|
// }
|
|
|
|
if (cUser.cDevice.support_whiteList && cUser.cDevice.support_whiteList.intValue != 0) {
|
|
|
|
[menuTitleArr2 addObject:@"通讯录"];
|
|
|
|
[menuImageArr2 addObject:@"icon_phonebook"];
|
|
|
|
}
|
|
|
|
if(cUser.cDevice.support_photo && cUser.cDevice.support_photo.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"远程拍照"];
|
|
|
|
[menuImageArr2 addObject:@"icon_photography"];
|
|
|
|
}
|
|
|
|
if(cUser.cDevice.support_healthCode && cUser.cDevice.support_healthCode.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"健康码"];
|
|
|
|
[menuImageArr2 addObject:@"icon_ttcode_qrcode"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_hsCode && cUser.cDevice.support_hsCode.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"核酸码"];
|
|
|
|
// [menuImageArr2 addObject:@"icon_nucleicacid"];
|
|
|
|
[menuImageArr2 addObject:@"icon_ttcode_qrcode"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_sms && cUser.cDevice.support_sms.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr2 addObject:@"手表短信"];
|
|
|
|
[menuImageArr2 addObject:@"icon_dmessage"];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************** 第四个菜单 *************************/
|
|
|
|
|
|
|
|
// if(cUser.cDevice.support_BT_Avoid_Losing && cUser.cDevice.support_BT_Avoid_Losing.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr3 addObject:@"蓝牙防丢"];
|
|
|
|
//[menuImageArr3 addObject:@"icon_anti_lost"];
|
|
|
|
[menuImageArr3 addObject:@"icon_find_devices"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(cUser.cDevice.support_downDial && cUser.cDevice.support_downDial.intValue == 1)
|
|
|
|
{
|
|
|
|
[menuTitleArr3 addObject:@"表盘中心"];
|
|
|
|
[menuImageArr3 addObject:@"icon_dial"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// [menuTitleArr3 addObject:@"钱包"];
|
|
|
|
// [menuImageArr3 addObject:@"icon_wallet"];
|
|
|
|
|
|
|
|
[self.ImageArr addObject:menuImageArr1];
|
|
|
|
[self.TitleArr addObject:menuTitleArr1];
|
|
|
|
|
|
|
|
if (menuImageArr2.count > 0)
|
|
|
|
{
|
|
|
|
[self.ImageArr addObject:menuImageArr2];
|
|
|
|
[self.TitleArr addObject:menuTitleArr2];
|
|
|
|
}
|
|
|
|
if (menuImageArr3.count > 0)
|
|
|
|
{
|
|
|
|
[self.ImageArr addObject:menuImageArr3];
|
|
|
|
[self.TitleArr addObject:menuTitleArr3];
|
|
|
|
}
|
|
|
|
[self.senerTitleArr addObject:@"定位模式"];
|
|
|
|
[self.senerImageArr addObject:@"icon_locate_mode"];
|
|
|
|
[self.senerTitleArr addObject:@"拒绝陌生人来电"];
|
|
|
|
[self.senerImageArr addObject:@"icon_incoming"];
|
|
|
|
if (cUser.cDevice.support_callPhone && cUser.cDevice.support_callPhone.intValue == 1)
|
|
|
|
[self.senerTitleArr addObject:@"拨号盘开关"];
|
|
|
|
[self.senerImageArr addObject:@"icon_dial_switch"];
|
|
|
|
|
|
|
|
|
|
|
|
[self.zx_navLeftBtn setTitle:cUser.cDevice.name forState:0];
|
|
|
|
[self.headerView setModel];
|
|
|
|
[self.deviceTable reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rightBtnTouch
|
|
|
|
{
|
|
|
|
WeakSelf
|
|
|
|
[DeviceSwitchover.sharedManager showMenuViewWithAdd:NO Point:CGPointMake(ScreenWidth - 30, getRectNavAndStatusHight - 10)];
|
|
|
|
[DeviceSwitchover.sharedManager setSwitchDevice:^(NSInteger index) {
|
|
|
|
Device *device = cUser.myDevices[index];
|
|
|
|
[weakSelf switchDeviceWithDevice:device];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
//MARK: 切换设备
|
|
|
|
/**
|
|
|
|
切换设备
|
|
|
|
@param mainDevice 设备信息
|
|
|
|
*/
|
|
|
|
-(void)switchDeviceWithDevice:(Device*) mainDevice
|
|
|
|
{
|
|
|
|
cUser.cDevice = mainDevice;
|
|
|
|
|
|
|
|
//MARK: add by lsz 2020-12-28 记录当前设备imei
|
|
|
|
[User saveDefaultImei:mainDevice.imei];
|
|
|
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
[self setMainDevWithMainDevCell:cUser.cDevice];
|
|
|
|
});
|
|
|
|
|
|
|
|
xLog(@"-------switchDeviceWithDevice-----------");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMainDevWithMainDevCell:(Device*)mainDevice
|
|
|
|
{
|
|
|
|
[self setDeviceMenu];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
解除绑定 方法
|
|
|
|
*/
|
|
|
|
- (void)unbundlingBtn
|
|
|
|
{
|
|
|
|
// 管理员显示--- 您是设备的管理员,如果您进行解绑,其他绑定该设备的用户,将自动解绑,确认解除绑定吗? F
|
|
|
|
NSString *title = @"解绑设备";
|
|
|
|
NSString *msg = @"\n解除绑定后,将无法对设备进行监护,设备将重启,其他绑定该设备的用户,将自动解绑";
|
|
|
|
if([cUser.cDevice.identity isEqualToString:@"admin"]){
|
|
|
|
msg = @"\n您是设备的管理员,如果您进行解绑,其他绑定该设备的用户,将自动解绑,确认解除绑定吗?";
|
|
|
|
}
|
|
|
|
|
|
|
|
//如果是 imei号登陆
|
|
|
|
int type = [myHelper getNowAccoutType:cUser];
|
|
|
|
if(type == 3)
|
|
|
|
{
|
|
|
|
msg = @"\n解除绑定后,设备将被恢复出厂设置,确认解除绑定吗?";
|
|
|
|
}
|
|
|
|
UIAlertController *sheet = [myHelper getAlertWithTitle:title
|
|
|
|
message:msg
|
|
|
|
actionTitles:@[@"确定"]
|
|
|
|
style:UIAlertControllerStyleAlert
|
|
|
|
block:^(UIAlertAction *action)
|
|
|
|
{
|
|
|
|
if ([action.title isEqualToString:@"确定"])
|
|
|
|
{
|
|
|
|
NSMutableDictionary * parameters = [NSMutableDictionary dictionary];
|
|
|
|
[parameters setObject:cUser.cDevice.imei forKey:@"imei"];
|
|
|
|
[cUser deleteDeviceSuccess:^(id responseObject) {
|
|
|
|
int type = [myHelper getNowAccoutType:cUser];
|
|
|
|
if(type == 3)
|
|
|
|
{
|
|
|
|
//如果是 imei 号 直接 退出登录
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin" object:nil];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//回到首页
|
|
|
|
[self updataDeviceListModel];
|
|
|
|
}
|
|
|
|
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
[self presentViewController:sheet animated:YES completion:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark 远程关机
|
|
|
|
/// 远程关机
|
|
|
|
- (void)performOperation
|
|
|
|
{
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
[parameters setObject:@(YES) forKey:@"opPowerOff"];
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:parameters success:^(id responseObject) {
|
|
|
|
[SVProgressHUD showSuccessWithStatus:@"远程关机成功"];
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)updataDeviceListModel
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
//刷新 关联数据
|
|
|
|
if(!cUser){
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin" object:nil];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Device *defaultDev = nil;
|
|
|
|
NSString *defaultImei = [User getDefaultImei];
|
|
|
|
if (defaultImei && cUser.myDevices) {
|
|
|
|
for (Device *dev in cUser.myDevices) {
|
|
|
|
if ([defaultImei isEqualToString:dev.imei]) {
|
|
|
|
defaultDev = dev;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defaultDev)
|
|
|
|
{
|
|
|
|
cUser.cDevice = defaultDev;
|
|
|
|
NSLog(@"===default:%@",defaultImei);
|
|
|
|
}
|
|
|
|
else if (![cUser.myDevices containsObject:cUser.cDevice] && cUser.myDevices.count > 0)
|
|
|
|
{
|
|
|
|
cUser.cDevice = [cUser.myDevices firstObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
[cUser getRelatedDeviceSuccess:^(id responseObject) {
|
|
|
|
[cUser getUserInfoSuccess:^(id responseObject) {
|
|
|
|
|
|
|
|
BOOL haveJuphoonDevice = NO;
|
|
|
|
for (Device* item in cUser.myDevices) {
|
|
|
|
if (item.support_video.integerValue == 4) {
|
|
|
|
haveJuphoonDevice = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(haveJuphoonDevice)
|
|
|
|
{
|
|
|
|
//MARK:拥有菊风的设备,需要登录 账号 (调试时期暂时停止)
|
|
|
|
if(![JCManager shared].client)
|
|
|
|
{
|
|
|
|
[[JCManager shared] initializeWithAPPKey:cUser.juphoonKey];
|
|
|
|
JCClientLoginParam* loginParam = [[JCClientLoginParam alloc] init];
|
|
|
|
loginParam.directConnectEnable = YES;
|
|
|
|
[[JCManager shared].client setServerAddress:@"http:cn.router.justalkcloud.com:8080"];
|
|
|
|
[[JCManager shared].client login:cUser.openid password:@"test" loginParam:loginParam];
|
|
|
|
[[JCManager shared].mediaDevice enableSpeaker:YES];
|
|
|
|
[JCManager shared].gMianVC = self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BOOL haveBairuiDevice = NO;
|
|
|
|
for (Device* item in cUser.myDevices)
|
|
|
|
{
|
|
|
|
if (item.support_video.integerValue == 5)
|
|
|
|
{
|
|
|
|
haveBairuiDevice = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(haveBairuiDevice)
|
|
|
|
{
|
|
|
|
//MARK:拥有佰锐的设备,需要登录 账号
|
|
|
|
if (![[BRManager shared] isUserLogin])
|
|
|
|
{
|
|
|
|
[[BRManager shared] initialize];
|
|
|
|
[BRManager shared].gMianVC = self;
|
|
|
|
[[BRManager shared] login:cUser.bairui_id nick:cUser.name];
|
|
|
|
}
|
|
|
|
xLog(@"佰锐账号是:%d", [cUser.bairui_id intValue]);
|
|
|
|
}
|
|
|
|
BOOL haveTihuDevice = NO;
|
|
|
|
for (Device* item in cUser.myDevices)
|
|
|
|
{
|
|
|
|
if (item.support_video.integerValue == 6)
|
|
|
|
{
|
|
|
|
haveTihuDevice = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(haveTihuDevice)
|
|
|
|
{
|
|
|
|
//MARK:拥有鹈鹕的设备,需要登录账号
|
|
|
|
if (![[TihuManager shared] isUserLogin])
|
|
|
|
{
|
|
|
|
[[TihuManager shared] initialize];
|
|
|
|
[TihuManager shared].gMianVC = self;
|
|
|
|
[[TihuManager shared] login:cUser.openid pwd:@"123456"];
|
|
|
|
|
|
|
|
xLog(@"鹈鹕账号是:%@", cUser.openid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//MARK:拥有声网的设备,需要调用查询接口,判断是否有用户在正在通话中的
|
|
|
|
for (Device *item in cUser.myDevices)
|
|
|
|
{
|
|
|
|
if (item.support_video.integerValue == 1)
|
|
|
|
{
|
|
|
|
[cUser getVideoInfoWithDeviceImei:item.imei CallType:0 Success:^(NSDictionary *responseObject) {
|
|
|
|
if ([responseObject valueForKey:@"video_id"]){
|
|
|
|
NSLog(@"===%@",responseObject);
|
|
|
|
if(![[self getCurrentVC] isKindOfClass:[CallViewController class]])
|
|
|
|
{
|
|
|
|
[weakSelf showCallViewWithDic:responseObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] postNotificationName:@"VideoCall" object:responseObject userInfo:responseObject];
|
|
|
|
}
|
|
|
|
} failure:^{
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} failure:nil];
|
|
|
|
|
|
|
|
if (cUser.myDevices.count > 0)
|
|
|
|
{
|
|
|
|
[cUser getRelatedChatGroupSuccess:^(id responseObject) {
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // TODO 0.5-->0.1
|
|
|
|
[weakSelf reloadDisSelectDevicesArr];
|
|
|
|
});
|
|
|
|
} failure:nil];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[weakSelf reloadDisSelectDevicesArr];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSString *agreeImei = [User agreeImei];
|
|
|
|
Device *agreeDevice;
|
|
|
|
if (agreeImei && cUser.myDevices)
|
|
|
|
{
|
|
|
|
for (Device *dev in cUser.myDevices)
|
|
|
|
{
|
|
|
|
if ([agreeImei isEqualToString:dev.imei])
|
|
|
|
{
|
|
|
|
agreeDevice = dev;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(agreeDevice)
|
|
|
|
{
|
|
|
|
[weakSelf switchDeviceWithDevice:agreeDevice];
|
|
|
|
[User removeAgreeImei];
|
|
|
|
}
|
|
|
|
// MARK 切换到同意的绑定设备 =====================================
|
|
|
|
|
|
|
|
} failure:nil];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
刷新 数据,判断设备 是否 被解绑或者新添加了设备
|
|
|
|
*/
|
|
|
|
-(void)reloadDisSelectDevicesArr
|
|
|
|
{
|
|
|
|
if(cUser.myDevices.count != 0)
|
|
|
|
{
|
|
|
|
//查找 当前的 设备是否是 在 myDevices 中 ,如果不在 , cDevice 用第一个
|
|
|
|
Device *mainDevice = cUser.cDevice;
|
|
|
|
//是否 存在 在列表中
|
|
|
|
BOOL isExist = NO;
|
|
|
|
for (Device* tempDevice in cUser.myDevices)
|
|
|
|
{
|
|
|
|
if([tempDevice.imei isEqualToString:mainDevice.imei])
|
|
|
|
{
|
|
|
|
isExist = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!isExist)
|
|
|
|
{
|
|
|
|
mainDevice = cUser.myDevices.firstObject;
|
|
|
|
cUser.cDevice = mainDevice;
|
|
|
|
}
|
|
|
|
[self switchDeviceWithDevice:mainDevice];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.tabBarController.selectedIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取当前屏幕显示的viewcontroller
|
|
|
|
- (UIViewController *)getCurrentVC
|
|
|
|
{
|
|
|
|
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
|
UIViewController *currentVC = [self getCurrentVCFrom:rootViewController];
|
|
|
|
return currentVC;
|
|
|
|
}
|
|
|
|
- (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC
|
|
|
|
{
|
|
|
|
UIViewController *currentVC;
|
|
|
|
if ([rootVC presentedViewController])
|
|
|
|
{
|
|
|
|
// 视图是被presented出来的
|
|
|
|
rootVC = [rootVC presentedViewController];
|
|
|
|
}
|
|
|
|
if ([rootVC isKindOfClass:[UITabBarController class]])
|
|
|
|
{
|
|
|
|
// 根视图为UITabBarController
|
|
|
|
currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]];
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ([rootVC isKindOfClass:[UINavigationController class]])
|
|
|
|
{
|
|
|
|
// 根视图为UINavigationController
|
|
|
|
currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// 根视图为非导航类
|
|
|
|
currentVC = rootVC;
|
|
|
|
}
|
|
|
|
return currentVC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取单聊群聊未读总数
|
|
|
|
- (void)getChatMsgNum
|
|
|
|
{
|
|
|
|
[cUser.cDevice getChatGroupsUnreadTotalSuccess:^(id responseObject) {
|
|
|
|
|
|
|
|
self.unreadTotal = responseObject[@"unreadTotal"];
|
|
|
|
[self.deviceTable reloadData];
|
|
|
|
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
#pragma mark - Navigation
|
|
|
|
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
|
|
// Get the new view controller using [segue destinationViewController].
|
|
|
|
// Pass the selected object to the new view controller.
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
@end
|