// // LDChildFansCell.m // YouHuiProject // // Created by 小花 on 2018/5/19. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDChildFansCell.h" @interface LDChildFansCell() @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UIImageView *tagImage; @property (nonatomic, strong) UILabel *name; @property (nonatomic, strong) UILabel *phoneNum; @property (nonatomic, strong) UILabel *date; @property (nonatomic, strong) UILabel *rightLabel; @end @implementation LDChildFansCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); LDChildFansCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[LDChildFansCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } return cell; } - (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 initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.iconView]; [self.contentView addSubview:self.tagImage]; [self.contentView addSubview:self.name]; [self.contentView addSubview:self.phoneNum]; [self.contentView addSubview:self.date]; [self.contentView addSubview:self.sencondFansSumBtn]; [self.contentView addSubview:self.updateBtn]; [self.contentView addSubview:self.rightLabel]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.height.mas_equalTo(50); make.centerY.mas_equalTo(self.mas_centerY); }]; [self.name mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconView.mas_right).mas_offset(15); make.top.mas_equalTo(15); make.width.mas_lessThanOrEqualTo(130); }]; [self.tagImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.name.mas_right).mas_offset(10); make.centerY.mas_equalTo(self.name.mas_centerY); make.width.mas_equalTo(55); make.height.mas_equalTo(15); }]; [self.phoneNum mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-15); make.left.mas_equalTo(self.name); }]; [self.date mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.phoneNum.mas_right).mas_offset(10); make.centerY.mas_equalTo(self.phoneNum.mas_centerY); }]; [self.sencondFansSumBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(FITSIZE(-17)); make.height.equalTo(self.mas_height); make.centerY.equalTo(self.mas_centerY); make.width.mas_equalTo(100); }]; [self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15); make.centerY.mas_equalTo(self.mas_centerY); make.width.mas_equalTo(Fitsize(52)); make.height.mas_equalTo(Fitsize(17)); }]; [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.centerY.mas_equalTo(self.mas_centerY); make.width.mas_equalTo(FITSIZE(55)); make.height.mas_equalTo(FITSIZE(20)); }]; } #pragma mark -事件 -(void)sencondFansAction{ if (self.delegate && [self.delegate respondsToSelector:@selector(recommendFansByUserID:withUserName:)]) { [self.delegate recommendFansByUserID:self.model.user_id withUserName:self.model.name]; } } #pragma mark -懒加载 - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] init]; _iconView.contentMode = UIViewContentModeScaleAspectFill; _iconView.layer.masksToBounds = YES; _iconView.backgroundColor = [UIColor yhGrayColor]; [_iconView setImage:[UIImage imageNamed:@"login"]]; _iconView.layer.cornerRadius = 25; } return _iconView; } - (UIImageView *)tagImage { if (!_tagImage) { _tagImage = [[UIImageView alloc] init]; _tagImage.contentMode = UIViewContentModeScaleAspectFit; // _tagImage.image = [UIImage imageNamed:@"Svip_icon"]; } return _tagImage; } - (UILabel *)name { if (!_name) { _name = [[UILabel alloc] init]; _name.textColor = [UIColor YHColorWithHex:0x333333]; _name.font = [UIFont systemFontOfSize:14]; _name.text = @"未知用户"; } return _name; } - (UILabel *)phoneNum { if (!_phoneNum) { _phoneNum = [[UILabel alloc] init]; _phoneNum.textColor = [UIColor YHColorWithHex:0x878787]; _phoneNum.font = [UIFont systemFontOfSize:12]; _phoneNum.text = @"****"; } return _phoneNum; } - (UILabel *)date { if (!_date) { _date = [[UILabel alloc] init]; _date.textColor = [UIColor YHColorWithHex:0x878787]; _date.font = [UIFont systemFontOfSize:12]; _date.text = @"--"; } return _date; } -(UIButton *)sencondFansSumBtn{ if (!_sencondFansSumBtn) { _sencondFansSumBtn=[UIButton buttonWithType:UIButtonTypeCustom]; [_sencondFansSumBtn setTitleColor:[UIColor YHColorWithHex:0xFF4633] forState:UIControlStateNormal]; _sencondFansSumBtn.titleLabel.font=[UIFont systemFontOfSize:12]; [_sencondFansSumBtn addTarget:self action:@selector(sencondFansAction) forControlEvents:UIControlEventTouchUpInside]; } return _sencondFansSumBtn; } - (UIButton *)updateBtn { if (!_updateBtn) { _updateBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_updateBtn setImage:[UIImage imageNamed:@"update_btn"] forState:UIControlStateNormal]; [_updateBtn addTarget:self action:@selector(updateBtnAction) forControlEvents:UIControlEventTouchUpInside]; } return _updateBtn; } - (UILabel *)rightLabel { if (!_rightLabel) { _rightLabel = [[UILabel alloc] init]; _rightLabel.textColor = [UIColor homeRedColor]; _rightLabel.font = [UIFont systemFontOfSize:FITSIZE(10)]; _rightLabel.text = @"查看上级"; _rightLabel.layer.borderWidth = 1; _rightLabel.layer.borderColor = [UIColor homeRedColor].CGColor; _rightLabel.layer.cornerRadius = FITSIZE(10); _rightLabel.textAlignment = NSTextAlignmentCenter; } return _rightLabel; } //-(UIButton *)registBtn //{ // if (!_registBtn) { // _registBtn =[[UIButton alloc]init]; // [_registBtn addTarget:self action:@selector(registClickBtn) forControlEvents:UIControlEventTouchUpInside]; // _registBtn setTitle:<#(nullable NSString *)#> forState:<#(UIControlState)#> // } // return _registBtn; //} -(void)registClickBtn//邀请注册 { } - (void)updateBtnAction { if (self.updateAction) { self.updateAction(_model); } } -(void)setModel:(LDChildFansModel *)model{ _model=model; // @property(nonatomic,copy)NSString *name; //名称 // @property(nonatomic,copy)NSString *phone; // s手机号 // @property(nonatomic,copy)NSString *fansDevel; // f粉丝等级 1 一级粉丝 2二级粉丝 // @property(nonatomic,copy)NSString *fansNum; //一级粉丝邀请的人数 // @property(nonatomic,copy)NSString *first_level_vermicelli_time; //r如果粉丝等级为1 时间取这个 // @property(nonatomic,copy)NSString *second_level_vermicelli_time; //r如果粉丝等级为2 时间取这个 // @property(nonatomic,copy)NSString *level; //1 会员 2超级会员 3 运营商 self.name.text=model.name; self.phoneNum.text=model.phone; self.tagImage.hidden = NO; switch ([model.level integerValue]) { case 1: { self.tagImage.image = [UIImage imageNamed:@"Vip_icon"]; self.sencondFansSumBtn.hidden=YES; } break; case 2: self.tagImage.image = [UIImage imageNamed:@"Svip_icon"]; break; case 3: { self.tagImage.image = [UIImage imageNamed:@"operator_icon"]; } break; default: self.tagImage.hidden = YES; break; } [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"login"]]; // self.cellType 1全部好友,2直属好友,3推荐好友,4团队好友,5潜在好友 self.date.text=model.regist_at; switch (self.cellType) {//判断是哪个等级 case 1: case 3: case 4:{//全部好友,直属好友,团队好友,都要s展示q查看上级 self.rightLabel.hidden = NO; self.rightLabel.text=@"查看上级"; self.updateBtn.hidden = YES; self.sencondFansSumBtn.hidden=YES; } break; case 2: {//直属好友, self.rightLabel.hidden=YES; self.updateBtn.hidden=YES; if ([model.fans_count integerValue]!=0) { [self.sencondFansSumBtn setTitle:[NSString stringWithFormat:@"推荐%ld人>",(long)model.fans_count.integerValue] forState:UIControlStateNormal]; self.sencondFansSumBtn.hidden=NO; }else{ self.sencondFansSumBtn.hidden=YES; } } break; case 5: { //潜在好友,需要显示邀请注册 self.updateBtn.hidden = YES; self.sencondFansSumBtn.hidden=YES; self.rightLabel.hidden=NO; self.rightLabel.text=@"邀请注册"; self.date.text=model.regist_at; } break; default: self.updateBtn.hidden = YES; self.sencondFansSumBtn.hidden=YES; self.rightLabel.hidden=YES; self.date.text=model.regist_at; break; } } @end