123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // 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 "RegionsList.h"
- @interface WillDoVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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];
-
- //@"学时审核",,@"学时" ,@"study_check"
- _titleArray = @[@"系统升级公告",@"教学区域审核",@"驾校审核通知",@"教练审核通知",@"教练车审核通知",@"终端审核通知",@"管理部门下发通知"];
- _shortTitleArray = @[@"公告",@"围栏",@"驾校",@"教练",@"车辆",@"终端",@"转校",@"通知"];
- _imagesArray = @[@"system_notify",@"teach_area",@"school_check",@"coach_check",@"car_check",@"terminal_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){
-
- [Tools permissionValidationWithID:@"804" result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- [self showMsgByMBWithString:failureStr];
- }
- return;
- }
- 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 +1];
- NSArray *arr = @[@"2",@"3",@"4",@"5",@"6"];
- if ([arr containsObject:vc.type]) {
- NSInteger theId = [vc.type integerValue]+802;
- [Tools permissionValidationWithID:[NSString stringWithFormat:@"%ld",theId] result:^(BOOL isCan, NSString *failureStr) {
- if (!isCan) {
- if (failureStr) {
- [self showMsgByMBWithString:failureStr];
- }
- return;
- }else{
- [self.navigationController pushViewController:vc animated:YES];
- }
- }];
- }else{
- [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];
- //,@"TIMEAUDITNUM"
- NSArray * keys = @[@"SYSTEMNOTICENUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"NOTICENUM"];
- NSDictionary * dic = successDic[@"body"][0];
- int count = 0;
- for (int i=0; i<keys.count; i++) {
- [_dataArray addObject:dic[keys[i]]];
- count += [[_dataArray lastObject] intValue];
- }
- UITabBarController *tabC = (UITabBarController *)self.parentViewController.parentViewController;
- if (count == 0) {
- [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:nil];
- }else{
- [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:[NSString stringWithFormat:@"%d", count]];
- }
- [_tableView reloadData];
- }];
-
- }
- @end
|