// // WaringVC.m // LN_School // // Created by EchoShacolee on 2017/8/11. // Copyright © 2017年 Danson. All rights reserved. // #import "WaringVC.h" #import "WillDoCell.h" #import "MengBanView.h" #import "WaringDetailList.h" @interface WaringVC () { NSArray *_titleArray; NSMutableArray *_dataArray; UITableView *_tableView; MengBanView *_mengBanView; //条件参数 NSString *_status; NSString *_start; NSString *_end; UIButton *_cancleWaring;//解除警报 } @end /* ydqj 遇到抢劫 jtsg 交通事故 clgz 车辆故障 chaosu 超速报警 gnssOpen 卫星定位 gnssCut 天线状态 powerOff 电源断电 overStop 超市停车 overBound 围栏越界 collision 碰撞报警 rollover 侧翻报警 openDoor 非法开门报警 */ @implementation WaringVC - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"报警信息"; self.navigationController.navigationBar.translucent = NO; [self customRightBtn]; // [self createBottomBarWithtoolTitles:@[@"解除报警"]]; if (_isNotification == NO) { //正常状态 [self goBackByNavigation]; } else { //推送状态 要将根视图变回去 UIBarButtonItem* backBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNavgation)]; [backBtn setTintColor:RQMianColor]; [self.navigationItem setLeftBarButtonItem:backBtn]; } _status = @"1"; _start = @""; _end = @""; _titleArray = @[@"遇到抢劫",@"交通事故",@"车辆故障",@"超速报警",@"卫星定位",@"天线状态",@"电源断电",@"超市停车",@"围栏越界",@"碰撞报警",@"侧翻报警",@"非法开门报警"]; _dataArray = [NSMutableArray new]; [self myInit]; } -(void)dismissNavgation { [myDelegate initHomeVC]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self getMacWarning]; } -(void)myInit{ _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height - kNavOffSet - kSafeAreaBottomHeight) style:UITableViewStylePlain]; _tableView.backgroundColor = KBackGroundColor; _tableView.showsVerticalScrollIndicator = NO; _tableView.rowHeight = 50.0f; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [UIView new]; [self.view addSubview:_tableView]; [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"]; UIView *view = [UIView new]; _tableView.tableFooterView = view; } -(void)customRightBtn{ UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)]; item.tintColor = RQMianColor; self.navigationItem.rightBarButtonItem = item; } -(void)setMengbanView{ if (_mengBanView) { [_mengBanView showView]; return; } NSArray * btnarr = @[@"未解除",@"已解除"]; NSString *start = @"开始时间"; NSString *end = @"结束时间"; NSArray * buttonsArray = @[@[@"1",btnarr],@[@"2",start],@[@"2",end]]; _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) { //确认解除报警 0 已解除 1 未解除(默认查未解除) if ([array[0] isEqualToString:@"已解除"]) { _status = @"0"; }else if ([array[0] isEqualToString:@"未解除"]){ _status = @"1"; } if (![array[1] isEqualToString:@"开始时间"]) { _start = array[1]; } if (![array[2] isEqualToString:@"结束时间"]) { _end = array[2]; } [self getMacWarning]; }]; [_mengBanView showView]; } #pragma mark tableview代理方法 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _titleArray.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ WillDoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WillDoCellId" forIndexPath:indexPath]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.titleLabel.text = _titleArray[indexPath.row]; CGFloat colorR = 200.0/_titleArray.count*indexPath.row; CGFloat colorG = 200.0/_titleArray.count*(_titleArray.count-indexPath.row); CGFloat colorB = 200.0/_titleArray.count*indexPath.row; cell.smallView.backgroundColor = RGB_COLOR(colorR, colorG, colorB); if (_dataArray.count == _titleArray.count) { NSString * str = [NSString stringWithFormat:@"%@",_dataArray[indexPath.row]]; if ([str floatValue] == 0) { cell.markNumLabel.hidden = YES; }else{ cell.markNumLabel.hidden = NO; cell.markNumLabel.text = str; if([str integerValue] > 999){ cell.markNumLabel.text = @"999+"; } } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { WaringDetailList * vc = [[WaringDetailList alloc] init]; vc.navigationItem.title = _titleArray[indexPath.row]; vc.startDate = _start; vc.endDate = _end; vc.status = _status; vc.type =[NSString stringWithFormat:@"%ld",(long)indexPath.row+1]; [self navPushHideTabbarToVC:vc]; } #pragma mark 创建BottomBarButton //-(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{ // // float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count; // float HeightBth = 50; // // for (int i=0; i