// // FKVipStatusCell.m // FirstLink // // Created by jack on 15/9/11. // Copyright (c) 2015年 FirstLink. All rights reserved. // #import "FKVipStatusCell.h" @interface FKVipStatusCell () @property (nonatomic, strong) UIImageView *vipImageView; @end @implementation FKVipStatusCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self addAllSubviews]; self.selectionStyle = UITableViewCellSelectionStyleNone; } return self; } - (void)addAllSubviews{ [self.contentView addSubview:self.vipImageView]; [self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.equalTo(self.contentView); make.height.mas_equalTo([FKVipStatusCell vipImageHeight]); }]; [self.vipImageView addSubview:self.headView]; [self.headView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.vipImageView); make.centerY.equalTo(self.vipImageView); make.size.mas_equalTo(CGSizeMake(70, 70)); }]; [self.vipImageView addSubview:self.vipIcon]; [self.vipIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.headView.mas_right).offset(-16); make.bottom.equalTo(self.headView); }]; [self.vipImageView addSubview:self.nickLabel]; [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.headView); make.top.equalTo(self.headView.mas_bottom).offset(8); }]; [self.vipImageView addSubview:self.vipTipLabel]; [self.vipTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.headView.mas_centerY).offset(2); make.right.equalTo(self.headView.mas_left).offset(-45); }]; [self.vipImageView addSubview:self.vipLabel]; [self.vipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.headView.mas_centerY).offset(-2); make.centerX.equalTo(self.vipTipLabel); }]; [self.vipImageView addSubview:self.dayTipLabel]; [self.dayTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.headView.mas_centerY).offset(2); make.left.equalTo(self.headView.mas_right).offset(45); }]; [self.vipImageView addSubview:self.dayLabel]; [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.headView.mas_centerY).offset(-2); make.centerX.equalTo(self.dayTipLabel); }]; } #pragma mark - Method + (CGFloat)vipImageHeight { return UISCREENWIDTH*376/750; } + (CGFloat)height { return [FKVipStatusCell vipImageHeight]; } #pragma mark - property - (UIImageView *)vipImageView { if (!_vipImageView) { _vipImageView = [[UIImageView alloc] init]; _vipImageView.image = [UIImage imageNamed:@"my_vip_bg_icon"]; } return _vipImageView; } - (AvatarImageView *)headView { if (!_headView) { _headView = [[AvatarImageView alloc]initWithFrame:CGRectMake(0, 0, 70, 70) boardWidth:4.0f boardColor:[UIColor whiteColor]]; _headView.backgroundColor = [UIColor whiteColor]; _headView.userInteractionEnabled = YES; } return _headView; } - (UILabel *)nickLabel { if (!_nickLabel) { _nickLabel = [UILabel new]; _nickLabel.font = [UIFont systemFontOfSize:14]; _nickLabel.textColor = UIColorFromRGB(0x333333); _nickLabel.textAlignment = NSTextAlignmentCenter; } return _nickLabel; } - (UIImageView *)vipIcon { if (!_vipIcon) { _vipIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HomeVIPTagIcon"]]; } return _vipIcon; } - (UILabel *)vipLabel { if (!_vipLabel) { _vipLabel = [UILabel new]; _vipLabel.font = [UIFont systemFontOfSize:14]; _vipLabel.textColor = UIColorFromRGB(0x333333); } return _vipLabel; } - (UILabel *)vipTipLabel { if (!_vipTipLabel) { _vipTipLabel = [UILabel new]; _vipTipLabel.text = @"会员等级"; _vipTipLabel.font = [UIFont systemFontOfSize:12]; _vipTipLabel.textColor = UIColorFromRGB(0xb4903e); } return _vipTipLabel; } - (UILabel *)dayLabel { if (!_dayLabel) { _dayLabel = [UILabel new]; _dayLabel.font = [UIFont systemFontOfSize:14]; _dayLabel.textColor = UIColorFromRGB(0x333333); } return _dayLabel; } - (UILabel *)dayTipLabel { if (!_dayTipLabel) { _dayTipLabel = [UILabel new]; _dayTipLabel.font = [UIFont systemFontOfSize:12]; _dayTipLabel.textColor = UIColorFromRGB(0xb4903e); _dayTipLabel.text = @"会员剩余"; } return _dayTipLabel; } - (void)config:(VipState)vipState remainDays:(NSUInteger)days { switch (vipState) { case VipStateNormal:{ self.vipIcon.hidden = NO; self.vipLabel.text = @"VIP会员"; self.dayLabel.text = [NSString stringWithFormat:@"%@天", @(days)]; break; } case VipStateNoApply:{ self.vipIcon.hidden = YES; self.vipLabel.text = @"非VIP会员"; self.dayLabel.text = @"0天"; break; } case VipStateOverDue:{ self.vipIcon.hidden = NO; self.vipLabel.text = @"VIP会员已过期"; self.dayLabel.text = @"0天"; break; } default: break; } User *user = [FKUserManager sharedManager].user; [self.headView.avatarView setImageWithURL:user.headurl placeholderImage:nil width:70 height:70]; [self.nickLabel setText:user.nickName]; } @end