|
|
|
//
|
|
|
|
// WatchHomeViewController.m
|
|
|
|
// watch
|
|
|
|
//
|
|
|
|
// Created by xTT on 2017/7/3.
|
|
|
|
// Copyright © 2017年 xTT. All rights reserved.
|
|
|
|
//
|
|
|
|
#import "MyTabBarViewController.h"
|
|
|
|
#import "WatchHomeViewController.h"
|
|
|
|
#import "MyMQTT.h"
|
|
|
|
#import "WCUpVersionView.h"
|
|
|
|
#import "EditDeviceViewController.h"
|
|
|
|
#import "HomeEmptyView.h"
|
|
|
|
#import "CustomAnnotationView.h"
|
|
|
|
#import "CLLocation+YCLocation.h"
|
|
|
|
#import "WatchFunctionCell.h"
|
|
|
|
#import "WatchHomeDevMainCell.h"
|
|
|
|
#import "WHomeFunCell.h"
|
|
|
|
#import "WHomeHeartAndTempCell.h"
|
|
|
|
#import "CarouselViewCell.h"
|
|
|
|
#import "HomeEmptyViewCell.h"
|
|
|
|
#import "HAndTViewController.h"
|
|
|
|
#import "WebViewController.h"
|
|
|
|
#import "OfficialAccountPushSwitch.h"
|
|
|
|
#import "JCManager.h"
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "BRManager.h"
|
|
|
|
#import "TihuManager.h"
|
|
|
|
#import "ContactsViewController.h"
|
|
|
|
#import "SOSViewController.h"
|
|
|
|
#import "VoiceAlarmViewController.h"
|
|
|
|
#import "DisturbBanViewController.h"
|
|
|
|
#import "RemoteCameraViewController.h"
|
|
|
|
#import "MonitorViewController.h"
|
|
|
|
|
|
|
|
//高德SDK
|
|
|
|
#import <AMapFoundationKit/AMapFoundationKit.h>
|
|
|
|
#import <AMapSearchKit/AMapSearchKit.h>
|
|
|
|
|
|
|
|
#import "CommonTableView.h"
|
|
|
|
#import "WatchHomeHeaderView.h"
|
|
|
|
#import "WatchHomeMenuTableViewCell.h"
|
|
|
|
|
|
|
|
#import "NewStepVC.h"
|
|
|
|
#import "RedFlowerSetVC.h"
|
|
|
|
#import "WiFiViewController.h"
|
|
|
|
#import "TimingSwitchVC.h"
|
|
|
|
#import "FamilyViewController.h"
|
|
|
|
#import "WhiteContactViewController.h"
|
|
|
|
#import "StudentInfoViewController.h"
|
|
|
|
#import "CourseViewController.h"
|
|
|
|
#import "jjcdViewController.h"
|
|
|
|
#import "DeviceLoseViewController.h"
|
|
|
|
#import "VIPViewController.h"
|
|
|
|
#import "WatchDialViewController.h"
|
|
|
|
#import "TimingSwitchModel.h"
|
|
|
|
#import "RejectStrangeCallViewController.h"
|
|
|
|
#import "NoWatchView.h"
|
|
|
|
#import "CommonPopView.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define TimeLableDefineFont [UIFont systemFontOfSize:10]
|
|
|
|
@interface WatchHomeViewController ()<YBPopupMenuDelegate,AMapSearchDelegate>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@property (nonatomic ,strong) NSMutableArray *headTitleArr;
|
|
|
|
//@property (nonatomic ,strong) NSMutableArray *headImageArr;
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *cellTitleArr;
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *cellImageArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) WatchHomeHeaderView *headerView;
|
|
|
|
@property (nonatomic ,strong) CommonTableView *watchHomeTable;
|
|
|
|
|
|
|
|
/// 当前是手表
|
|
|
|
@property (nonatomic ,assign) NSInteger currentPage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
未被选中的 Device 列表
|
|
|
|
*/
|
|
|
|
@property (nonatomic ,strong) NSMutableArray * disSelectDevicesArr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (strong, nonatomic) TimingSwitchModel *model;
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NoWatchView *noView;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation WatchHomeViewController
|
|
|
|
|
|
|
|
|
|
|
|
//MARK : 设置聊天角标
|
|
|
|
-(void)setCornerMark{
|
|
|
|
//-------设置 聊天消息红点---------
|
|
|
|
//获取当前圈子
|
|
|
|
Circle* currentCircle = [cUser getCircleWithImei:cUser.cDevice.imei];
|
|
|
|
if(!currentCircle){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
xLog(@"-------设置 聊天消息红点---------");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
self.view.backgroundColor = KKBackgroundGrey;
|
|
|
|
self.zx_hideBaseNavBar = YES;
|
|
|
|
|
|
|
|
UIImageView *topImg = [[UIImageView alloc] init];
|
|
|
|
topImg.image = ImageName_(@"comm_bg_img_");
|
|
|
|
[self.view addSubview:topImg];
|
|
|
|
[topImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.equalTo(self.view);
|
|
|
|
make.left.right.equalTo(self.view);
|
|
|
|
make.height.mas_equalTo(Adapted(topImg.image.size.height));
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
[self.view addSubview:self.watchHomeTable];
|
|
|
|
[self.watchHomeTable mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
|
|
|
|
make.left.right.equalTo(self.view);
|
|
|
|
make.bottom.equalTo(self.view.mas_bottom);
|
|
|
|
}];
|
|
|
|
|
|
|
|
self.noView = [[NoWatchView alloc] init];
|
|
|
|
self.noView.hidden = YES;
|
|
|
|
[self.view addSubview:self.noView];
|
|
|
|
|
|
|
|
UIButton *rightBtn = [UICommon ui_buttonSimple:CGRectMake(ScreenWidth-44-15, iPhoneX_NavHeight-44, 44, 44) font:Font_(0) normalColor:KKWhiteColorColor normalText:@"" click:^(id x) {
|
|
|
|
[self rightBarItemClick];
|
|
|
|
}];
|
|
|
|
[rightBtn setImage:ImageName_(@"home_addWatch_icon") forState:0];
|
|
|
|
[self.view addSubview:rightBtn];
|
|
|
|
|
|
|
|
UILabel *leftLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBoldADA_(18) textColor:KKBlack20 text:@"守护" Radius:0];
|
|
|
|
[self.view addSubview:leftLabel];
|
|
|
|
[leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.equalTo(self.view).offset(15);
|
|
|
|
make.centerY.equalTo(rightBtn);
|
|
|
|
}];
|
|
|
|
|
|
|
|
WEAKSELF
|
|
|
|
//MARK : 收到新的聊天消息推送
|
|
|
|
// [[NSNotificationCenter defaultCenter] addObserverForName:PUSH_type_chatGroupMessage
|
|
|
|
// object:nil
|
|
|
|
// queue:[NSOperationQueue mainQueue]
|
|
|
|
// usingBlock:^(NSNotification * _Nonnull note)
|
|
|
|
// {
|
|
|
|
// [cUser getRelatedDeviceSuccess:^(id responseObject) {
|
|
|
|
// [cUser getUserInfoSuccess:nil failure:nil];
|
|
|
|
//
|
|
|
|
// if (cUser.myDevices.count > 0) {
|
|
|
|
// [cUser getRelatedChatGroupSuccess:^(id responseObject) {
|
|
|
|
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
// [weakSelf setCornerMark];
|
|
|
|
//
|
|
|
|
// xLog(@"--------PUSH 设置 聊天消息红点----------");
|
|
|
|
// });
|
|
|
|
// } failure:nil];
|
|
|
|
// [weakSelf showRoHiddenAllFunction:YES];
|
|
|
|
// }else{
|
|
|
|
// [weakSelf showRoHiddenAllFunction:NO];
|
|
|
|
// }
|
|
|
|
// } failure:^(id faiObject) {
|
|
|
|
//
|
|
|
|
// }];
|
|
|
|
// }];
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:@"LoginComplete"
|
|
|
|
object:nil
|
|
|
|
queue:[NSOperationQueue mainQueue]
|
|
|
|
usingBlock:^(NSNotification * _Nonnull note)
|
|
|
|
{
|
|
|
|
// 白色状态栏
|
|
|
|
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
|
|
|
|
//MARK: 如果 没有deviceToken 就 重新注册 推送
|
|
|
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
if(!app.deviceTokenStr){
|
|
|
|
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
|
|
|
|
|
|
|
}
|
|
|
|
//上传更新版本到后台
|
|
|
|
[weakSelf upDataVersion];
|
|
|
|
|
|
|
|
[weakSelf viewWillAppear:YES];
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//延迟2秒后订阅通知,不然会调用2次 viewWillAppear
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
//MARK: 灭屏后亮屏会 通知
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
|
|
|
[weakSelf viewWillAppear:YES];
|
|
|
|
}];
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
[self upDataVersion];
|
|
|
|
|
|
|
|
// add by lsz 2020-12-26
|
|
|
|
[cUser getMsgUnreadCount:@"message" Success:^(id responseObject) {
|
|
|
|
NSLog(@"==========================");
|
|
|
|
NSLog(@"===%@", responseObject);
|
|
|
|
if([responseObject[@"count"] intValue] > 0) {
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"HAVE_NEW_MESSAGE" object:nil];
|
|
|
|
NSLog(@"=========count > 0==========");
|
|
|
|
}
|
|
|
|
NSLog(@"==========================");
|
|
|
|
} failure:^{
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
NSLog(@"===========Home viewDidLoad=================");
|
|
|
|
|
|
|
|
|
|
|
|
// 添加设备 后通知
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:@"device_add"
|
|
|
|
object:nil
|
|
|
|
queue:[NSOperationQueue mainQueue]
|
|
|
|
usingBlock:^(NSNotification * _Nonnull note)
|
|
|
|
{
|
|
|
|
NSLog(@"===添加设备成功通知===");
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
if (cUser.myDevices && cUser.myDevices.count ==0) {
|
|
|
|
[weakSelf viewWillAppear:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:@"UPDATADEVICE"
|
|
|
|
object:nil
|
|
|
|
queue:[NSOperationQueue mainQueue]
|
|
|
|
usingBlock:^(NSNotification * _Nonnull note)
|
|
|
|
{
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
[weakSelf viewWillAppear:YES];
|
|
|
|
});
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)dealloc{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self]; //移除所有通知
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
上传版本号
|
|
|
|
*/
|
|
|
|
-(void)upDataVersion
|
|
|
|
{
|
|
|
|
if([User currentUser]){
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSString *dayRecord = (NSString*)[defaults objectForKey:FirstEveryDayKey];
|
|
|
|
NSDateFormatter *formatter = [NSDateFormatter new];
|
|
|
|
[formatter setDateFormat:@"yyyy-MM-dd"];
|
|
|
|
NSDate *nowDate = [NSDate date];
|
|
|
|
NSString *nowDay = [formatter stringFromDate:nowDate];
|
|
|
|
if(dayRecord){
|
|
|
|
if([dayRecord isEqualToString:nowDay]){
|
|
|
|
return;
|
|
|
|
}else{
|
|
|
|
[defaults setObject:nowDay forKey:FirstEveryDayKey];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
[defaults setObject:nowDay forKey:FirstEveryDayKey];
|
|
|
|
}
|
|
|
|
//MARK: 每天的第一天获取广告配置
|
|
|
|
[cUser getADConfig];
|
|
|
|
|
|
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
|
|
if([ZKUDID value]){
|
|
|
|
[params setValue:[ZKUDID value] forKey:@"uuid"];
|
|
|
|
}
|
|
|
|
//当前版本号
|
|
|
|
NSString *version = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
|
|
|
|
[params setValue:version forKey:@"version"];
|
|
|
|
[params setValue:TargetName forKey:@"channel"];
|
|
|
|
|
|
|
|
[xMyHttp URL:HTTP_VERSION method:@"POST" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
|
//判断当前版本是否是最新版本, !! 提示更新 !!
|
|
|
|
NSDictionary *dic = (NSDictionary*)responseObject;
|
|
|
|
NSString * newVersion = dic[@"ios_version"];
|
|
|
|
NSString * toAppStoreURL = dic[@"ios_url"];
|
|
|
|
NSString * content = dic[@"content"];
|
|
|
|
if(!(newVersion && toAppStoreURL && content)){
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
toAppStoreURL = [toAppStoreURL stringByReplacingOccurrencesOfString:@"https:" withString:@"itms-apps:"];
|
|
|
|
|
|
|
|
//去掉其他,只保留数字
|
|
|
|
NSString *tempNewVersion = [[newVersion componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet]] componentsJoinedByString:@""];
|
|
|
|
//当前版本号
|
|
|
|
NSString *version = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
|
|
|
|
version = [[version componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet]] componentsJoinedByString:@""];
|
|
|
|
// 判断是否是强制更新
|
|
|
|
NSInteger isforceUpdate = [dic[@"forceUpdate"] integerValue];
|
|
|
|
xLog(@"是否是强制更新 :%ld" ,(long)isforceUpdate);
|
|
|
|
if (isforceUpdate == 1){
|
|
|
|
// 强制更新需要去除 每日标记
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
[defaults removeObjectForKey:FirstEveryDayKey];
|
|
|
|
}
|
|
|
|
if(tempNewVersion.integerValue > version.integerValue){
|
|
|
|
|
|
|
|
//MARK : 显示内容 测试
|
|
|
|
WCUpVersionView * view = [[WCUpVersionView alloc] initWithNewUpversionAlertViewWithSetVersion:newVersion Content:content];
|
|
|
|
view.isforceUpdate = @(isforceUpdate).boolValue;
|
|
|
|
//更新跳转
|
|
|
|
view.upVersionBlock = ^{
|
|
|
|
// IOS11 以下的
|
|
|
|
if([[[UIDevice currentDevice] systemVersion] doubleValue] < 11.0){
|
|
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:toAppStoreURL]];
|
|
|
|
}else{
|
|
|
|
// iOS 11 以上
|
|
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:toAppStoreURL] options:@{} completionHandler:^(BOOL success) {
|
|
|
|
xLog(@"success: %d",success);
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// itms-apps://itunes.apple.com/cn/app/id1268542657?mt=8
|
|
|
|
xLog(@"版本更新打印的信息 %@",responseObject);
|
|
|
|
} failure:^(NSURLSessionDataTask *task, NSError *error) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle
|
|
|
|
{
|
|
|
|
return UIStatusBarStyleLightContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
self.currentPage = 0;
|
|
|
|
NSLog(@"======HomeVC viewWillAppear==========");
|
|
|
|
|
|
|
|
WEAKSELF
|
|
|
|
//刷新 关联数据
|
|
|
|
if(!cUser){
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin"
|
|
|
|
object:nil];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 查找默认imei add by lsz 2020-12-28
|
|
|
|
Device *defaultDev = nil;
|
|
|
|
NSString *defaultImei = [User getDefaultImei];
|
|
|
|
if (defaultImei && cUser.myDevices)
|
|
|
|
{
|
|
|
|
//for (Device *dev in cUser.myDevices)
|
|
|
|
for (NSInteger i = 0; i < cUser.myDevices.count; i++)
|
|
|
|
{
|
|
|
|
Device *dev = cUser.myDevices[i];
|
|
|
|
if ([defaultImei isEqualToString:dev.imei])
|
|
|
|
{
|
|
|
|
self.currentPage = i;
|
|
|
|
defaultDev = dev;
|
|
|
|
[self.headerView scrollViewDidScrolls:i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//[self.headerView scrollViewDidScrolls:self.currentPage];
|
|
|
|
|
|
|
|
if (defaultDev)
|
|
|
|
{
|
|
|
|
cUser.cDevice = defaultDev;
|
|
|
|
self.watchHomeTable.hidden = NO;
|
|
|
|
if (self.headerView)
|
|
|
|
self.headerView.watchArr = cUser.myDevices;
|
|
|
|
self.watchHomeTable.tableHeaderView.height = cUser.myDevices.count > 1 ? 228 : 215;
|
|
|
|
[weakSelf reloadDisSelectDevicesArr];
|
|
|
|
NSLog(@"===default:%@",defaultImei);
|
|
|
|
}
|
|
|
|
else if (![cUser.myDevices containsObject:cUser.cDevice] && cUser.myDevices.count > 0)
|
|
|
|
{
|
|
|
|
cUser.cDevice = [cUser.myDevices firstObject];
|
|
|
|
}
|
|
|
|
self.noView.hidden = cUser.myDevices.count > 0 ? YES : NO;
|
|
|
|
[cUser getRelatedDeviceSuccess:^(id responseObject) {
|
|
|
|
[cUser getUserInfoSuccess:^(id responseObject) {
|
|
|
|
self.noView.hidden = cUser.myDevices.count > 0 ? YES : NO;
|
|
|
|
if (self.headerView)
|
|
|
|
self.headerView.watchArr = cUser.myDevices;
|
|
|
|
self.watchHomeTable.tableHeaderView.height = cUser.myDevices.count > 1 ? 228 : 215;
|
|
|
|
[weakSelf reloadDisSelectDevicesArr];
|
|
|
|
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];
|
|
|
|
} else {
|
|
|
|
xLog(@"====================>佰锐视频账号已经登录");
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
xLog(@"====>鹈鹕视频账号已经登录");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//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);
|
|
|
|
[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];
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK 切换到同意的绑定设备 ===================================== add by lsz 2021-6-22
|
|
|
|
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.disSelectDevicesArr = [[NSMutableArray alloc] initWithArray:cUser.myDevices];
|
|
|
|
|
|
|
|
[self switchDeviceWithDevice:mainDevice];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self switchDeviceWithDevice:nil];
|
|
|
|
xLog(@"cUser.myDevices.count : %zd", cUser.myDevices.count);
|
|
|
|
}
|
|
|
|
self.headerView.watchArr = cUser.myDevices;
|
|
|
|
|
|
|
|
//清除预加载的图片
|
|
|
|
MyTabBarViewController *mytabVC = (MyTabBarViewController*)self.tabBarController;
|
|
|
|
[mytabVC removeTransitionImageView];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)mapViewtapPressed{
|
|
|
|
//跳转到定位页面
|
|
|
|
[self performSegueWithIdentifier:@"goMapVC" sender:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)tapActionWithMainDeviceImageView:(UITapGestureRecognizer *)sender{
|
|
|
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
|
|
|
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"EditDeviceViewController"];
|
|
|
|
[vc setValue:@(NO) forKey:@"isAdd"];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
添加或切换设备
|
|
|
|
*/
|
|
|
|
- (void)rightBarItemClick
|
|
|
|
{
|
|
|
|
//跳转 添加设备 指令
|
|
|
|
//是微信用户的,判断是否有 手机号了,没有需要添加后才能添加设备
|
|
|
|
if(cUser.wxid && (cUser.phone == nil || cUser.phone.length == 0))
|
|
|
|
{
|
|
|
|
CommonPopView *popView = [CommonPopView new];
|
|
|
|
[popView bangdinPhone];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LoginStoryboard" bundle:nil];
|
|
|
|
UINavigationController *vc = [sb instantiateViewControllerWithIdentifier:@"ScanCodeViewController"];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//MARK: 切换设备
|
|
|
|
/**
|
|
|
|
切换设备
|
|
|
|
@param mainDevice 设备信息
|
|
|
|
*/
|
|
|
|
-(void)switchDeviceWithDevice:(Device*) mainDevice{
|
|
|
|
cUser.cDevice = mainDevice;
|
|
|
|
//MARK: add by lsz 2020-12-28 记录当前设备imei
|
|
|
|
[User saveDefaultImei:mainDevice.imei];
|
|
|
|
|
|
|
|
[self loadMenuData];
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
// [self setMainDevWithMainDevCell:cUser.cDevice];
|
|
|
|
});
|
|
|
|
|
|
|
|
xLog(@"-------switchDeviceWithDevice-----------");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (CommonTableView *)watchHomeTable
|
|
|
|
{
|
|
|
|
if (!_watchHomeTable)
|
|
|
|
{
|
|
|
|
_watchHomeTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:55 cellRow:0 isAdaptive:NO isLine:YES commonCell:WatchHomeMenuTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
|
|
|
|
|
|
|
|
WatchHomeMenuTableViewCell *cell = (WatchHomeMenuTableViewCell *)cells;
|
|
|
|
[UICommon tableView:self->_watchHomeTable willDisplayCell:cell forRowAtIndexPath:indexPath cellCoutn:self.cellImageArr.count sizeH:16];
|
|
|
|
if (indexPath.row == self.cellImageArr.count-1)
|
|
|
|
[UICommon setExtraCellLineHidden:cell];
|
|
|
|
cell.titleStr = self.cellTitleArr[indexPath.row];
|
|
|
|
cell.imageStr = self.cellImageArr[indexPath.row];
|
|
|
|
if ([self.cellTitleArr[indexPath.row] isEqualToString:@"定时开关机"])
|
|
|
|
cell.swithStr = self.model.switchStatus.boolValue ? @"已开启" : @"已关闭";
|
|
|
|
|
|
|
|
|
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
|
|
|
|
WatchHomeMenuTableViewCell * cell = (WatchHomeMenuTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];//即为要得到的cell
|
|
|
|
NSLog(@"%@",cell.titleLabel.text);
|
|
|
|
[self pusView:cell.titleLabel.text];
|
|
|
|
|
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
_watchHomeTable.tableHeaderView = self.headerView;
|
|
|
|
_watchHomeTable.tableHeaderView.height = cUser.myDevices.count > 1 ? 228 : 215;
|
|
|
|
_watchHomeTable.backgroundColor = KKClearColor;
|
|
|
|
[UICommon setTavleViewlink:_watchHomeTable distance:30];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return _watchHomeTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (WatchHomeHeaderView *)headerView
|
|
|
|
{
|
|
|
|
if (!_headerView)
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
_headerView = [[WatchHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 228)];
|
|
|
|
self.headerView.scrollViewTouch = ^(NSInteger index) {
|
|
|
|
weakSelf.currentPage = index;
|
|
|
|
Device *device = cUser.myDevices[index];
|
|
|
|
[weakSelf switchDeviceWithDevice:device];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return _headerView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)loadMenuData
|
|
|
|
{
|
|
|
|
// self.headTitleArr = [[NSMutableArray alloc] init];
|
|
|
|
// self.headImageArr = [[NSMutableArray alloc] init];
|
|
|
|
self.cellTitleArr = [[NSMutableArray alloc] init];
|
|
|
|
self.cellImageArr = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
NSLog(@"%@",cUser.cDevice);
|
|
|
|
if (!cUser.cDevice)
|
|
|
|
{
|
|
|
|
|
|
|
|
self.watchHomeTable.cellRow = 0;
|
|
|
|
[self.watchHomeTable reloadData];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if (cUser.cDevice.support_whiteList && cUser.cDevice.support_whiteList.intValue !=0)
|
|
|
|
// [self.headTitleArr addObject:@"管理员"];
|
|
|
|
// else
|
|
|
|
// [self.headTitleArr addObject:@"电话本"];
|
|
|
|
// [self.headImageArr addObject:@"icon_phonebook"];
|
|
|
|
|
|
|
|
|
|
|
|
// [self.headTitleArr addObject:@"手表短信"];
|
|
|
|
// [self.headImageArr addObject:@"icon_phonemessage"];
|
|
|
|
//
|
|
|
|
// if(cUser.cDevice.support_step && cUser.cDevice.support_step.intValue == 1){
|
|
|
|
// [self.headTitleArr addObject:@"计步"];
|
|
|
|
// [self.headImageArr addObject:@"icon_Pedometer"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (cUser.cDevice.support_disturb && cUser.cDevice.support_disturb.intValue == 1) {
|
|
|
|
// [self.headTitleArr addObject:@"上课禁用"];
|
|
|
|
// [self.headImageArr addObject:@"icon_disabled"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//if(cUser.cDevice.opRejectStrangeCall && cUser.cDevice.opRejectStrangeCall.intValue == 1)
|
|
|
|
{
|
|
|
|
[self.cellTitleArr addObject:@"拒接陌生人来电"];
|
|
|
|
[self.cellImageArr addObject:@"icon_more_HaveSome"];
|
|
|
|
}
|
|
|
|
// if(cUser.cDevice.support_photo && cUser.cDevice.support_photo.intValue == 1){
|
|
|
|
// [self.cellTitleArr addObject:@"远程拍照"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_photography"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(cUser.cDevice.support_monitor && cUser.cDevice.support_monitor.intValue == 1) {
|
|
|
|
// [self.cellTitleArr addObject:@"监听设备"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_monitor"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_alarm && cUser.cDevice.support_alarm.intValue == 1) {
|
|
|
|
[self.cellTitleArr addObject:@"设备闹钟"];
|
|
|
|
[self.cellImageArr addObject:@"icon_alarm"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_sos && cUser.cDevice.support_sos.intValue == 1) {
|
|
|
|
[self.cellTitleArr addObject:@"SOS号码"];
|
|
|
|
[self.cellImageArr addObject:@"icon_sosnumber"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(cUser.cDevice.support_wifi && cUser.cDevice.support_wifi.intValue == 1){
|
|
|
|
// [self.cellTitleArr addObject:@"设备WIFI"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_wifi"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if(cUser.cDevice.support_find && cUser.cDevice.support_find.intValue == 1){
|
|
|
|
[self.cellTitleArr addObject:@"查找设备"];
|
|
|
|
[self.cellImageArr addObject:@"icon_looking_for_equipment"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// 学生卡
|
|
|
|
// if(cUser.cDevice.deviceType && cUser.cDevice.deviceType.intValue == 2) {
|
|
|
|
// [self.cellTitleArr addObject:@"亲情号"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_phonebook"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // 学生资料
|
|
|
|
// if(cUser.cDevice.deviceType && cUser.cDevice.deviceType.intValue == 2) {
|
|
|
|
// [self.cellTitleArr addObject:@"学生资料"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_more_watch_data"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (cUser.cDevice.support_whiteList && cUser.cDevice.support_whiteList.intValue != 0) {
|
|
|
|
// [self.cellTitleArr addObject:@"通讯录"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_phonebook"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (cUser.cDevice.support_callPhone && cUser.cDevice.support_callPhone.intValue == 1)
|
|
|
|
{
|
|
|
|
[self.cellTitleArr addObject:@"手表拨号"];
|
|
|
|
[self.cellImageArr addObject:@"icon_off"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(cUser.cDevice.support_family && cUser.cDevice.support_family.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [self.cellTitleArr addObject:@"亲情号"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_new_contact_book"];
|
|
|
|
// }
|
|
|
|
// if(cUser.cDevice.support_healthCode && cUser.cDevice.support_healthCode.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [self.cellTitleArr addObject:@"分享图片"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_ttcode_qrcode"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(cUser.cDevice.support_hht && cUser.cDevice.support_hht.intValue == 1)
|
|
|
|
// {
|
|
|
|
// [self.cellTitleArr addObject:@"VIP客服"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_ttcode_VIP"];
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// [self.cellTitleArr addObject:@"设备资料"];
|
|
|
|
// [self.cellImageArr addObject:@"icon_more_watch_data"];
|
|
|
|
if(cUser.cDevice.support_timingSwitch && cUser.cDevice.support_timingSwitch.intValue == 1){
|
|
|
|
[self.cellTitleArr addObject:@"定时开关机"];
|
|
|
|
[self.cellImageArr addObject:@"icon_more_Switchingmachine"];
|
|
|
|
[self GetSwitchData];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self.cellTitleArr addObject:@"远程关机"];
|
|
|
|
[self.cellImageArr addObject:@"icon_more_Shutdown"];
|
|
|
|
|
|
|
|
[self.cellTitleArr addObject:@"解绑手表"];
|
|
|
|
[self.cellImageArr addObject:@"icon_more_unbind"];
|
|
|
|
|
|
|
|
// self.headerView.watchArr = cUser.myDevices;
|
|
|
|
//[self.headerView addMenuBtn:self.headTitleArr ImageArr:self.headImageArr];
|
|
|
|
self.watchHomeTable.cellRow = self.cellTitleArr.count;
|
|
|
|
[self.watchHomeTable reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)pusView:(NSString *)title
|
|
|
|
{
|
|
|
|
if([title isEqualToString:@"电话本"] || [title isEqualToString:@"管理员"])
|
|
|
|
{
|
|
|
|
[UICommon PusXibViewController:[ContactsViewController new] :@"ContactsViewController"];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"监听设备"])
|
|
|
|
{
|
|
|
|
[UICommon PusXibViewController:[MonitorViewController new] :@"MonitorViewController"];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"设备闹钟"])
|
|
|
|
{
|
|
|
|
[UICommon PusXibViewController:[VoiceAlarmViewController new] :@"VoiceAlarmViewController"];
|
|
|
|
}
|
|
|
|
if([title isEqualToString:@"拒接陌生人来电"])
|
|
|
|
{
|
|
|
|
RejectStrangeCallViewController *vc = [[RejectStrangeCallViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"上课禁用"])
|
|
|
|
{
|
|
|
|
// [UICommon PusXibViewController:[DisturbBanViewController new] :@"DisturbBanViewController"];
|
|
|
|
DisturbBanViewController *vc = [[DisturbBanViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"SOS号码"])
|
|
|
|
{
|
|
|
|
[UICommon PusXibViewController:[SOSViewController new] :@"SOSViewController"];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"设备资料"])
|
|
|
|
{
|
|
|
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
|
|
|
EditDeviceViewController *vc = [sb instantiateViewControllerWithIdentifier:@"EditDeviceViewController"];
|
|
|
|
[vc setValue:@(NO) forKey:@"isAdd"];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"远程拍照"])
|
|
|
|
{
|
|
|
|
[UICommon PusXibViewController:[RemoteCameraViewController new] :@"RemoteCameraViewController"];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"计步"])
|
|
|
|
{
|
|
|
|
// [[self getViewController] performSegueWithIdentifier:@"goStepVC" sender:nil];
|
|
|
|
NewStepVC * vc = [NewStepVC new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
// else if([title isEqualToString:@"视频通话"])
|
|
|
|
// {
|
|
|
|
// UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
|
|
|
|
// UIViewController *vc =[sb instantiateViewControllerWithIdentifier:@"VideoCallViewController"];
|
|
|
|
// [self.navigationController pushViewController:vc animated:YES];
|
|
|
|
// }
|
|
|
|
else if([title isEqualToString:@"设备WIFI"])
|
|
|
|
{
|
|
|
|
WiFiViewController * vc = [WiFiViewController new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"爱心奖励"])
|
|
|
|
{
|
|
|
|
RedFlowerSetVC *vc = [RedFlowerSetVC new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"话费流量"])
|
|
|
|
{
|
|
|
|
[self performSegueWithIdentifier:@"goQueryCall" sender:nil];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"查找设备"])
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
CommonPopView *popview = [CommonPopView new];
|
|
|
|
[popview subPopView:popViewType_czsb PopTitle:@"查找设备" PopText:@"点击查找设备,设备接收到指令,会响铃60 秒,按任意键可以取消。若设备处于关机或未联网状态,则无法向设备端发送相关指令。" okTouchBlock:^{
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opFind":@(1)}
|
|
|
|
success:^(id responseObject) {
|
|
|
|
[UICommon MessageSuccessText:@"查找设备成功,等待响铃" isImg:YES];
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
xLog(@"查找设备失败");
|
|
|
|
[UICommon MessageErrorText:faiObject[@"msg"]];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"定时开关机"])
|
|
|
|
{
|
|
|
|
TimingSwitchVC *vc = [TimingSwitchVC new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}else if([title isEqualToString:@"亲情号"])
|
|
|
|
{
|
|
|
|
FamilyViewController *vc = [[FamilyViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}else if([title isEqualToString:@"通讯录"])
|
|
|
|
{
|
|
|
|
WhiteContactViewController *vc = [[WhiteContactViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}else if([title isEqualToString:@"学生资料"])
|
|
|
|
{
|
|
|
|
StudentInfoViewController *vc = [[StudentInfoViewController alloc] init];
|
|
|
|
[vc setValue:@(NO) forKey:@"isAdd"];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}else if([title isEqualToString:@"课程表"])
|
|
|
|
{
|
|
|
|
CourseViewController *vc = [[CourseViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"亲情号"])
|
|
|
|
{
|
|
|
|
FamilyViewController *vc = [[FamilyViewController alloc] init];
|
|
|
|
vc.view.backgroundColor = KKBackgroundGrey;
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"分享图片"])
|
|
|
|
{
|
|
|
|
jjcdViewController *vc = [jjcdViewController new];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"设备防丢"])
|
|
|
|
{
|
|
|
|
DeviceLoseViewController *vc = [[DeviceLoseViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"VIP客服"])
|
|
|
|
{
|
|
|
|
VIPViewController *vc = [[VIPViewController alloc] init];
|
|
|
|
//vc.view.backgroundColor = UIColor.whiteColor;
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"表盘中心"])
|
|
|
|
{
|
|
|
|
WatchDialViewController *vc = [[WatchDialViewController alloc] init];
|
|
|
|
//vc.view.backgroundColor = UIColor.whiteColor;
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"手表拨号"])
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
NSInteger opCall = cUser.cDevice.opDialSwitch.boolValue ? 0 : 1;
|
|
|
|
NSString *tmp = cUser.cDevice.opDialSwitch.boolValue ? @"关闭" : @"开启";
|
|
|
|
CommonPopView *popview = [CommonPopView new];
|
|
|
|
[popview subPopView:popViewType_ycgj PopTitle:@"手表拨号" PopText:[NSString stringWithFormat:@"设备将%@手表拨号,是否确认",tmp] okTouchBlock:^{
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opCallPhone":@(opCall)}
|
|
|
|
success:^(id responseObject) {
|
|
|
|
cUser.cDevice.opDialSwitch = @(opCall);
|
|
|
|
[weakSelf.watchHomeTable reloadData];
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"远程关机"])
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
CommonPopView *popview = [CommonPopView new];
|
|
|
|
[popview subPopView:popViewType_ycgj PopTitle:@"远程关机" PopText:@"设备将会远程关机,是否确认" okTouchBlock:^{
|
|
|
|
[weakSelf performOperationWithName:title];
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ([title isEqualToString:@"解绑手表"])
|
|
|
|
{
|
|
|
|
NSString *msg = @"解除绑定后,将无法对设备进行监护,设备将重启,其他绑定该设备的用户,将自动解绑";
|
|
|
|
if([cUser.cDevice.identity isEqualToString:@"admin"]){
|
|
|
|
msg = @"您是设备的管理员,如果您进行解绑,其他绑定该设备的用户,将自动解绑,确认解除绑定吗?";
|
|
|
|
}
|
|
|
|
//如果是 imei号登陆
|
|
|
|
int type = [myHelper getNowAccoutType:cUser];
|
|
|
|
if(type == 3)
|
|
|
|
msg = @"\n解除绑定后,设备将被恢复出厂设置,确认解除绑定吗?";
|
|
|
|
|
|
|
|
CommonPopView *popview = [CommonPopView new];
|
|
|
|
[popview subPopView:popViewType_jbsb PopTitle:@"解绑设备" PopText:msg okTouchBlock:^{
|
|
|
|
NSMutableDictionary * parameters = [NSMutableDictionary dictionary];
|
|
|
|
[parameters setObject:cUser.cDevice.imei forKey:@"imei"];
|
|
|
|
[cUser deleteDeviceSuccess:^(id responseObject) {
|
|
|
|
int type = [myHelper getNowAccoutType:cUser];
|
|
|
|
[self reloadDisSelectDevicesArr];
|
|
|
|
if(type == 3)
|
|
|
|
{
|
|
|
|
//如果是 imei 号 直接 退出登录
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin" object:nil];
|
|
|
|
}else{
|
|
|
|
//回到首页
|
|
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performOperationWithName:(NSString *)title
|
|
|
|
{
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
if ([title isEqualToString:@"远程关机"])
|
|
|
|
[parameters setObject:@(YES) forKey:@"opPowerOff"];
|
|
|
|
[cUser.cDevice editOperationDeviceInfoWithParameters:parameters success:^(id responseObject) {
|
|
|
|
if ([title isEqualToString:@"远程关机"]){
|
|
|
|
[UICommon MessageSuccessText:@"远程关机成功" isImg:YES];
|
|
|
|
}
|
|
|
|
} failure:^(id faiObject) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark 获取定时开关机开关状态
|
|
|
|
/// 获取定时开关机开关状态
|
|
|
|
- (void)GetSwitchData
|
|
|
|
{
|
|
|
|
WEAKSELF
|
|
|
|
[TimingSwitchModel getTimingSwitchDataSuccess:^(TimingSwitchModel * _Nonnull model) {
|
|
|
|
weakSelf.model = model;
|
|
|
|
[self.watchHomeTable reloadData];
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|