commentVC.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // commentVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/3/21.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "commentVC.h"
  9. #import "CommentCell.h"
  10. @interface commentVC ()<UITableViewDataSource,UITableViewDelegate>
  11. {
  12. NSInteger currentPage;
  13. HolderView *holderV;
  14. UITableView *mainTableView;
  15. NSMutableArray *models;
  16. }
  17. @end
  18. @implementation commentVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.title = @"学员点评";
  22. [self configNavBar];
  23. [self myInit];
  24. }
  25. -(void)viewWillDisappear:(BOOL)animated
  26. {
  27. //所有有请求的页面都要加
  28. [super viewWillDisappear:animated];
  29. RemoveHUD();
  30. }
  31. -(void)myInit
  32. {
  33. models = [NSMutableArray array];
  34. mainTableView = [[UITableView alloc] initWithFrame:kFrame];
  35. mainTableView.backgroundColor = backGroundColor;
  36. mainTableView.delegate = self;
  37. mainTableView.dataSource = self;
  38. [self.view addSubview:mainTableView];
  39. holderV = [[HolderView alloc] initWithFrame:kFrame];
  40. [holderV freshBlock:^{
  41. [self getSchOrCoachEvaluates];
  42. }];
  43. [self addV:holderV];
  44. [holderV setHidden:YES];
  45. currentPage = 1;
  46. [self getSchOrCoachEvaluates];
  47. }
  48. #pragma mark 数据请求
  49. - (void)getSchOrCoachEvaluates
  50. {
  51. [LoadingView showHUD];
  52. if (![Util connectedToNetWork]) {
  53. showMsgUnconnect();
  54. return;
  55. }
  56. NSMutableArray *arr = [NSMutableArray array];
  57. [arr addPro:@"bpjr" Value:defUser.userDict[@"ciIdentifyNum"]];
  58. [arr addPro:@"type" Value:@"2"];
  59. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  60. [arr addPro:@"isPage" Value:@"1"];
  61. [arr addPro:@"pageSize" Value:@"10"];
  62. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)currentPage]];
  63. NSString* method = @"getSchOrCoachEvaluates";
  64. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  65. RemoveHUD();
  66. //NSLog(@"评论列表---->%@----->%@",arr,root);
  67. [holderV setHidden:NO];
  68. if (!root) {
  69. return;
  70. }
  71. if ([root[@"code"] isEqualToString:@"1"]) {
  72. ShowMsg(root[@"body"]);
  73. return;
  74. }
  75. if ([root[@"body"] count] == 0) {
  76. ShowMsg(@"已加载全部数据");
  77. }
  78. NSArray *array = root[@"body"];
  79. if (array && array.count > 0) {
  80. currentPage ++;
  81. [models addObjectsFromArray:root[@"body"]];
  82. }
  83. if (models.count > 0) {
  84. [holderV setHidden:YES];
  85. [mainTableView reloadData];
  86. }
  87. }];
  88. }
  89. #pragma mark tableview delegate
  90. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  91. {
  92. return models.count;
  93. }
  94. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  95. {
  96. CommentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  97. if (cell == nil)
  98. {
  99. cell = [[CommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  100. }
  101. NSDictionary *dic = models[indexPath.row];
  102. [cell setDict:dic];
  103. return cell;
  104. }
  105. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  106. {
  107. NSDictionary *dic = models[indexPath.row];
  108. CGFloat wid = kSize.width - 90;
  109. CGFloat height = [dic[@"PJCONTENT"] heightForWid:wid Font:Font14];
  110. if (height < 30.0) {
  111. height = 30;
  112. }
  113. return 90 + height;
  114. }
  115. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  116. {
  117. return .1;
  118. }
  119. - (void)didReceiveMemoryWarning {
  120. [super didReceiveMemoryWarning];
  121. // Dispose of any resources that can be recreated.
  122. }
  123. /*
  124. #pragma mark - Navigation
  125. // In a storyboard-based application, you will often want to do a little preparation before navigation
  126. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  127. // Get the new view controller using [segue destinationViewController].
  128. // Pass the selected object to the new view controller.
  129. }
  130. */
  131. @end