// // AllCoachCell.m // jiaPei // // Created by apple on 16/8/18. // Copyright © 2016年 JCZ. All rights reserved. // #import "AllCoachCell.h" #import "CoachOrderCommentVC.h" #import "CDPStarEvaluation.h" @interface AllCoachCell() { //NSMutableArray *starArray; UIImageView *VImg; CDPStarEvaluation *starImageView;//星形评价 } @end @implementation AllCoachCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = backGroundColor; CGFloat wid = kSize.width; CGFloat x,y,w,h; x = 10; y = 10; w = 80; h = 90; _headImg = [[UIImageView alloc] setxywh]; [_headImg borderColor:KlineColor width:2 cornorRadios:5]; [self.contentView addSubview:_headImg]; x += w + 10; w = wid - x - 10; h = 30; UILabel *label; NSMutableArray *labelArray = [NSMutableArray array]; for (int i = 0; i < 3; i ++) { label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + i*h, w, h)]; [self.contentView addSubview:label]; [labelArray addObject:label]; } _nameLabel = labelArray[0]; _nameLabel.width -= 40; _carTypeLabel = [[UILabel alloc] initWithFrame:_nameLabel.frame]; [self.contentView addSubview:_carTypeLabel]; _scoreLabel = labelArray[1]; _countLabel = labelArray[2]; VImg = [[UIImageView alloc] initWithFrame:CGRectMake(kSize.width - 40, _nameLabel.y + 5, 20, 20)]; //VImg.backgroundColor = [UIColor redColor]; [self.contentView addSubview:VImg]; //星级 y += h + 7; h = 16; w = h*4.98; starImageView = [[CDPStarEvaluation alloc] initWithFrame:CGRectMake(x, y, w, h) onTheView:self.contentView]; NSString *titString = @"0条学员点评"; w = [titString sizeForFont:NormalFont].width + 3; x = wid - w - 10; y = _countLabel.y; h = 30; _commentBtn = [[UIButton alloc] setxywh]; [_commentBtn setTitle:@"" textColor:[UIColor colorWithRed:54/255.0 green:123/255.0 blue:193/255.0 alpha:1] font:NormalFont fotState:UIControlStateNormal]; [_commentBtn target:self]; [self.contentView addSubview:_commentBtn]; y += h/2.0 + [titString sizeForFont:NormalFont].height/2.0 + 1; [_commentBtn addViewWithRect:CGRectMake(x, y, w, 1.5) Color:[UIColor colorWithRed:54/255.0 green:123/255.0 blue:193/255.0 alpha:1]]; } return self; } -(void)setDataDic:(NSDictionary *)dataDic { _dataDic = dataDic; NSString *headString = [Tools imageStringWithPhotoString:dataDic[@"PHOTO"] HeadImgString:dataDic[@"HEADIMG"] Type:1]; _headImg.contentMode = UIViewContentModeScaleAspectFit; [_headImg sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"NOIMG"]]; if ([dataDic[@"VIP"] isEqualToString:@"0"]) { VImg.image = [UIImage imageNamed:@"vipIcon.png"]; }else{ VImg.image = [UIImage imageNamed:@"school_name_icon.png"]; } //星级 [starImageView setStarWithFloat:[dataDic[@"STAR"] floatValue]/5.0]; NSString *driveAge = dataDic[@"DRIVEAGE"]; if (!driveAge || driveAge.length < 1 || [driveAge isEqualToString:@"0"]) { driveAge = @"1"; } [_nameLabel setText:dataDic[@"NAME"] Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentLeft]; NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ 驾龄%@年",dataDic[@"NAME"],driveAge]]; [abs beginEditing];//FontTitle kTitleColor //字体大小 [abs addAttribute:NSFontAttributeName value:[UIFont scaleSize:20.0] range:NSMakeRange(0, [dataDic[@"NAME"] length])]; //字体颜色 [abs addAttribute:NSForegroundColorAttributeName value:kTitleColor range:NSMakeRange(0, [dataDic[@"NAME"] length])]; _nameLabel.attributedText = abs; [_carTypeLabel setText:[NSString stringWithFormat:@"%@ %@",[dataDic[@"SEX"] isEqualToString:@"1"]?@"男":@"女",dataDic[@"CARTYPE"]] Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentRight]; [_scoreLabel setText:[NSString stringWithFormat:@"综合评分:%@分",dataDic[@"SCORE"]] Font:NormalFont TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentRight]; [_countLabel setText:[NSString stringWithFormat:@"交易成功:%@笔",dataDic[@"ORDERNUM"]] Font:NormalFont TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft]; [_commentBtn setTitle:[NSString stringWithFormat:@"%@条学员评价",dataDic[@"COUNT"]] forState:UIControlStateNormal]; } -(void)btnClick:(UIButton *)sender { //跳转到评论页面 CoachOrderCommentVC *vc = [[CoachOrderCommentVC alloc] init]; vc.coachID = _dataDic[@"CI_OUT_ID"]; [_superVC navPushHideTabbarToVC:vc]; } @end