144 lines
5.0 KiB
Objective-C
Executable File
144 lines
5.0 KiB
Objective-C
Executable File
//
|
|
// FirstViewController.m
|
|
// Talk
|
|
//
|
|
// Created by xuzs on 22/10/11.
|
|
// Copyright (c) 2022年 xuzs. All rights reserved.
|
|
//
|
|
|
|
#import "EquList.h"
|
|
#import "UI.h"
|
|
#import "HttpManager.h"
|
|
#import "Msg.h"
|
|
#import "Pub.h"
|
|
#import "sysInfo.h"
|
|
//#import "EquListCell.h"
|
|
#import "Opendoor.h"
|
|
#import "EquAdd.h"
|
|
#import "EquConfig.h"
|
|
#import "FaceUpload.h"
|
|
|
|
@interface EquList ()
|
|
@property (nonatomic, strong)UIView *rview;
|
|
|
|
@end
|
|
|
|
@implementation EquList
|
|
NSMutableArray *_dataArray;
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
// [self setNavTitle:@"我的设备"];
|
|
// [self setNavRight:@"add" action:@selector(AddEqu)];
|
|
// [self setUI];
|
|
// [self setData];
|
|
}
|
|
/*
|
|
- (void)setData{
|
|
_dataArray = [[NSMutableArray alloc] initWithCapacity:0];
|
|
[_dataArray addObjectsFromArray:[Opendoor getEqulist]];
|
|
[self.tableView reloadData];
|
|
|
|
}
|
|
- (void)setUI{
|
|
|
|
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, [UI getScreenWidth], [UI getScreenHeight]-60) style:UITableViewStylePlain];
|
|
[self.tableView registerClass:[EquListCell class] forCellReuseIdentifier:@"EquListCell"];
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
|
|
NSLog(@"table:%f,%f,%f,%f",self.tableView.frame.origin.x,self.tableView.frame.origin.y,self.tableView.frame.size.width,self.tableView.frame.size.height);
|
|
|
|
|
|
}
|
|
|
|
- (void)AddEqu{
|
|
EquAdd *equadd = [[EquAdd alloc] init];
|
|
equadd.parent = self;
|
|
[self.navigationController pushViewController:equadd animated:YES];
|
|
}
|
|
|
|
#pragma mark 返回分组数
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
//NSLog(@"计算分组数");
|
|
return 1;
|
|
}
|
|
|
|
#pragma mark 返回每组行数
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
//NSLog(@"计算每组(组%li)行数",(long)section);
|
|
return _dataArray.count;
|
|
}
|
|
|
|
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
return 60;
|
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
NSLog(@"cellForRowAtIndexPath:%ld",indexPath.row);
|
|
//EquListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EquListCell" forIndexPath:indexPath];
|
|
EquListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EquListCell"];
|
|
|
|
if (cell == nil) {
|
|
cell = [[EquListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EquListCell"];
|
|
}
|
|
if(indexPath.row<_dataArray.count){
|
|
cell.titleLabel.text = [_dataArray[indexPath.row] valueForKey:@"name"];
|
|
cell.contentLabel.text = [_dataArray[indexPath.row] valueForKey:@"equid"];
|
|
}
|
|
|
|
|
|
// if (indexPath.row == self.timeListenData.count - 1) {
|
|
// [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
|
|
// }
|
|
return cell;
|
|
}
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
//NSLog(@"didSelectRowAtIndexPath:%ld",indexPath.row);
|
|
if(indexPath.row<_dataArray.count){
|
|
NSArray * options = @[@"命名设备",@"配置网关",@"人脸开门",@"删除"];
|
|
[Msg Select:self SourceView:[tableView cellForRowAtIndexPath:indexPath] Title:@"请选择" Options:options SelectedHandler:^(int index) {
|
|
if(index==0){
|
|
EquAdd *equadd = [[EquAdd alloc] init];
|
|
equadd.parent = self;
|
|
equadd.equid = [_dataArray[indexPath.row] valueForKey:@"equid"];
|
|
equadd.name = [_dataArray[indexPath.row] valueForKey:@"name"];
|
|
[self.navigationController pushViewController:equadd animated:YES];
|
|
}
|
|
else if(index==1){
|
|
|
|
EquConfig *equconfig = [[EquConfig alloc] init];
|
|
equconfig.equid = [_dataArray[indexPath.row] valueForKey:@"equid"];
|
|
[self.navigationController pushViewController:equconfig animated:YES];
|
|
}
|
|
else if(index==2){
|
|
FaceUpload *face = [[FaceUpload alloc] init];
|
|
face.equid = [_dataArray[indexPath.row] valueForKey:@"equid"];
|
|
face.index0 = 0;
|
|
[self.navigationController pushViewController:face animated:YES];
|
|
}
|
|
else if(index==3){
|
|
[HttpManager DelEqu:[Pub getApp].sysinfo.username Token:[Pub getApp].sysinfo.token Equid:[_dataArray[indexPath.row] valueForKey:@"equid"] HttpResultHandler:^(NSDictionary *json) {
|
|
if([[json objectForKey:@"result"] isEqualToString:@"ok"]){
|
|
[Opendoor refEqulist:^{
|
|
[self setData];
|
|
}];
|
|
}
|
|
}];
|
|
}
|
|
}];
|
|
}
|
|
|
|
}
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
*/
|
|
|
|
@end
|