123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // commentVC.m
- // jiaPeiC
- //
- // Created by apple on 16/3/21.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "commentVC.h"
- #import "CommentCell.h"
- @interface commentVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- 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;
- }
- -(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
|