// // DeviceDetailsPage.m // airtree // // Created by if on 2016/11/18. // Copyright © 2016年 Gloria. All rights reserved. // #import "DeviceDetailsPage.h" #import "ChangeDeviceNamePage.h" #import "DateTimePicker.h" #import "MyDeviceStatus.h" #import "CommonReqModel.h" #import "NetworkSingleton.h" @interface DeviceDetailsPage () { UITableView *_tableView; //NSTimer *timer; NSString *checkStatus; } @end @implementation DeviceDetailsPage - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.navigationItem.title = @"设备详情"; [self setNavigationLeft:@"返回" sel:@selector(backAction)]; self.view.backgroundColor = [UIColor whiteColor]; // UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)]; // view.userInteractionEnabled = YES; // UIButton *quitLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // quitLoginBtn.frame =CGRectMake(20, 50, SCREEN_WIDTH-40, 40); // [quitLoginBtn.layer setMasksToBounds:YES]; // [quitLoginBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径 // quitLoginBtn.backgroundColor = BLUE_BUTTON_COLOR; // [quitLoginBtn setTitle:@"解绑该设备" forState:UIControlStateNormal]; // [quitLoginBtn addTarget:self action:@selector(unBindDevice) forControlEvents:UIControlEventTouchUpInside]; // [view addSubview:quitLoginBtn]; _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-40) style:UITableViewStyleGrouped]; _tableView.dataSource = self; _tableView.delegate = self; //_tableView.tableFooterView = view; [self.view addSubview:_tableView]; // if([device[@"type"] integerValue] == 1) // { // [self loadDeviceInfoList]; // } // //此处调用加载数据的接口 // [self loadDeviceInfoList]; } -(void) viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; [_tableView reloadData]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:YES]; } -(void)backAction { [self dismissViewControllerAnimated:YES completion:nil]; } -(void)unBindDevice { [Global alertMessageEx:@"确定要解除绑定吗" title:@"提示信息" okTtitle:@"确认" cancelTitle:@"取消" delegate:self]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { // buttonIndex 0 取消 1 确定 switch (buttonIndex) { case 0: { } break; case 1: { NSString *path = [NSString stringWithFormat:Moral_Unbind_Url]; CommonReqModel * model = [[CommonReqModel alloc] init]; model.userID = _loginUser[@"_id"]; model.deviceID = self._id; model.name = _curDeviceName; MPWeakSelf(self); [NetworkSingleton networkingPostMethod:model.toDic urlName:path success:^(id responseBody) { BaseResModel * resModel = [Global toBaseModel:responseBody]; if(resModel.code == 0) { [Global alertMessageEx:@"解绑成功!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; [weakself dismissViewControllerAnimated:YES completion:nil]; } else { [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; } } failure:^(NSString *error) { [Global alertMessageEx:error title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; }]; } break; default: break; } } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 1; } //此处上面和下面 是设置 footerview - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 80; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)]; UIButton *quitLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; quitLoginBtn.frame =CGRectMake(20, 50, SCREEN_WIDTH-40, 40); [quitLoginBtn.layer setMasksToBounds:YES]; [quitLoginBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径 quitLoginBtn.backgroundColor = RgbColor(85, 81, 168); [quitLoginBtn setTitle:@"解绑该设备" forState:UIControlStateNormal]; [quitLoginBtn addTarget:self action:@selector(unBindDevice) forControlEvents:UIControlEventTouchUpInside]; [view addSubview:quitLoginBtn]; return view; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString * identifier = @"deviceManage"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (nil == cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; switch (indexPath.row) { case 0: { cell.textLabel.text = @"设备编号"; cell.textLabel.font = FONT16; cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE; cell.detailTextLabel.text = self._id; cell.detailTextLabel.font = FONT14; cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB; } break; case 1: { cell.textLabel.text = @"MAC地址"; cell.textLabel.font = FONT16; cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE; cell.detailTextLabel.text = self.mac; cell.detailTextLabel.font = FONT14; cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB; } break; case 2: { cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.text = @"设备名称"; cell.textLabel.font = FONT16; cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE; cell.userInteractionEnabled = YES; cell.detailTextLabel.text = _curDeviceName; cell.detailTextLabel.font = FONT14; cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB; } break; default: break; } return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; switch (indexPath.row) { case 0: { } break; case 1: { } break; case 2: { ChangeDeviceNamePage *page = [[ChangeDeviceNamePage alloc] initIsFirstPage:NO]; //page.currentPage = self.currentPage; [self.navigationController pushViewController:page animated:YES]; } break; default: break; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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