123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- //
- #import "SearchComment.h"
- #import "CommentCell.h"
- #import "CommentScoreView.h"
- @interface SearchComment ()<UITableViewDataSource,UITableViewDelegate>
- {
- //模型。
- NSArray* models;
-
- UITableView* myTableView;
-
- UILabel* lblEmpty;
-
- /**每次下载后。就判断.
- 如果cnt为0就显示。否则隐藏
- */
- UIView* placeHolder;
-
- CommentScoreView *CSView;
-
- UIButton *upBtn;
-
- NSInteger commentID;
- }
- @end
- /**整体UI搭建为。下面为tableview。上面是tableheader
- */
- @implementation SearchComment
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- [self getSchOrCoachEvaluates];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- -(void)myInit
- {
- [self configNavigationBar];
- [self.view setBackgroundColor:[UIColor whiteColor]];
- [self setTitle:@"学员点评"];
-
- CGFloat x,y,w,h;
-
- UITableView* tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet)];
- [tv setDelegate:self];
- [tv setDataSource:self];
- [self.view addSubview:tv];
-
- CSView = [[CommentScoreView alloc] initWithFrame:CGRectMake(0, kSize.width, 0, 130)];
- CSView.type = _type;
- CSView.sfbh = _bpjr;
- [CSView setBoardWid:2 Color:KlineColor];
-
- tv.tableHeaderView = CSView;
- tv.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, .1)];
-
- myTableView = tv;
-
- //placeHolder
- UIView* vi = [[UIView alloc] initWithFrame:kFrame];
- vi.y += 30;
- [self.view addSubview:vi];
- vi.hidden = YES;
- placeHolder = vi;
-
- w = h = kSize.width/3.0;
- x = y = w;
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"community4.png"]];
- [iv setContentMode:UIViewContentModeScaleAspectFit];
- [placeHolder addSubview:iv];
-
- y += h + 20;
- x = 0;
- w = kSize.width;
- h = 40;
- UILabel* label;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setText:@"暂无相关点评~"];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setTextColor:contentTextColor];
- [placeHolder addSubview:label];
- }
- -(void)btnClick:(UIButton *)sender
- {
- commentID = sender.tag;
- [self uploadSchOrCoachEvaluatePoint];
- }
- #pragma mark tableView delegate
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 150;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return models.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- CommentCell* cell = [CommentCell cellForTableView:tableView Style:CommentCellStyleSchool];
- cell.VCName = @"SearchComment";
- [cell setDict:models[indexPath.row]];
-
- upBtn = cell.upBtn;
- [upBtn target:self tag:indexPath.row];
-
- return cell;
- }
- #pragma mark 数据请求
- -(void)getSchOrCoachEvaluates
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray* arr = [NSMutableArray array];
-
- [arr addPro:@"bpjz" Value:self.bpjr];
- [arr addPro:@"type" Value:self.type];
- [arr addPro:@"outId" Value:defUser.userDict[@"outId"]];
- [arr addPro:@"isPage" Value:@"1"];
- [arr addPro:@"pageSize" Value:@"60"];
- [arr addPro:@"currentPage" Value:@"1"];
-
- // NSLog(@"评论列表参数 ---->%@",arr);
- NSString* method = @"getSchOrCoachEvaluates";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
- models = root[@"body"];
-
- if (models.count < 1) {
- placeHolder.hidden = NO;
- }else{
- placeHolder.hidden = YES;
-
- CSView.countLabel.text = [NSString stringWithFormat:@"%d人评价",(int)models.count];
- [myTableView reloadData];
- }
- }];
- }
- -(void)uploadSchOrCoachEvaluatePoint
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSDictionary *dic = models[commentID];
-
- NSMutableArray* arr = [NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"id" Value:dic[@"ID"]];
-
- NSString* method = @"uploadSchOrCoachEvaluatePoint";
- if (![dic[@"ISPOINT"] isEqualToString:@"0"]) {
- method = @"deleteSchOrCoachEvaluatePoint";
- }
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- //NSLog(@"点赞结果---->%@",root);
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- [self getSchOrCoachEvaluates];
-
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if (![dic[@"ISPOINT"] isEqualToString:@"0"]) {
- // [upBtn setTitle:[NSString stringWithFormat:@"%d",[dic[@"POINTNUM"] intValue] - 1] forState:UIControlStateNormal];
- // }else{
- // [upBtn setTitle:[NSString stringWithFormat:@"%d",[dic[@"POINTNUM"] intValue] + 1] forState:UIControlStateNormal];
- // }
- // });
- }];
- }
- @end
|