// // commentVC.m // jiaPeiC // // Created by apple on 16/3/21. // Copyright © 2016年 JCZ. All rights reserved. // #import "commentVC.h" #import "CommentCell.h" @interface commentVC () { NSInteger currentPage; HolderView *holderV; UITableView *mainTableView; NSMutableArray *models; } @end @implementation commentVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"学员点评"; [self configNavBar]; [self myInit]; } -(void)viewWillDisappear:(BOOL)animated { //所有有请求的页面都要加 [super viewWillDisappear:animated]; RemoveHUD(); } -(void)myInit { models = [NSMutableArray array]; mainTableView = [[UITableView alloc] initWithFrame:kFrame]; mainTableView.backgroundColor = backGroundColor; mainTableView.delegate = self; mainTableView.dataSource = self; [self.view addSubview:mainTableView]; holderV = [[HolderView alloc] initWithFrame:kFrame]; [holderV freshBlock:^{ [self getSchOrCoachEvaluates]; }]; [self addV:holderV]; [holderV setHidden:YES]; currentPage = 1; [self getSchOrCoachEvaluates]; } #pragma mark 数据请求 - (void)getSchOrCoachEvaluates { [LoadingView showHUD]; if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *arr = [NSMutableArray array]; [arr addPro:@"bpjr" Value:defUser.userDict[@"ciIdentifyNum"]]; [arr addPro:@"type" Value:@"2"]; [arr addPro:@"user" Value:defUser.userDict[@"id"]]; [arr addPro:@"isPage" Value:@"1"]; [arr addPro:@"pageSize" Value:@"10"]; [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)currentPage]]; NSString* method = @"getSchOrCoachEvaluates"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) { RemoveHUD(); //NSLog(@"评论列表---->%@----->%@",arr,root); [holderV setHidden:NO]; if (!root) { return; } if ([root[@"code"] isEqualToString:@"1"]) { ShowMsg(root[@"body"]); return; } if ([root[@"body"] count] == 0) { ShowMsg(@"已加载全部数据"); } NSArray *array = root[@"body"]; if (array && array.count > 0) { currentPage ++; [models addObjectsFromArray:root[@"body"]]; } if (models.count > 0) { [holderV setHidden:YES]; [mainTableView reloadData]; } }]; } #pragma mark tableview delegate -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return models.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CommentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[CommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; } NSDictionary *dic = models[indexPath.row]; [cell setDict:dic]; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *dic = models[indexPath.row]; CGFloat wid = kSize.width - 90; CGFloat height = [dic[@"PJCONTENT"] heightForWid:wid Font:Font14]; if (height < 30.0) { height = 30; } return 90 + height; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ return [UIView new]; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return .1; } - (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