口袋优选

KBChildFansCell.m 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. //
  2. // KBChildFansCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBChildFansCell.h"
  9. @interface KBChildFansCell()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UIImageView *tagImage;
  12. @property (nonatomic, strong) UILabel *name;
  13. @property (nonatomic, strong) UILabel *phoneNum;
  14. @property (nonatomic, strong) UILabel *date;
  15. @end
  16. @implementation KBChildFansCell
  17. + (instancetype)cellWithTableView:(UITableView *)tableView {
  18. static NSString *cellID = nil;
  19. cellID = NSStringFromClass([self class]);
  20. KBChildFansCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  21. if (!cell) {
  22. cell = [[KBChildFansCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  23. }
  24. return cell;
  25. }
  26. - (void)awakeFromNib {
  27. [super awakeFromNib];
  28. // Initialization code
  29. }
  30. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  31. [super setSelected:selected animated:animated];
  32. // Configure the view for the selected state
  33. }
  34. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  35. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  36. if (self) {
  37. [self initSubViews];
  38. }
  39. return self;
  40. }
  41. - (void)initSubViews {
  42. [self.contentView addSubview:self.iconView];
  43. [self.contentView addSubview:self.tagImage];
  44. [self.contentView addSubview:self.name];
  45. [self.contentView addSubview:self.phoneNum];
  46. [self.contentView addSubview:self.date];
  47. [self.contentView addSubview:self.sencondFansSumBtn];
  48. [self.contentView addSubview:self.updateBtn];
  49. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(15);
  51. make.width.height.mas_equalTo(50);
  52. make.centerY.mas_equalTo(self.mas_centerY);
  53. }];
  54. [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(15);
  56. make.top.mas_equalTo(15);
  57. make.width.mas_lessThanOrEqualTo(150);
  58. }];
  59. [self.tagImage mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.mas_equalTo(self.name.mas_right).mas_offset(10);
  61. make.centerY.mas_equalTo(self.name.mas_centerY);
  62. make.width.mas_equalTo(55);
  63. make.height.mas_equalTo(15);
  64. }];
  65. [self.phoneNum mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.bottom.mas_equalTo(-15);
  67. make.left.mas_equalTo(self.name);
  68. }];
  69. [self.date mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.mas_equalTo(self.phoneNum.mas_right).mas_offset(10);
  71. make.centerY.mas_equalTo(self.phoneNum.mas_centerY);
  72. }];
  73. [self.sencondFansSumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.right.mas_equalTo(FITSIZE(-17));
  75. make.height.equalTo(self.mas_height);
  76. make.centerY.equalTo(self.mas_centerY);
  77. make.width.mas_equalTo(100);
  78. }];
  79. [self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.right.mas_equalTo(-15);
  81. make.centerY.mas_equalTo(self.mas_centerY);
  82. make.width.mas_equalTo(Fitsize(52));
  83. make.height.mas_equalTo(Fitsize(17));
  84. }];
  85. }
  86. #pragma mark -事件
  87. -(void)sencondFansAction{
  88. if (self.delegate && [self.delegate respondsToSelector:@selector(recommendFansByUserID:withUserName:)]) {
  89. [self.delegate recommendFansByUserID:self.model.user_id withUserName:self.model.name];
  90. }
  91. }
  92. #pragma mark -懒加载
  93. - (UIImageView *)iconView {
  94. if (!_iconView) {
  95. _iconView = [[UIImageView alloc] init];
  96. _iconView.contentMode = UIViewContentModeScaleAspectFill;
  97. _iconView.layer.masksToBounds = YES;
  98. _iconView.backgroundColor = [UIColor yhGrayColor];
  99. [_iconView setImage:[UIImage imageNamed:@"login"]];
  100. _iconView.layer.cornerRadius = 25;
  101. }
  102. return _iconView;
  103. }
  104. - (UIImageView *)tagImage {
  105. if (!_tagImage) {
  106. _tagImage = [[UIImageView alloc] init];
  107. _tagImage.contentMode = UIViewContentModeScaleAspectFit;
  108. _tagImage.image = [UIImage imageNamed:@"Svip_icon"];
  109. }
  110. return _tagImage;
  111. }
  112. - (UILabel *)name {
  113. if (!_name) {
  114. _name = [[UILabel alloc] init];
  115. _name.textColor = [UIColor YHColorWithHex:0x333333];
  116. _name.font = [UIFont systemFontOfSize:14];
  117. _name.text = @"未知用户";
  118. }
  119. return _name;
  120. }
  121. - (UILabel *)phoneNum {
  122. if (!_phoneNum) {
  123. _phoneNum = [[UILabel alloc] init];
  124. _phoneNum.textColor = [UIColor YHColorWithHex:0x878787];
  125. _phoneNum.font = [UIFont systemFontOfSize:12];
  126. _phoneNum.text = @"****";
  127. }
  128. return _phoneNum;
  129. }
  130. - (UILabel *)date {
  131. if (!_date) {
  132. _date = [[UILabel alloc] init];
  133. _date.textColor = [UIColor YHColorWithHex:0x878787];
  134. _date.font = [UIFont systemFontOfSize:12];
  135. _date.text = @"--";
  136. }
  137. return _date;
  138. }
  139. -(UIButton *)sencondFansSumBtn{
  140. if (!_sencondFansSumBtn) {
  141. _sencondFansSumBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  142. [_sencondFansSumBtn setTitleColor:[UIColor YHColorWithHex:0xFF4633] forState:UIControlStateNormal];
  143. _sencondFansSumBtn.titleLabel.font=[UIFont systemFontOfSize:12];
  144. [_sencondFansSumBtn addTarget:self action:@selector(sencondFansAction) forControlEvents:UIControlEventTouchUpInside];
  145. }
  146. return _sencondFansSumBtn;
  147. }
  148. - (UIButton *)updateBtn {
  149. if (!_updateBtn) {
  150. _updateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  151. [_updateBtn setImage:[UIImage imageNamed:@"update_btn"] forState:UIControlStateNormal];
  152. [_updateBtn addTarget:self action:@selector(updateBtnAction) forControlEvents:UIControlEventTouchUpInside];
  153. }
  154. return _updateBtn;
  155. }
  156. - (void)updateBtnAction {
  157. if (self.updateAction) {
  158. self.updateAction(_model);
  159. }
  160. }
  161. -(void)setModel:(KBChildFansModel *)model{
  162. _model=model;
  163. // @property(nonatomic,copy)NSString *name; //名称
  164. // @property(nonatomic,copy)NSString *phone; // s手机号
  165. // @property(nonatomic,copy)NSString *fansDevel; // f粉丝等级 1 一级粉丝 2二级粉丝
  166. // @property(nonatomic,copy)NSString *fansNum; //一级粉丝邀请的人数
  167. // @property(nonatomic,copy)NSString *first_level_vermicelli_time; //r如果粉丝等级为1 时间取这个
  168. // @property(nonatomic,copy)NSString *second_level_vermicelli_time; //r如果粉丝等级为2 时间取这个
  169. // @property(nonatomic,copy)NSString *level; //1 会员 2超级会员 3 运营商
  170. self.name.text=model.name;
  171. // if (model.name.length > 10) {
  172. // [self.name mas_updateConstraints:^(MASConstraintMaker *make) {
  173. // make.width.mas_equalTo(150);
  174. // }];
  175. // }
  176. self.phoneNum.text=model.phone;
  177. switch ([model.level integerValue]) {
  178. case 1:
  179. {
  180. self.tagImage.image = [UIImage imageNamed:@"Vip_icon"];
  181. self.sencondFansSumBtn.hidden=YES;
  182. }
  183. break;
  184. case 2:
  185. case 3:
  186. {
  187. self.tagImage.image = [UIImage imageNamed:@"Svip_icon"];
  188. }
  189. break;
  190. default:
  191. break;
  192. }
  193. switch ([model.fansDevel integerValue]) {
  194. case 1:
  195. {
  196. self.date.text=model.first_level_vermicelli_time;
  197. if ([model.fansNum integerValue]!=0) {
  198. [self.sencondFansSumBtn setTitle:[NSString stringWithFormat:@"推荐%@人>",model.fansNum] forState:UIControlStateNormal];
  199. self.sencondFansSumBtn.hidden=NO;
  200. }else{
  201. self.sencondFansSumBtn.hidden=YES;
  202. }
  203. }
  204. break;
  205. case 2:
  206. {
  207. self.date.text=model.second_level_vermicelli_time;
  208. self.sencondFansSumBtn.hidden=YES;
  209. }
  210. break;
  211. default:
  212. break;
  213. }
  214. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"login"]];
  215. self.updateBtn.hidden = [model.level integerValue]==1 && model.uplevel.boolValue ? NO : YES;
  216. }
  217. @end