NBZOverCarListVC.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // NBZOverCarListVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/12/14.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "NBZOverCarListVC.h"
  9. #import "CarDetail.h"
  10. @interface NBZOverCarListVC ()<UITableViewDelegate,UITableViewDataSource>
  11. {
  12. UITableView * _tableView;
  13. NSArray *_dataSurce;
  14. NSString *_method;
  15. NSString *_keyTime;
  16. HolderView * holderV;
  17. }
  18. @end
  19. @implementation NBZOverCarListVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. _dataSurce = [NSArray new];
  23. _method = @"";
  24. [self myInit];
  25. [self getData];
  26. }
  27. -(void)myInit{
  28. switch (_vcType) {
  29. case 1:
  30. {
  31. self.navigationItem.title = @"年检到期车辆";
  32. _method = @"getInspectionList";
  33. _keyTime = @"TCI_INSPECTION_NEXT_TIME";
  34. }
  35. break;
  36. case 2:
  37. {
  38. self.navigationItem.title = @"保险到期车辆";
  39. _method = @"getInsuranceList";
  40. _keyTime = @"TCI_INSURANCE_START_TIME";
  41. }
  42. break;
  43. case 3:
  44. {
  45. self.navigationItem.title = @"综合性能检测到期车辆";
  46. _method = @"getComprehensiveList";
  47. _keyTime = @"TCI_INSPECTION_NEXT_TIME";
  48. }
  49. break;
  50. default:
  51. break;
  52. }
  53. self.navigationController.navigationBar.translucent = NO;
  54. self.view.backgroundColor = KBackGroundColor;
  55. [self goBackByNavigation];
  56. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
  57. _tableView.dataSource = self;
  58. _tableView.delegate = self;
  59. _tableView.tableFooterView = [UIView new];
  60. [self.view addSubview:_tableView];
  61. holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
  62. [holderV freshBlock:^{
  63. [self getData];
  64. }];
  65. [self.view addSubview:holderV];
  66. }
  67. #pragma mark -数据请求
  68. -(void)getData{
  69. //判断网络是否连接
  70. if (![NetManager connectedToNetWork]) {
  71. showMsgUnconnect();
  72. return;
  73. }
  74. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  75. [mDic setValue:defUser.userDict[@"id"] forKey:@"userId"];
  76. [mDic setValue:@"" forKey:@"carNum"];
  77. [mDic setValue:@"" forKey:@"isPage"];
  78. [mDic setValue:@"" forKey:@"pageSize"];
  79. [mDic setValue:@"" forKey:@"currentPage"];
  80. [MBProgressHUD showLoadToView:self.view];
  81. [NetManager requestAnythingWithURL:_method dictionary:mDic dataArray:nil completion:^(NSDictionary *root) {
  82. [MBProgressHUD hideHUDForView:self.view];
  83. holderV.hidden = NO;
  84. if (!root) {
  85. ShowMsg(@"数据请求失败,请重试");
  86. return;
  87. }
  88. if ([root[@"code"] integerValue] == 1) {
  89. ShowMsg(root[@"msg"]);
  90. return;
  91. }
  92. _dataSurce = root[@"body"];
  93. if (_dataSurce.count > 0) {
  94. holderV.hidden = YES;
  95. }
  96. [_tableView reloadData];
  97. }];
  98. }
  99. #pragma mark tableview代理方法
  100. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  101. return _dataSurce.count;
  102. }
  103. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  104. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  105. if (!cell) {
  106. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  107. }
  108. NSDictionary *dic = _dataSurce[indexPath.row];
  109. NSString *str = dic[@"TCO_COACH_NAME"];
  110. if (!str) {
  111. str = @"";
  112. }
  113. cell.textLabel.text = [NSString stringWithFormat:@"%@ %@",dic[@"TCO_LICNUM"],str];
  114. cell.detailTextLabel.text = dic[_keyTime];
  115. return cell;
  116. }
  117. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  118. NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
  119. [mDic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
  120. [mDic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
  121. [mDic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
  122. [mDic setValue:_dataSurce[indexPath.row][@"TCO_LICNUM"] forKey:@"licnum"];
  123. [mDic setValue:@"" forKey:@"isPage"];
  124. [mDic setValue:@"" forKey:@"pageSize"];
  125. [mDic setValue:@"" forKey:@"currentPage"];
  126. CarDetail * vc = [[CarDetail alloc]init];
  127. vc.carNum = _dataSurce[indexPath.row][@"TCO_CARNUM"];
  128. vc.requesetDic = mDic;
  129. [self navPushHideTabbarToVC:vc];
  130. }
  131. - (void)didReceiveMemoryWarning {
  132. [super didReceiveMemoryWarning];
  133. // Dispose of any resources that can be recreated.
  134. }
  135. /*
  136. #pragma mark - Navigation
  137. // In a storyboard-based application, you will often want to do a little preparation before navigation
  138. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  139. // Get the new view controller using [segue destinationViewController].
  140. // Pass the selected object to the new view controller.
  141. }
  142. */
  143. @end