// // YOUPAILCOnlineCell.m // LiveChat // // Created by 张灿 on 2018/9/11. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCOnlineCell.h" #import "YOUPAILZLevelView.h" #import "YOUPAIHRAgeSexView.h" @interface YOUPAILCOnlineCell() @property(nonatomic,strong)UIImageView* youpaipavatarImgV; @property(nonatomic,strong)UILabel* youpaipnickLab; @property (nonatomic,strong)UIImageView *youpaipsexImgV; @property (nonatomic,strong)UIImageView *youpaipvipV; @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView; @property (nonatomic, weak) YOUPAIHRAgeSexView *youpaipsexView; //@property(nonatomic,strong)UILabel* tagLabel;//标签 //@property(nonatomic,strong)UILabel* ageLab; @property(nonatomic,strong)UILabel* youpaipcityLab; //@property(nonatomic,strong)UILabel* timeLab; @property(nonatomic,strong)UILabel* youpaipsignL; @property(nonatomic,strong)UIButton* youpaifollowBtn; @end @implementation YOUPAILCOnlineCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ self.youpaipavatarImgV = [[UIImageView alloc]init]; self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill; self.youpaipavatarImgV.layer.masksToBounds = YES; self.youpaipavatarImgV.layer.cornerRadius = 51/2; [self.contentView addSubview:self.youpaipavatarImgV]; [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.centerY.equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(51.0f, 51.0f)); }]; UILabel* nickLab = [[UILabel alloc]init]; nickLab.textColor = LZ273145Color; nickLab.font = LCBoldFont(14); [self.contentView addSubview:nickLab]; self.youpaipnickLab = nickLab; [nickLab makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.right).offset(@10); make.top.mas_equalTo(self.youpaipavatarImgV).offset(5); }]; YOUPAIHRAgeSexView *sexView = [YOUPAIHRAgeSexView new]; self.youpaipsexView = sexView; [self.contentView addSubview:sexView]; [sexView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nickLab); make.top.equalTo(nickLab.mas_bottom).offset(2); make.size.mas_equalTo(CGSizeMake(30, 14)); }]; UIImageView *vipV = [[UIImageView alloc] init]; [self.contentView addSubview:vipV]; self.youpaipvipV = vipV; [vipV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(sexView.mas_right).offset(3.0f); make.centerY.equalTo(sexView); }]; YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init]; [self.contentView addSubview:levelView]; self.youpaiplevelView = levelView; [levelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(vipV.mas_right).offset(3.0f); make.centerY.equalTo(sexView); }]; // UILabel* tagLabel = [[UILabel alloc]init]; // tagLabel.textColor = HexColorFromRGB(0xA7A9FD); // // tagLabel.textAlignment = NSTextAlignmentCenter; // tagLabel.backgroundColor = HexColorFromRGB(0xF7F7FF); // tagLabel.layer.cornerRadius = 10; // tagLabel.layer.masksToBounds = YES; // tagLabel.font = LCFont(10); // [self addSubview:tagLabel]; // self.tagLabel = tagLabel; // [self.tagLabel makeConstraints:^(MASConstraintMaker *make) { // make.right.equalTo(self.right).offset(@-12); // make.top.equalTo(@27); // make.height.equalTo(@20); // }]; //关注 UIButton *youpaifollowBtn = [UIButton new]; self.youpaifollowBtn = youpaifollowBtn; [self.contentView addSubview:youpaifollowBtn]; [youpaifollowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(60, 29)); }]; [youpaifollowBtn addTarget:self action:@selector(youpaifollowBtnCliock:) forControlEvents:UIControlEventTouchUpInside]; [youpaifollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; youpaifollowBtn.layer.cornerRadius = 14.5; youpaifollowBtn.layer.masksToBounds = YES; youpaifollowBtn.titleLabel.font = [UIFont systemFontOfSize:13]; UILabel* signL = [[UILabel alloc]init]; signL.font = LCFont12; signL.textColor = HexColorFromRGB(0x9F9DA5); [self.contentView addSubview:signL]; self.youpaipsignL = signL; [signL makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nickLab); make.top.equalTo(sexView.bottom).offset(@2); make.height.equalTo(@15); make.width.mas_equalTo(ScaleSize(230)); }]; signL.lineBreakMode = NSLineBreakByTruncatingTail; //分割线 // UIView *lineView = [UIView new]; // [self.contentView addSubview:lineView]; // [lineView mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.mas_equalTo(14); // make.right.mas_equalTo(-14); // make.bottom.mas_equalTo(0); // make.height.mas_equalTo(0.5); // }]; // lineView.backgroundColor = HexColorFromRGB(0x28262D); } -(void)youpaifollowBtnCliock:(UIButton*)sender{ sender.selected = !sender.selected; [LCCommonHttp followUserId:self.youpaiponlineModel.youpaipuserid]; } - (void)setYoupaiponlineModel:(YOUPAILCOnlineModel *)onlineModel{ _youpaiponlineModel = onlineModel; [self.youpaipsexView youpaifreloadWith:onlineModel.youpaipgender Age:onlineModel.youpaipage]; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:onlineModel.youpaipavatar]]; self.youpaipnickLab.text = onlineModel.youpaipnickname; self.youpaipcityLab.text = onlineModel.youpaipcity; self.youpaifollowBtn.selected = onlineModel.is_follow==1?YES:NO; [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal]; [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZD3D1D7Color,LZD3D1D7Color] ByGradientType:1] forState:UIControlStateSelected]; [self.youpaifollowBtn setTitle:@"已关注" forState:UIControlStateSelected]; [self.youpaifollowBtn setTitle:@"关注" forState:UIControlStateNormal]; // if (onlineModel.is_follow ==1) { // // [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZD3D1D7Color,LZD3D1D7Color] ByGradientType:1] forState:UIControlStateSelected]; // [self.youpaifollowBtn setTitle:@"已关注" forState:UIControlStateSelected]; // // }else{ // [self.youpaifollowBtn setTitle:@"关注" forState:UIControlStateNormal]; // [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal]; // } self.youpaipvipV.hidden = YES; if (onlineModel.youpaipvip_icon.length != 0) { self.youpaipvipV.hidden = NO; [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:onlineModel.youpaipvip_icon]]; [self.youpaipvipV mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipsexView.mas_right).offset(5.0f); make.centerY.equalTo(self.youpaipsexView); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; } [self.youpaiplevelView youpaifreloadWithIcon:onlineModel.youpaipgrade.youpaipimg1 iconWidth:onlineModel.youpaipgrade.youpaipicon_width bgImg:onlineModel.youpaipgrade.youpaipimg2 bgImgWidth:onlineModel.youpaipgrade.youpaipicon1_width levelName:onlineModel.youpaipgrade.youpaipgrade_name level:onlineModel.youpaipgrade.youpaipgrade]; [self.youpaiplevelView mas_updateConstraints:^(MASConstraintMaker *make) { make.size.mas_offset(self.youpaiplevelView.mj_size); }]; self.youpaipsignL.text = [NSString stringWithFormat:@"ID:%@",onlineModel.youpaipusercode.length == 0 ? @" " : onlineModel.youpaipusercode]; } @end