AllCoachCell.m 5.4 KB

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