CommentScoreView.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // CommentScoreView.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/21.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "CommentScoreView.h"
  9. @implementation CommentScoreView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self)
  14. {
  15. CGFloat db = 20;
  16. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(db, db, 120, 30)];
  17. label.text = @"平均分";
  18. label.font = [UIFont scaleSize:14];
  19. label.backgroundColor = backGroundColor;
  20. label.textAlignment = NSTextAlignmentCenter;
  21. label.layer.borderWidth = .5;
  22. label.layer.borderColor = KlineColor.CGColor;
  23. [self addSubview:label];
  24. _scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(db, db+30, 120, 40)];
  25. _scoreLabel.text = @"4";
  26. _scoreLabel.font = [UIFont scaleSize:30];
  27. _scoreLabel.textColor = [UIColor colorWithRed:255/255.0 green:67/255.0 blue:1/255.0 alpha:1];
  28. _scoreLabel.textAlignment = NSTextAlignmentCenter;
  29. _scoreLabel.layer.borderWidth = .5;
  30. _scoreLabel.layer.borderColor = KlineColor.CGColor;
  31. [self addSubview:_scoreLabel];
  32. _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(db, db + 70, 120, 20)];
  33. _countLabel.text = [NSString stringWithFormat:@"%d人评价",arc4random()%15 + 3];
  34. _countLabel.font = [UIFont scaleSize:14];
  35. _countLabel.textAlignment = NSTextAlignmentCenter;
  36. _countLabel.layer.borderWidth = .5;
  37. _countLabel.layer.borderColor = KlineColor.CGColor;
  38. [self addSubview:_countLabel];
  39. NSArray *titles = @[@"服务",@"场地",@"收费"];
  40. NSMutableArray *stars = [[NSMutableArray alloc] init];
  41. for (int i = 0; i < 3; i ++)
  42. {
  43. UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(160 * kSize.width/320, db+30*i, 40, 30)];
  44. label1.text = titles[i];
  45. label1.textAlignment = NSTextAlignmentCenter;
  46. label1.font = [UIFont scaleSize:14];
  47. label1.textColor = contentTextColor;
  48. [self addSubview:label1];
  49. if (i == 1)
  50. {
  51. _starLabel = label1;
  52. }
  53. RatingBar *starBar = [[RatingBar alloc] initWithFrame:CGRectMake(200 *kSize.width /320, db+30*i, 100, 30) Flag:NO];
  54. starBar.enable = NO;
  55. starBar.starNumber = arc4random()%3 + 3;
  56. [self addSubview:starBar];
  57. [stars addObject:starBar];
  58. }
  59. self.star1 = stars[0];
  60. self.star2 = stars[1];
  61. self.star3 = stars[2];
  62. }
  63. return self;
  64. }
  65. -(void)setSfbh:(NSString *)sfbh
  66. {
  67. _sfbh = sfbh;
  68. [self getSchOrCoachEvaluate];
  69. }
  70. -(void)getSchOrCoachEvaluate
  71. {
  72. if (![Util connectedToNetWork]) {
  73. showMsgUnconnect();
  74. return;
  75. }
  76. NSMutableArray* arr = [NSMutableArray array];
  77. [arr addPro:@"bpjz" Value:_sfbh];
  78. [arr addPro:@"type" Value:_type];
  79. NSString* method = @"getSchOrCoachEvaluate";
  80. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  81. //NSLog(@"综合信息-->%@-->%@",arr,root);
  82. if (!root) {
  83. ShowMsgFailed();
  84. return;
  85. }
  86. if ([root[@"code"] isEqualToString:@"1"]) {
  87. ShowMsg(root[@"body"]);
  88. return;
  89. }
  90. NSDictionary *dic = root[@"body"];
  91. if ([dic isKindOfClass:[NSDictionary class]]) {
  92. if (dic[@"star"] && [dic[@"star"] length] > 0) {
  93. _scoreLabel.text = dic[@"star"];
  94. }
  95. if (dic[@"count"] && [dic[@"count"] length] > 0) {
  96. _countLabel.text = dic[@"count"];
  97. }
  98. if (dic[@"serviceStar"] && [dic[@"serviceStar"] length] > 0) {
  99. _star1.starNumber = [dic[@"serviceStar"] integerValue];
  100. }
  101. if (dic[@"siteStar"] && [dic[@"siteStar"] length] > 0) {
  102. _star2.starNumber = [dic[@"siteStar"] integerValue];
  103. }
  104. if (dic[@"tollStar"] && [dic[@"tollStar"] length] > 0) {
  105. _star3.starNumber = [dic[@"tollStar"] integerValue];
  106. }
  107. }
  108. }];
  109. }
  110. @end