123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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<toolTitles.count; i++) {
- //
- // UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
- // button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-knavoffset, widthBtn, HeightBth);
- // if (i == 1) {
- // [button setTitle:@"解除报警" forState:UIControlStateNormal];
- // _cancleWaring = button;
- // }else{
- // [button setTitle:toolTitles[i] forState:UIControlStateNormal];
- // }
- //
- // UIColor * color = RQMianColor;
- // button.backgroundColor = color;
- // [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- // [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- // button.tag = 100+i;
- //
- // [self.view addSubview:button];
- // }
- //}
- //
- //- (void)buttonClick:(UIButton *)sender{
- //
- // UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您确定要解除所有报警吗" preferredStyle:UIAlertControllerStyleAlert];
- //
- // [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- // [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //
- // [self removeMacWarning];
- //
- // }]];
- // [self presentViewController:alertFind animated:true completion:nil];
- //
- //}
- //
- #pragma mark 网络请求
- -(void)getMacWarning{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
- [dic setObject:_status forKey:@"status"];
- [dic setObject:_start forKey:@"startTime"];
- [dic setObject:_end forKey:@"endTime"];
-
- NSString *method = @"getMacWarning";
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowMsg(@"数据请求失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- NSLog(@"%@",root[@"msg"]);
- return;
- }
-
- [_dataArray removeAllObjects];
- NSArray * keys = @[@"YDQJ",
- @"JTSG",
- @"CLGZ",
- @"CHAOSU",
- @"GNSSOPEN",
- @"GNSSCUT",
- @"POWEROFF",
- @"OVERSTOP",
- @"OVERBOUND",
- @"COLLISION",
- @"ROLLOVER",
- @"OPENDOOR"];
- NSDictionary * dic = root[@"body"];
- for (int i=0; i<keys.count; i++) {
- [_dataArray addObject:dic[keys[i]]];
- }
-
- [_tableView reloadData];
- }];
- }
- //-(void)removeMacWarning{
- //
- // if (![NetManager connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- // [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
- // [dic setObject:@"" forKey:@"mwId"];
- // [dic setObject:@"" forKey:@"kind"];
- // [dic setObject:@"" forKey:@"sim"];
- //
- // NSString *method = @"removeMacWarning";
- // [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
- //
- // if (!root) {
- // ShowMsg(@"数据请求失败,请重试");
- // return;
- // }
- // if ([root[@"code"] integerValue] == 1) {
- // ShowMsg(root[@"msg"]);
- // return;
- // }
- //
- // ShowMsg(@"操作成功");
- //
- // [self getMacWarning];
- // }];
- //}
- - (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
|