CheckMessage_VC.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. //
  2. // CheckMessage_VC.m
  3. // Haishenghai-master
  4. //
  5. // Created by 刘云鸽 on 2019/4/10.
  6. // Copyright © 2019 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "CheckMessage_VC.h"
  9. #import "MessageTableCell.h"
  10. #import "Header.h"
  11. @interface CheckMessage_VC ()<UITableViewDataSource,UITableViewDelegate>
  12. {
  13. NSString *messageID;
  14. NSString *location;
  15. NSString *siteName;
  16. NSString *D_location;
  17. NSString *deviceType;
  18. NSString *recheckTime;
  19. NSString *recheckId;
  20. NSString *ID;
  21. }
  22. @property(nonatomic,strong)NSMutableArray *dataArray;
  23. @end
  24. @implementation CheckMessage_VC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // //接收回调来的条件筛选值
  28. // Do any additional setup after loading the view.
  29. self.view.backgroundColor = [UIColor whiteColor];
  30. self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
  31. [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  32. self.navigationItem.title =@"消息";
  33. [self setupUI];
  34. [DataSourceManager gettroubledeviceWithUrlPagesize:100 Page:1 formTime:@"" toTime:@"" completionBlock:^(NSMutableArray *array) {
  35. _dataArray =array;
  36. [_tableView reloadData];
  37. }];
  38. //集成下拉刷新控件
  39. [self setupDownRefresh];
  40. }
  41. -(void)refreshData{
  42. //集成下拉刷新控件
  43. [self.tableView.mj_header beginRefreshing];
  44. }
  45. /**
  46. * 集成下拉刷新控件
  47. */
  48. - (void)setupDownRefresh
  49. {
  50. // 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadNewData方法)
  51. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewDatas)];
  52. //马上进入刷新状态
  53. [self.tableView.mj_header beginRefreshing];
  54. }
  55. -(void)loadNewDatas{
  56. self.dataArray = [NSMutableArray array];
  57. //请求数据
  58. [DataSourceManager gettroubledeviceWithUrlPagesize:100 Page:1 formTime:@"" toTime:@"" completionBlock:^(NSMutableArray *array) {
  59. _dataArray =array;
  60. [_tableView reloadData];
  61. //结束刷新
  62. [self.tableView.mj_header endRefreshing];
  63. }];
  64. }
  65. // 如果不想让其他页面的导航栏变为透明 需要重置
  66. - (void)viewWillDisappear:(BOOL)animated{
  67. [super viewWillAppear:animated];
  68. }
  69. -(void)setupUI{
  70. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  71. rightButton.frame = CGRectMake(0, 0, 44, 44);
  72. [rightButton setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
  73. [rightButton addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
  74. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
  75. self.navigationItem.leftBarButtonItem = rightItem;
  76. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
  77. // _tableView.backgroundColor = [UIColor grayColor];
  78. _tableView.delegate = self;
  79. _tableView.dataSource = self;
  80. _tableView.userInteractionEnabled = YES;
  81. _tableView.showsHorizontalScrollIndicator=NO;
  82. [self.view addSubview:_tableView];
  83. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  84. }
  85. #pragma mark-- tableviewDelegate
  86. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  87. return _dataArray.count;
  88. }
  89. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  90. return 159;
  91. }
  92. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  93. static NSString *cellId = @"cell";
  94. MessageTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  95. if (!cell) {
  96. cell = [[MessageTableCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
  97. }
  98. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  99. cell.layer.cornerRadius = 18;
  100. UIView *line = [[UIView alloc]init];
  101. line.frame = CGRectMake(0, 150, WIDTH, 9);
  102. line.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  103. [cell.contentView addSubview:line];
  104. troubleDeveceModel *model = [self.dataArray objectAtIndex:indexPath.row];
  105. // messageID = model.messageId;
  106. // location =model.location;
  107. // D_location = model.deviceLoation;
  108. // siteName = model.deployment;
  109. // deviceType = model.deviceName;
  110. // ID = model.ID;
  111. cell.nameLabel.text = model.deviceName;
  112. cell.numberLabel.text = model.deveceID;
  113. cell.locationLabel.text = model.deviceLoation;
  114. cell.detailLocationLabel.text = model.location;
  115. cell.detailLocationLabel.numberOfLines =0;
  116. cell.detailLocationLabel.lineBreakMode = NSLineBreakByWordWrapping;
  117. cell.placeLabel.text = model.deployment;
  118. //iOS开发服务器返回的时间戳变成时间
  119. // NSString *timeStampString = [NSString stringWithFormat:@"%@",model.gmtCreate];
  120. // // iOS 生成的时间戳是10位
  121. // NSTimeInterval interval =[timeStampString doubleValue] / 1000.0;
  122. // NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
  123. //
  124. // NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  125. // [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  126. // NSString *dateString = [formatter stringFromDate: date];
  127. cell.timelabel.text = model.gmtCreate;
  128. if ([model.troubleType isEqualToString:@"1"]) {
  129. cell.image.image = [UIImage imageNamed:@"hsh_home_alert"];
  130. cell.stateLabel.text = @"火警";
  131. cell.stateLabel.textColor = [UIColor redColor];
  132. }else if ([model.troubleType isEqualToString:@"0"]){
  133. cell.stateLabel.text = @"设备故障";
  134. cell.stateLabel.textColor = [UIColor orangeColor];
  135. cell.image.image = [UIImage imageNamed:@"hsh_home_fault"];
  136. }else{
  137. cell.stateLabel.textColor = [UIColor blueColor];
  138. cell.stateLabel.text = @"火警恢复正常";
  139. cell.image.image = [UIImage imageNamed:@"hsh_home_normal"];
  140. }
  141. NSString *checkId = model.recheckId;
  142. if (checkId.length>4) {
  143. //hsh_news_audited
  144. [cell.checkButton setBackgroundImage:[UIImage imageNamed:@"hsh_news_audited"] forState:UIControlStateNormal];
  145. }else{
  146. [cell.checkButton setBackgroundImage:[UIImage imageNamed:@"hsh_news_unaudited"] forState:UIControlStateNormal];
  147. }
  148. cell.checkButton.tag = indexPath.row;
  149. [cell.checkButton addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
  150. return cell;
  151. }
  152. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  153. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  154. }
  155. #pragma mark----Event
  156. -(void)searchClick{
  157. [self.navigationController popViewControllerAnimated:YES];
  158. }
  159. -(void)checkButton:(UIButton*)btn{
  160. troubleDeveceModel *model = _dataArray[btn.tag];
  161. Recorddetail_VC *record = [[Recorddetail_VC alloc]init];
  162. record.msgID = model.messageId;
  163. record.loaction = model.location;
  164. record.D_loaction = model.deviceLoation;
  165. record.siteName = model.deployment;
  166. record.deviceType =model.deviceName;
  167. record.recheckTime = model.recheckTime;
  168. record.recheckId = model.recheckId;
  169. record.ID = model.ID;
  170. record.navigationItem.title = @"记录详情";
  171. record.hidesBottomBarWhenPushed = YES;
  172. [self.navigationController pushViewController:record animated:YES];
  173. }- (void)didReceiveMemoryWarning {
  174. [super didReceiveMemoryWarning];
  175. // Dispose of any resources that can be recreated.
  176. }
  177. /*
  178. #pragma mark - Navigation
  179. // In a storyboard-based application, you will often want to do a little preparation before navigation
  180. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  181. // Get the new view controller using [segue destinationViewController].
  182. // Pass the selected object to the new view controller.
  183. }
  184. */
  185. @end