AllCoachCell.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // AllCoachCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/8/18.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "AllCoachCell.h"
  9. #import "CoachOrderCommentVC.h"
  10. #import "CDPStarEvaluation.h"
  11. #import "UIImageView+WebCache.h"
  12. @interface AllCoachCell()
  13. {
  14. //NSMutableArray *starArray;
  15. UIImageView *VImg;
  16. CDPStarEvaluation *starImageView;//星形评价
  17. }
  18. @end
  19. @implementation AllCoachCell
  20. - (void)awakeFromNib {
  21. [super awakeFromNib];
  22. // Initialization code
  23. }
  24. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  25. [super setSelected:selected animated:animated];
  26. // Configure the view for the selected state
  27. }
  28. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  29. {
  30. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  31. if (self) {
  32. self.backgroundColor = KBackGroundColor;
  33. CGFloat wid = kSize.width;
  34. CGFloat x,y,w,h;
  35. x = 10;
  36. y = 10;
  37. w = 80;
  38. h = 90;
  39. _headImg = [[UIImageView alloc] KSetxywh];
  40. [_headImg borderColor:kLineColor width:2 cornorRadios:5];
  41. [self.contentView addSubview:_headImg];
  42. x += w + 10;
  43. w = wid - x - 10;
  44. h = 30;
  45. UILabel *label;
  46. NSMutableArray *labelArray = [NSMutableArray array];
  47. for (int i = 0; i < 3; i ++) {
  48. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + i*h, w, h)];
  49. [self.contentView addSubview:label];
  50. [labelArray addObject:label];
  51. }
  52. _nameLabel = labelArray[0];
  53. _nameLabel.width -= 40;
  54. _carTypeLabel = [[UILabel alloc] initWithFrame:_nameLabel.frame];
  55. [self.contentView addSubview:_carTypeLabel];
  56. _scoreLabel = labelArray[1];
  57. _countLabel = labelArray[2];
  58. VImg = [[UIImageView alloc] initWithFrame:CGRectMake(kSize.width - 40, _nameLabel.y + 5, 20, 20)];
  59. //VImg.backgroundColor = [UIColor redColor];
  60. [self.contentView addSubview:VImg];
  61. //星级
  62. y += h + 7;
  63. h = 16;
  64. w = h*4.98;
  65. starImageView = [[CDPStarEvaluation alloc] initWithFrame:CGRectMake(x, y, w, h) onTheView:self.contentView];
  66. NSString *titString = @"0条学员点评";
  67. w = [titString sizeForFont:Font16].width + 3;
  68. x = wid - w - 10;
  69. y = _countLabel.y;
  70. h = 30;
  71. _commentBtn = [[UIButton alloc] KSetxywh];
  72. [_commentBtn setTitle:@"" textColor:[UIColor colorWithRed:54/255.0 green:123/255.0 blue:193/255.0 alpha:1] font:Font16 fotState:UIControlStateNormal];
  73. [_commentBtn target:self];
  74. [self.contentView addSubview:_commentBtn];
  75. y += h/2.0 + [titString sizeForFont:Font16].height/2.0 + 1;
  76. [_commentBtn addViewWithRect:CGRectMake(x, y, w, 1.5) Color:[UIColor colorWithRed:54/255.0 green:123/255.0 blue:193/255.0 alpha:1]];
  77. }
  78. return self;
  79. }
  80. -(void)setDataDic:(NSDictionary *)dataDic
  81. {
  82. _dataDic = dataDic;
  83. NSString *headString = dataDic[@"PHOTO"];
  84. if (!headString) {
  85. headString = dataDic[@"HEADIMG"];
  86. }
  87. if (!headString) {
  88. headString = @"";
  89. }
  90. _headImg.contentMode = UIViewContentModeScaleAspectFit;
  91. [_headImg sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"NOIMG"]];
  92. if ([dataDic[@"VIP"] integerValue] == 0) {
  93. VImg.image = [UIImage imageNamed:@"vipIcon.png"];
  94. }else{
  95. VImg.image = [UIImage imageNamed:@"school_name_icon.png"];
  96. }
  97. //星级
  98. [starImageView setStarWithFloat:[dataDic[@"STAR"] floatValue]/5.0];
  99. NSString *driveAge = [NSString stringWithFormat:@"%@",dataDic[@"DRIVEAGE"]];
  100. if (!driveAge || driveAge.length < 1 || [driveAge isEqualToString:@"0"]) {
  101. driveAge = @"1";
  102. }
  103. [_nameLabel setText:dataDic[@"NAME"] Font:Font17 TextColor:KContentTextColor Alignment:NSTextAlignmentLeft];
  104. NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ 驾龄%@年",dataDic[@"NAME"],driveAge]];
  105. [abs beginEditing];//FontTitle titleColor
  106. //字体大小
  107. [abs addAttribute:NSFontAttributeName
  108. value:[UIFont scaleSize:20.0]
  109. range:NSMakeRange(0, [dataDic[@"NAME"] length])];
  110. //字体颜色
  111. [abs addAttribute:NSForegroundColorAttributeName
  112. value:KTitleColor
  113. range:NSMakeRange(0, [dataDic[@"NAME"] length])];
  114. _nameLabel.attributedText = abs;
  115. [_carTypeLabel setText:[NSString stringWithFormat:@"%@ %@",[dataDic[@"SEX"] integerValue] == 1?@"男":@"女",dataDic[@"CARTYPE"]] Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentRight];
  116. [_scoreLabel setText:[NSString stringWithFormat:@"综合评分:%@分",dataDic[@"SCORE"]] Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentRight];
  117. [_countLabel setText:[NSString stringWithFormat:@"交易成功:%@笔",dataDic[@"ORDERNUM"]] Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
  118. [_commentBtn setTitle:[NSString stringWithFormat:@"%@条学员评价",dataDic[@"COUNT"]] forState:UIControlStateNormal];
  119. }
  120. -(void)btnClick:(UIButton *)sender
  121. {
  122. //跳转到评论页面
  123. CoachOrderCommentVC *vc = [[CoachOrderCommentVC alloc] init];
  124. vc.coachID = _dataDic[@"CI_OUT_ID"];
  125. [_superVC navPushHideTabbarToVC:vc];
  126. }
  127. @end