No Description

FKVipStatusCell.m 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // FKVipStatusCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/9/11.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKVipStatusCell.h"
  9. @interface FKVipStatusCell ()
  10. @property (nonatomic, strong) UIImageView *vipImageView;
  11. @end
  12. @implementation FKVipStatusCell
  13. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  14. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  15. if (self) {
  16. [self addAllSubviews];
  17. self.selectionStyle = UITableViewCellSelectionStyleNone;
  18. }
  19. return self;
  20. }
  21. - (void)addAllSubviews{
  22. [self.contentView addSubview:self.vipImageView];
  23. [self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.top.right.equalTo(self.contentView);
  25. make.height.mas_equalTo([FKVipStatusCell vipImageHeight]);
  26. }];
  27. [self.vipImageView addSubview:self.headView];
  28. [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.centerX.equalTo(self.vipImageView);
  30. make.centerY.equalTo(self.vipImageView);
  31. make.size.mas_equalTo(CGSizeMake(70, 70));
  32. }];
  33. [self.vipImageView addSubview:self.vipIcon];
  34. [self.vipIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.equalTo(self.headView.mas_right).offset(-16);
  36. make.bottom.equalTo(self.headView);
  37. }];
  38. [self.vipImageView addSubview:self.nickLabel];
  39. [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.centerX.equalTo(self.headView);
  41. make.top.equalTo(self.headView.mas_bottom).offset(8);
  42. }];
  43. [self.vipImageView addSubview:self.vipTipLabel];
  44. [self.vipTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.headView.mas_centerY).offset(2);
  46. make.right.equalTo(self.headView.mas_left).offset(-45);
  47. }];
  48. [self.vipImageView addSubview:self.vipLabel];
  49. [self.vipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.bottom.equalTo(self.headView.mas_centerY).offset(-2);
  51. make.centerX.equalTo(self.vipTipLabel);
  52. }];
  53. [self.vipImageView addSubview:self.dayTipLabel];
  54. [self.dayTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.headView.mas_centerY).offset(2);
  56. make.left.equalTo(self.headView.mas_right).offset(45);
  57. }];
  58. [self.vipImageView addSubview:self.dayLabel];
  59. [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.bottom.equalTo(self.headView.mas_centerY).offset(-2);
  61. make.centerX.equalTo(self.dayTipLabel);
  62. }];
  63. }
  64. #pragma mark - Method
  65. + (CGFloat)vipImageHeight {
  66. return UISCREENWIDTH*376/750;
  67. }
  68. + (CGFloat)height {
  69. return [FKVipStatusCell vipImageHeight];
  70. }
  71. #pragma mark - property
  72. - (UIImageView *)vipImageView {
  73. if (!_vipImageView) {
  74. _vipImageView = [[UIImageView alloc] init];
  75. _vipImageView.image = [UIImage imageNamed:@"my_vip_bg_icon"];
  76. }
  77. return _vipImageView;
  78. }
  79. - (AvatarImageView *)headView {
  80. if (!_headView) {
  81. _headView = [[AvatarImageView alloc]initWithFrame:CGRectMake(0, 0, 70, 70)
  82. boardWidth:4.0f
  83. boardColor:[UIColor whiteColor]];
  84. _headView.backgroundColor = [UIColor whiteColor];
  85. _headView.userInteractionEnabled = YES;
  86. }
  87. return _headView;
  88. }
  89. - (UILabel *)nickLabel {
  90. if (!_nickLabel) {
  91. _nickLabel = [UILabel new];
  92. _nickLabel.font = [UIFont systemFontOfSize:14];
  93. _nickLabel.textColor = UIColorFromRGB(0x333333);
  94. _nickLabel.textAlignment = NSTextAlignmentCenter;
  95. }
  96. return _nickLabel;
  97. }
  98. - (UIImageView *)vipIcon {
  99. if (!_vipIcon) {
  100. _vipIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HomeVIPTagIcon"]];
  101. }
  102. return _vipIcon;
  103. }
  104. - (UILabel *)vipLabel {
  105. if (!_vipLabel) {
  106. _vipLabel = [UILabel new];
  107. _vipLabel.font = [UIFont systemFontOfSize:14];
  108. _vipLabel.textColor = UIColorFromRGB(0x333333);
  109. }
  110. return _vipLabel;
  111. }
  112. - (UILabel *)vipTipLabel {
  113. if (!_vipTipLabel) {
  114. _vipTipLabel = [UILabel new];
  115. _vipTipLabel.text = @"会员等级";
  116. _vipTipLabel.font = [UIFont systemFontOfSize:12];
  117. _vipTipLabel.textColor = UIColorFromRGB(0xb4903e);
  118. }
  119. return _vipTipLabel;
  120. }
  121. - (UILabel *)dayLabel {
  122. if (!_dayLabel) {
  123. _dayLabel = [UILabel new];
  124. _dayLabel.font = [UIFont systemFontOfSize:14];
  125. _dayLabel.textColor = UIColorFromRGB(0x333333);
  126. }
  127. return _dayLabel;
  128. }
  129. - (UILabel *)dayTipLabel {
  130. if (!_dayTipLabel) {
  131. _dayTipLabel = [UILabel new];
  132. _dayTipLabel.font = [UIFont systemFontOfSize:12];
  133. _dayTipLabel.textColor = UIColorFromRGB(0xb4903e);
  134. _dayTipLabel.text = @"会员剩余";
  135. }
  136. return _dayTipLabel;
  137. }
  138. - (void)config:(VipState)vipState remainDays:(NSUInteger)days {
  139. switch (vipState) {
  140. case VipStateNormal:{
  141. self.vipIcon.hidden = NO;
  142. self.vipLabel.text = @"VIP会员";
  143. self.dayLabel.text = [NSString stringWithFormat:@"%@天", @(days)];
  144. break;
  145. }
  146. case VipStateNoApply:{
  147. self.vipIcon.hidden = YES;
  148. self.vipLabel.text = @"非VIP会员";
  149. self.dayLabel.text = @"0天";
  150. break;
  151. }
  152. case VipStateOverDue:{
  153. self.vipIcon.hidden = NO;
  154. self.vipLabel.text = @"VIP会员已过期";
  155. self.dayLabel.text = @"0天";
  156. break;
  157. }
  158. default:
  159. break;
  160. }
  161. User *user = [FKUserManager sharedManager].user;
  162. [self.headView.avatarView setImageWithURL:user.headurl placeholderImage:nil width:70 height:70];
  163. [self.nickLabel setText:user.nickName];
  164. }
  165. @end