| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //
- // FireAlarm_VC.m
- // Haishenghai-master
- //
- // Created by GG on 2019/1/4.
- // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
- //
- #import "FireAlarm_VC.h"
- #import "FireAlarmCell.h"
- @interface FireAlarm_VC ()<UITableViewDelegate,UITableViewDataSource>
- {
- NSInteger selectindexpath;
- }
- @property(nonatomic,strong)NSMutableArray *dataArray;
- @end
- @implementation FireAlarm_VC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"火警通知";
- self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
- UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
- backBtn.frame = CGRectMake(0, 0, 44, 44);
- [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
- _dataArray = [NSMutableArray array];
- [self setupUI];
- [self setupDownRefresh];
- }
- -(void)backClick{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)setupDownRefresh
- {
-
- // 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadNewData方法)
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewDatas)];
- //马上进入刷新状态
- [self.tableView.mj_header beginRefreshing];
- }
- -(void)loadNewDatas{
- [self.dataArray removeAllObjects];
- //请求数据
- [DataSourceManager getFireAlarmURLWithPage:1 Pagesize:100 completionBlock:^(NSMutableArray *array) {
- _dataArray =array;
- [self.tableView reloadData];
- [self.tableView.mj_header endRefreshing];
- }];
- }
- -(void)setupRefresh{
- // self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadNewDatas)];
- // [self.tableView.mj_footer beginRefreshing];
- }
- -(void)setupUI{
- self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT) style:UITableViewStylePlain];
- // _tableView.backgroundColor = [UIColor grayColor];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.userInteractionEnabled = YES;
- _tableView.showsHorizontalScrollIndicator=NO;
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- [self.view addSubview:_tableView];
- }
- #pragma mark-- tableviewDelegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _dataArray.count;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 150;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellId = @"cell";
- FireAlarmCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (!cell) {
- cell = [[FireAlarmCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- FireNoticeModel *model = [_dataArray objectAtIndex:indexPath.row];
- cell.model =model;
- cell.nameLabel.text = model.deviceName;
- cell.deployLabel.text =model.deployment;
- if ([model.troubleType isEqualToString:@"1"]) {
- cell.typeLabel.text = @"火警";
- }
- cell.numberLabel.text = model.deviceId;
- cell.locationLabel.text = model.location;
- cell.locationLabel.numberOfLines =0;
- cell.locationLabel.lineBreakMode = NSLineBreakByWordWrapping;
- cell.timeLabel.text = model.gmtCreate;
- cell.adressLabel.text = model.deviceLocation;
- //需要自定义
- cell.sureBtn.tag = indexPath.row;
- [cell.sureBtn addTarget:self action:@selector(onBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- return cell;
- }
- -(void)onBtnClick:(UIButton *)btn{
- FireNoticeModel *model = _dataArray[btn.tag];
- NSLog(@"------%@",model.ID);
- [DataSourceManager readFireAlarmWithUrlprocessID:model.ID completionBlock:^(NSDictionary *dic) {
- NSLog(@"%ld",btn.tag);
-
- if (btn.tag) {
- [btn removeFromSuperview];
- }
- }];
-
-
-
- }
- - (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
|