// // CommentScoreView.m // jiaPei // // Created by apple on 16/1/21. // Copyright © 2016年 JCZ. All rights reserved. // #import "CommentScoreView.h" @implementation CommentScoreView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { CGFloat db = 20; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(db, db, 120, 30)]; label.text = @"平均分"; label.font = [UIFont scaleSize:14]; label.backgroundColor = backGroundColor; label.textAlignment = NSTextAlignmentCenter; label.layer.borderWidth = .5; label.layer.borderColor = KlineColor.CGColor; [self addSubview:label]; _scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(db, db+30, 120, 40)]; _scoreLabel.text = @"4"; _scoreLabel.font = [UIFont scaleSize:30]; _scoreLabel.textColor = [UIColor colorWithRed:255/255.0 green:67/255.0 blue:1/255.0 alpha:1]; _scoreLabel.textAlignment = NSTextAlignmentCenter; _scoreLabel.layer.borderWidth = .5; _scoreLabel.layer.borderColor = KlineColor.CGColor; [self addSubview:_scoreLabel]; _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(db, db + 70, 120, 20)]; _countLabel.text = [NSString stringWithFormat:@"%d人评价",arc4random()%15 + 3]; _countLabel.font = [UIFont scaleSize:14]; _countLabel.textAlignment = NSTextAlignmentCenter; _countLabel.layer.borderWidth = .5; _countLabel.layer.borderColor = KlineColor.CGColor; [self addSubview:_countLabel]; NSArray *titles = @[@"服务",@"场地",@"收费"]; NSMutableArray *stars = [[NSMutableArray alloc] init]; for (int i = 0; i < 3; i ++) { UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(160 * kSize.width/320, db+30*i, 40, 30)]; label1.text = titles[i]; label1.textAlignment = NSTextAlignmentCenter; label1.font = [UIFont scaleSize:14]; label1.textColor = contentTextColor; [self addSubview:label1]; if (i == 1) { _starLabel = label1; } RatingBar *starBar = [[RatingBar alloc] initWithFrame:CGRectMake(200 *kSize.width /320, db+30*i, 100, 30) Flag:NO]; starBar.enable = NO; starBar.starNumber = arc4random()%3 + 3; [self addSubview:starBar]; [stars addObject:starBar]; } self.star1 = stars[0]; self.star2 = stars[1]; self.star3 = stars[2]; } return self; } -(void)setSfbh:(NSString *)sfbh { _sfbh = sfbh; [self getSchOrCoachEvaluate]; } -(void)getSchOrCoachEvaluate { if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray* arr = [NSMutableArray array]; [arr addPro:@"bpjz" Value:_sfbh]; [arr addPro:@"type" Value:_type]; NSString* method = @"getSchOrCoachEvaluate"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) { //NSLog(@"综合信息-->%@-->%@",arr,root); if (!root) { ShowMsgFailed(); return; } if ([root[@"code"] isEqualToString:@"1"]) { ShowMsg(root[@"body"]); return; } NSDictionary *dic = root[@"body"]; if ([dic isKindOfClass:[NSDictionary class]]) { if (dic[@"star"] && [dic[@"star"] length] > 0) { _scoreLabel.text = dic[@"star"]; } if (dic[@"count"] && [dic[@"count"] length] > 0) { _countLabel.text = dic[@"count"]; } if (dic[@"serviceStar"] && [dic[@"serviceStar"] length] > 0) { _star1.starNumber = [dic[@"serviceStar"] integerValue]; } if (dic[@"siteStar"] && [dic[@"siteStar"] length] > 0) { _star2.starNumber = [dic[@"siteStar"] integerValue]; } if (dic[@"tollStar"] && [dic[@"tollStar"] length] > 0) { _star3.starNumber = [dic[@"tollStar"] integerValue]; } } }]; } @end