猎豆优选

LDChildFansCell.m 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. //
  2. // LDChildFansCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDChildFansCell.h"
  9. @interface LDChildFansCell()
  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. @property (nonatomic, strong) UILabel *rightLabel;
  16. @end
  17. @implementation LDChildFansCell
  18. + (instancetype)cellWithTableView:(UITableView *)tableView {
  19. static NSString *cellID = nil;
  20. cellID = NSStringFromClass([self class]);
  21. LDChildFansCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  22. if (!cell) {
  23. cell = [[LDChildFansCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  24. }
  25. return cell;
  26. }
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. // Initialization code
  30. }
  31. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  32. [super setSelected:selected animated:animated];
  33. // Configure the view for the selected state
  34. }
  35. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  36. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  37. if (self) {
  38. [self initSubViews];
  39. }
  40. return self;
  41. }
  42. - (void)initSubViews {
  43. [self.contentView addSubview:self.iconView];
  44. [self.contentView addSubview:self.tagImage];
  45. [self.contentView addSubview:self.name];
  46. [self.contentView addSubview:self.phoneNum];
  47. [self.contentView addSubview:self.date];
  48. [self.contentView addSubview:self.sencondFansSumBtn];
  49. [self.contentView addSubview:self.updateBtn];
  50. [self.contentView addSubview:self.rightLabel];
  51. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.mas_equalTo(15);
  53. make.width.height.mas_equalTo(50);
  54. make.centerY.mas_equalTo(self.mas_centerY);
  55. }];
  56. [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(15);
  58. make.top.mas_equalTo(15);
  59. make.width.mas_lessThanOrEqualTo(130);
  60. }];
  61. [self.tagImage mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.mas_equalTo(self.name.mas_right).mas_offset(10);
  63. make.centerY.mas_equalTo(self.name.mas_centerY);
  64. make.width.mas_equalTo(55);
  65. make.height.mas_equalTo(15);
  66. }];
  67. [self.phoneNum mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.bottom.mas_equalTo(-15);
  69. make.left.mas_equalTo(self.name);
  70. }];
  71. [self.date mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.mas_equalTo(self.phoneNum.mas_right).mas_offset(10);
  73. make.centerY.mas_equalTo(self.phoneNum.mas_centerY);
  74. }];
  75. [self.sencondFansSumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.right.mas_equalTo(FITSIZE(-17));
  77. make.height.equalTo(self.mas_height);
  78. make.centerY.equalTo(self.mas_centerY);
  79. make.width.mas_equalTo(100);
  80. }];
  81. [self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.right.mas_equalTo(-15);
  83. make.centerY.mas_equalTo(self.mas_centerY);
  84. make.width.mas_equalTo(Fitsize(52));
  85. make.height.mas_equalTo(Fitsize(17));
  86. }];
  87. [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.right.mas_equalTo(-10);
  89. make.centerY.mas_equalTo(self.mas_centerY);
  90. make.width.mas_equalTo(FITSIZE(55));
  91. make.height.mas_equalTo(FITSIZE(20));
  92. }];
  93. }
  94. #pragma mark -事件
  95. -(void)sencondFansAction{
  96. if (self.delegate && [self.delegate respondsToSelector:@selector(recommendFansByUserID:withUserName:)]) {
  97. [self.delegate recommendFansByUserID:self.model.user_id withUserName:self.model.name];
  98. }
  99. }
  100. #pragma mark -懒加载
  101. - (UIImageView *)iconView {
  102. if (!_iconView) {
  103. _iconView = [[UIImageView alloc] init];
  104. _iconView.contentMode = UIViewContentModeScaleAspectFill;
  105. _iconView.layer.masksToBounds = YES;
  106. _iconView.backgroundColor = [UIColor yhGrayColor];
  107. [_iconView setImage:[UIImage imageNamed:@"login"]];
  108. _iconView.layer.cornerRadius = 25;
  109. }
  110. return _iconView;
  111. }
  112. - (UIImageView *)tagImage {
  113. if (!_tagImage) {
  114. _tagImage = [[UIImageView alloc] init];
  115. _tagImage.contentMode = UIViewContentModeScaleAspectFit;
  116. // _tagImage.image = [UIImage imageNamed:@"Svip_icon"];
  117. }
  118. return _tagImage;
  119. }
  120. - (UILabel *)name {
  121. if (!_name) {
  122. _name = [[UILabel alloc] init];
  123. _name.textColor = [UIColor YHColorWithHex:0x333333];
  124. _name.font = [UIFont systemFontOfSize:14];
  125. _name.text = @"未知用户";
  126. }
  127. return _name;
  128. }
  129. - (UILabel *)phoneNum {
  130. if (!_phoneNum) {
  131. _phoneNum = [[UILabel alloc] init];
  132. _phoneNum.textColor = [UIColor YHColorWithHex:0x878787];
  133. _phoneNum.font = [UIFont systemFontOfSize:12];
  134. _phoneNum.text = @"****";
  135. }
  136. return _phoneNum;
  137. }
  138. - (UILabel *)date {
  139. if (!_date) {
  140. _date = [[UILabel alloc] init];
  141. _date.textColor = [UIColor YHColorWithHex:0x878787];
  142. _date.font = [UIFont systemFontOfSize:12];
  143. _date.text = @"--";
  144. }
  145. return _date;
  146. }
  147. -(UIButton *)sencondFansSumBtn{
  148. if (!_sencondFansSumBtn) {
  149. _sencondFansSumBtn=[UIButton buttonWithType:UIButtonTypeCustom];
  150. [_sencondFansSumBtn setTitleColor:[UIColor YHColorWithHex:0xFF4633] forState:UIControlStateNormal];
  151. _sencondFansSumBtn.titleLabel.font=[UIFont systemFontOfSize:12];
  152. [_sencondFansSumBtn addTarget:self action:@selector(sencondFansAction) forControlEvents:UIControlEventTouchUpInside];
  153. }
  154. return _sencondFansSumBtn;
  155. }
  156. - (UIButton *)updateBtn {
  157. if (!_updateBtn) {
  158. _updateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  159. [_updateBtn setImage:[UIImage imageNamed:@"update_btn"] forState:UIControlStateNormal];
  160. [_updateBtn addTarget:self action:@selector(updateBtnAction) forControlEvents:UIControlEventTouchUpInside];
  161. }
  162. return _updateBtn;
  163. }
  164. - (UILabel *)rightLabel {
  165. if (!_rightLabel) {
  166. _rightLabel = [[UILabel alloc] init];
  167. _rightLabel.textColor = [UIColor homeRedColor];
  168. _rightLabel.font = [UIFont systemFontOfSize:FITSIZE(10)];
  169. _rightLabel.text = @"查看上级";
  170. _rightLabel.layer.borderWidth = 1;
  171. _rightLabel.layer.borderColor = [UIColor homeRedColor].CGColor;
  172. _rightLabel.layer.cornerRadius = FITSIZE(10);
  173. _rightLabel.textAlignment = NSTextAlignmentCenter;
  174. }
  175. return _rightLabel;
  176. }
  177. //-(UIButton *)registBtn
  178. //{
  179. // if (!_registBtn) {
  180. // _registBtn =[[UIButton alloc]init];
  181. // [_registBtn addTarget:self action:@selector(registClickBtn) forControlEvents:UIControlEventTouchUpInside];
  182. // _registBtn setTitle:<#(nullable NSString *)#> forState:<#(UIControlState)#>
  183. // }
  184. // return _registBtn;
  185. //}
  186. -(void)registClickBtn//邀请注册
  187. {
  188. }
  189. - (void)updateBtnAction {
  190. if (self.updateAction) {
  191. self.updateAction(_model);
  192. }
  193. }
  194. -(void)setModel:(LDChildFansModel *)model{
  195. _model=model;
  196. // @property(nonatomic,copy)NSString *name; //名称
  197. // @property(nonatomic,copy)NSString *phone; // s手机号
  198. // @property(nonatomic,copy)NSString *fansDevel; // f粉丝等级 1 一级粉丝 2二级粉丝
  199. // @property(nonatomic,copy)NSString *fansNum; //一级粉丝邀请的人数
  200. // @property(nonatomic,copy)NSString *first_level_vermicelli_time; //r如果粉丝等级为1 时间取这个
  201. // @property(nonatomic,copy)NSString *second_level_vermicelli_time; //r如果粉丝等级为2 时间取这个
  202. // @property(nonatomic,copy)NSString *level; //1 会员 2超级会员 3 运营商
  203. self.name.text=model.name;
  204. self.phoneNum.text=model.phone;
  205. self.tagImage.hidden = NO;
  206. switch ([model.level integerValue]) {
  207. case 1:
  208. {
  209. self.tagImage.image = [UIImage imageNamed:@"Vip_icon"];
  210. self.sencondFansSumBtn.hidden=YES;
  211. }
  212. break;
  213. case 2:
  214. self.tagImage.image = [UIImage imageNamed:@"Svip_icon"];
  215. break;
  216. case 3:
  217. {
  218. self.tagImage.image = [UIImage imageNamed:@"operator_icon"];
  219. }
  220. break;
  221. default:
  222. self.tagImage.hidden = YES;
  223. break;
  224. }
  225. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"login"]];
  226. // self.cellType 1全部好友,2直属好友,3推荐好友,4团队好友,5潜在好友
  227. self.date.text=model.regist_at;
  228. switch (self.cellType) {//判断是哪个等级
  229. case 1:
  230. case 3:
  231. case 4:{//全部好友,直属好友,团队好友,都要s展示q查看上级
  232. self.rightLabel.hidden = NO;
  233. self.rightLabel.text=@"查看上级";
  234. self.updateBtn.hidden = YES;
  235. self.sencondFansSumBtn.hidden=YES;
  236. }
  237. break;
  238. case 2:
  239. {//直属好友,
  240. self.rightLabel.hidden=YES;
  241. self.updateBtn.hidden=YES;
  242. if ([model.fans_count integerValue]!=0) {
  243. [self.sencondFansSumBtn setTitle:[NSString stringWithFormat:@"推荐%ld人>",(long)model.fans_count.integerValue] forState:UIControlStateNormal];
  244. self.sencondFansSumBtn.hidden=NO;
  245. }else{
  246. self.sencondFansSumBtn.hidden=YES;
  247. }
  248. }
  249. break;
  250. case 5:
  251. {
  252. //潜在好友,需要显示邀请注册
  253. self.updateBtn.hidden = YES;
  254. self.sencondFansSumBtn.hidden=YES;
  255. self.rightLabel.hidden=NO;
  256. self.rightLabel.text=@"邀请注册";
  257. self.date.text=model.regist_at;
  258. }
  259. break;
  260. default:
  261. self.updateBtn.hidden = YES;
  262. self.sencondFansSumBtn.hidden=YES;
  263. self.rightLabel.hidden=YES;
  264. self.date.text=model.regist_at;
  265. break;
  266. }
  267. }
  268. @end