// // WillDoVC.m // LNManager // // Created by EchoShacolee on 2017/4/6. // Copyright © 2017年 lee. All rights reserved. // #import "WillDoVC.h" #import "WillDoCell.h" #import "WD_DetailVC.h" #import "XueShiCheckList.h" #import "RegionsList.h" @interface WillDoVC () { UITableView *_tableView; NSMutableArray *_dataArray; NSArray *_titleArray; NSArray *_shortTitleArray; NSArray *_imagesArray; } @end @implementation WillDoVC - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"消息"; self.view.backgroundColor = [UIColor whiteColor]; //@"管理员给你安排了7门必修课程,请及时登录平台进行学习",@"2012年2月14日 17:39" _titleArray = @[@"系统升级公告",@"学时审核",@"电子围栏审核",@"驾校审核通知",@"教练审核通知",@"教练车审核通知",@"终端审核通知",@"学员转校审核通知",@"管理部门下发通知"]; _shortTitleArray = @[@"公告",@"学时",@"围栏",@"驾校",@"教练",@"车辆",@"终端",@"转校",@"通知"]; _imagesArray = @[@"system_notify",@"study_check",@"teach_area",@"school_check",@"coach_check",@"car_check",@"terminal_check",@"student_check",@"notify"]; _dataArray = [NSMutableArray new]; [self myInit]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self getData]; } -(void)myInit{ _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height - kTabBarHeight) style:UITableViewStylePlain]; _tableView.rowHeight = 70.0f; _tableView.delegate = self; _tableView.dataSource = self; _tableView.backgroundColor = RGB_COLOR(242, 243, 241); _tableView.showsVerticalScrollIndicator = NO; [self.view addSubview:_tableView]; [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"]; UIView *view = [UIView new]; _tableView.tableFooterView = view; } #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.imageName = _imagesArray[indexPath.row]; cell.titleLabel.text = _titleArray[indexPath.row]; 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 integerValue] > 999 ? @"999+" : str; } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 1) { XueShiCheckList * vc = [[XueShiCheckList alloc]init]; [self.navigationController pushViewController:vc animated:YES]; return; }else if (indexPath.row == 2){ RegionsList * vc = [[RegionsList alloc]init]; vc.type = @"1"; [self.navigationController pushViewController:vc animated:YES]; return; } WD_DetailVC * vc = [[WD_DetailVC alloc]init]; vc.navigationItem.title = _titleArray[indexPath.row]; vc.type = [NSString stringWithFormat:@"%ld",(long)indexPath.row]; [self.navigationController pushViewController:vc animated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark 网络请求 -(void)getData{ NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init]; [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"]; [NetworkManager requestWithMethod:@"getMsgStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { if (failureStr) { return; } if ([successDic[@"code"] isEqualToString:@"1"]) { return; } [_dataArray removeAllObjects]; NSArray * keys = @[@"SYSTEMNOTICENUM",@"TIMEAUDITNUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"STUDENTCHANGESCHOOLAUDITNUM",@"NOTICENUM"]; NSDictionary * dic = successDic[@"body"][0]; for (int i=0; i