WillDoVC.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // WillDoVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "WillDoVC.h"
  9. #import "WillDoCell.h"
  10. #import "WD_DetailVC.h"
  11. #import "XueShiCheckList.h"
  12. #import "RegionsList.h"
  13. @interface WillDoVC ()<UITableViewDelegate,UITableViewDataSource>
  14. {
  15. UITableView *_tableView;
  16. NSMutableArray *_dataArray;
  17. NSArray *_titleArray;
  18. NSArray *_shortTitleArray;
  19. NSArray *_imagesArray;
  20. }
  21. @end
  22. @implementation WillDoVC
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.navigationItem.title = @"消息";
  26. self.view.backgroundColor = [UIColor whiteColor];
  27. //@"管理员给你安排了7门必修课程,请及时登录平台进行学习",@"2012年2月14日 17:39"
  28. _titleArray = @[@"系统升级公告",@"学时审核",@"电子围栏审核",@"驾校审核通知",@"教练审核通知",@"教练车审核通知",@"终端审核通知",@"学员转校审核通知",@"管理部门下发通知"];
  29. _shortTitleArray = @[@"公告",@"学时",@"围栏",@"驾校",@"教练",@"车辆",@"终端",@"转校",@"通知"];
  30. _imagesArray = @[@"system_notify",@"study_check",@"teach_area",@"school_check",@"coach_check",@"car_check",@"terminal_check",@"student_check",@"notify"];
  31. _dataArray = [NSMutableArray new];
  32. [self myInit];
  33. }
  34. -(void)viewWillAppear:(BOOL)animated{
  35. [super viewWillAppear:animated];
  36. [self getData];
  37. }
  38. -(void)myInit{
  39. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height - kTabBarHeight) style:UITableViewStylePlain];
  40. _tableView.rowHeight = 70.0f;
  41. _tableView.delegate = self;
  42. _tableView.dataSource = self;
  43. _tableView.backgroundColor = RGB_COLOR(242, 243, 241);
  44. _tableView.showsVerticalScrollIndicator = NO;
  45. [self.view addSubview:_tableView];
  46. [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"];
  47. UIView *view = [UIView new];
  48. _tableView.tableFooterView = view;
  49. }
  50. #pragma mark tableview代理方法
  51. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  52. return _titleArray.count;
  53. }
  54. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  55. WillDoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WillDoCellId" forIndexPath:indexPath];
  56. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  57. cell.imageName = _imagesArray[indexPath.row];
  58. cell.titleLabel.text = _titleArray[indexPath.row];
  59. if (_dataArray.count == _titleArray.count) {
  60. NSString * str = [NSString stringWithFormat:@"%@",_dataArray[indexPath.row]];
  61. if ([str floatValue] == 0) {
  62. cell.markNumLabel.hidden = YES;
  63. }else{
  64. cell.markNumLabel.hidden = NO;
  65. cell.markNumLabel.text = [str integerValue] > 999 ? @"999+" : str;
  66. }
  67. }
  68. return cell;
  69. }
  70. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  71. if (indexPath.row == 1) {
  72. XueShiCheckList * vc = [[XueShiCheckList alloc]init];
  73. [self.navigationController pushViewController:vc animated:YES];
  74. return;
  75. }else if (indexPath.row == 2){
  76. RegionsList * vc = [[RegionsList alloc]init];
  77. vc.type = @"1";
  78. [self.navigationController pushViewController:vc animated:YES];
  79. return;
  80. }
  81. WD_DetailVC * vc = [[WD_DetailVC alloc]init];
  82. vc.navigationItem.title = _titleArray[indexPath.row];
  83. vc.type = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
  84. [self.navigationController pushViewController:vc animated:YES];
  85. }
  86. - (void)didReceiveMemoryWarning {
  87. [super didReceiveMemoryWarning];
  88. // Dispose of any resources that can be recreated.
  89. }
  90. #pragma mark 网络请求
  91. -(void)getData{
  92. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  93. [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  94. [NetworkManager requestWithMethod:@"getMsgStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  95. if (failureStr) {
  96. return;
  97. }
  98. if ([successDic[@"code"] isEqualToString:@"1"]) {
  99. return;
  100. }
  101. [_dataArray removeAllObjects];
  102. NSArray * keys = @[@"SYSTEMNOTICENUM",@"TIMEAUDITNUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"STUDENTCHANGESCHOOLAUDITNUM",@"NOTICENUM"];
  103. NSDictionary * dic = successDic[@"body"][0];
  104. for (int i=0; i<keys.count; i++) {
  105. [_dataArray addObject:dic[keys[i]]];
  106. }
  107. [_tableView reloadData];
  108. }];
  109. }
  110. @end