| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- //
- // CheckMessage_VC.m
- // Haishenghai-master
- //
- // Created by 刘云鸽 on 2019/4/10.
- // Copyright © 2019 Haishenghai intelligence network technology. All rights reserved.
- //
- #import "CheckMessage_VC.h"
- #import "MessageTableCell.h"
- #import "Header.h"
- @interface CheckMessage_VC ()<UITableViewDataSource,UITableViewDelegate>
- {
- NSString *messageID;
- NSString *location;
- NSString *siteName;
- NSString *D_location;
- NSString *deviceType;
- NSString *recheckTime;
- NSString *recheckId;
- NSString *ID;
- }
- @property(nonatomic,strong)NSMutableArray *dataArray;
- @end
- @implementation CheckMessage_VC
- - (void)viewDidLoad {
- [super viewDidLoad];
- // //接收回调来的条件筛选值
- // Do any additional setup after loading the view.
- self.view.backgroundColor = [UIColor whiteColor];
- 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]}];
- self.navigationItem.title =@"消息";
- [self setupUI];
- [DataSourceManager gettroubledeviceWithUrlPagesize:100 Page:1 formTime:@"" toTime:@"" completionBlock:^(NSMutableArray *array) {
-
- _dataArray =array;
- [_tableView reloadData];
- }];
-
-
- //集成下拉刷新控件
- [self setupDownRefresh];
- }
- -(void)refreshData{
- //集成下拉刷新控件
- [self.tableView.mj_header beginRefreshing];
-
- }
- /**
- * 集成下拉刷新控件
- */
- - (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 = [NSMutableArray array];
- //请求数据
-
- [DataSourceManager gettroubledeviceWithUrlPagesize:100 Page:1 formTime:@"" toTime:@"" completionBlock:^(NSMutableArray *array) {
- _dataArray =array;
- [_tableView reloadData];
- //结束刷新
- [self.tableView.mj_header endRefreshing];
- }];
- }
- // 如果不想让其他页面的导航栏变为透明 需要重置
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillAppear:animated];
- }
- -(void)setupUI{
-
- UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
- rightButton.frame = CGRectMake(0, 0, 44, 44);
- [rightButton setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
- [rightButton addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
- self.navigationItem.leftBarButtonItem = rightItem;
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
- // _tableView.backgroundColor = [UIColor grayColor];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.userInteractionEnabled = YES;
- _tableView.showsHorizontalScrollIndicator=NO;
-
- [self.view addSubview:_tableView];
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
-
- }
- #pragma mark-- tableviewDelegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _dataArray.count;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 159;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellId = @"cell";
- MessageTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (!cell) {
- cell = [[MessageTableCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
- }
-
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.layer.cornerRadius = 18;
-
- UIView *line = [[UIView alloc]init];
- line.frame = CGRectMake(0, 150, WIDTH, 9);
- line.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
- [cell.contentView addSubview:line];
-
- troubleDeveceModel *model = [self.dataArray objectAtIndex:indexPath.row];
- // messageID = model.messageId;
- // location =model.location;
- // D_location = model.deviceLoation;
- // siteName = model.deployment;
- // deviceType = model.deviceName;
- // ID = model.ID;
- cell.nameLabel.text = model.deviceName;
- cell.numberLabel.text = model.deveceID;
- cell.locationLabel.text = model.deviceLoation;
- cell.detailLocationLabel.text = model.location;
- cell.detailLocationLabel.numberOfLines =0;
- cell.detailLocationLabel.lineBreakMode = NSLineBreakByWordWrapping;
- cell.placeLabel.text = model.deployment;
- //iOS开发服务器返回的时间戳变成时间
- // NSString *timeStampString = [NSString stringWithFormat:@"%@",model.gmtCreate];
- // // iOS 生成的时间戳是10位
- // NSTimeInterval interval =[timeStampString doubleValue] / 1000.0;
- // NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
- //
- // NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- // [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- // NSString *dateString = [formatter stringFromDate: date];
- cell.timelabel.text = model.gmtCreate;
- if ([model.troubleType isEqualToString:@"1"]) {
- cell.image.image = [UIImage imageNamed:@"hsh_home_alert"];
- cell.stateLabel.text = @"火警";
- cell.stateLabel.textColor = [UIColor redColor];
- }else if ([model.troubleType isEqualToString:@"0"]){
- cell.stateLabel.text = @"设备故障";
- cell.stateLabel.textColor = [UIColor orangeColor];
- cell.image.image = [UIImage imageNamed:@"hsh_home_fault"];
-
- }else{
- cell.stateLabel.textColor = [UIColor blueColor];
- cell.stateLabel.text = @"火警恢复正常";
- cell.image.image = [UIImage imageNamed:@"hsh_home_normal"];
-
- }
- NSString *checkId = model.recheckId;
-
- if (checkId.length>4) {
- //hsh_news_audited
- [cell.checkButton setBackgroundImage:[UIImage imageNamed:@"hsh_news_audited"] forState:UIControlStateNormal];
- }else{
- [cell.checkButton setBackgroundImage:[UIImage imageNamed:@"hsh_news_unaudited"] forState:UIControlStateNormal];
-
- }
- cell.checkButton.tag = indexPath.row;
- [cell.checkButton addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
-
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:NO];
-
- }
- #pragma mark----Event
- -(void)searchClick{
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)checkButton:(UIButton*)btn{
-
- troubleDeveceModel *model = _dataArray[btn.tag];
-
- Recorddetail_VC *record = [[Recorddetail_VC alloc]init];
- record.msgID = model.messageId;
- record.loaction = model.location;
- record.D_loaction = model.deviceLoation;
- record.siteName = model.deployment;
- record.deviceType =model.deviceName;
- record.recheckTime = model.recheckTime;
- record.recheckId = model.recheckId;
- record.ID = model.ID;
- record.navigationItem.title = @"记录详情";
- record.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:record animated:YES];
-
- }- (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
|