123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // CarList.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/4/17.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "CarList.h"
- #import "CarDetail.h"
- @interface CarList ()<UITableViewDelegate,UITableViewDataSource>
- {
- UITableView * _tableView;
- NSArray *_dataSurce;
- NSMutableDictionary * _requestDic;
-
- HolderView * holderV;
- }
- @end
- @implementation CarList
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"车辆列表";
-
- self.navigationController.navigationBar.translucent = NO;
- self.view.backgroundColor = KBackGroundColor;
- [self goBackByNavigation];
-
- _dataSurce = [NSArray new];
- [self myInit];
- [self getData];
-
- }
- -(void)myInit{
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
- _tableView.dataSource = self;
- _tableView.delegate = self;
- _tableView.tableFooterView = [UIView new];
- [self.view addSubview:_tableView];
-
- holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
- [holderV freshBlock:^{
- [self getData];
- }];
- [self.view addSubview:holderV];
- }
- -(void)getData{
-
- //判断网络是否连接
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
- [mDic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
- [mDic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
- [mDic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
- [mDic setValue:@"" forKey:@"licnum"];
- [mDic setValue:@"" forKey:@"isPage"];
- [mDic setValue:@"" forKey:@"pageSize"];
- [mDic setValue:@"" forKey:@"currentPage"];
-
- _requestDic = mDic;
- [NetManager requestAnythingWithURL:@"cars" dictionary:mDic dataArray:nil completion:^(NSDictionary *root) {
-
- holderV.hidden = NO;
-
- if (!root) {
- ShowMsg(@"数据请求失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- _dataSurce = root[@"body"];
-
- if (_dataSurce.count > 0) {
- holderV.hidden = YES;
- }
-
- [_tableView reloadData];
- }];
- }
- #pragma mark tableview代理方法
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _dataSurce.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
- if (!cell) {
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellId"];
- }
-
- NSDictionary *dic = _dataSurce[indexPath.row];
- cell.textLabel.text = [NSString stringWithFormat:@"%@ %@",dic[@"TCO_LICNUM"],dic[@"TCO_COACH_NAME"]];
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- [ _requestDic setValue:_dataSurce[indexPath.row][@"TCO_LICNUM"] forKey:@"licnum"];
-
- CarDetail * vc = [[CarDetail alloc]init];
- vc.carNum = _dataSurce[indexPath.row][@"TCO_CARNUM"];
- vc.requesetDic = _requestDic;
- [self navPushHideTabbarToVC:vc];
- }
- - (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
|