YOUPAILZLiveOnlineMemberCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. //
  2. // YOUPAILZLiveOnlineMemberCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/6/23.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveOnlineMemberCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. #import "YOUPAILZAvatarView.h"
  11. @interface YOUPAILZLiveOnlineMemberCell ()
  12. @property (nonatomic, weak) UIImageView *youpaiprankImgV;
  13. @property (nonatomic, weak) UILabel *youpaiprankL;
  14. @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView;
  15. @property (nonatomic, weak) UILabel *youpaipnicknameL;
  16. @property (nonatomic, weak) UIImageView *youpaipsexV;
  17. @property (nonatomic, weak) UIImageView *youpaipvipImgV;
  18. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  19. @property (nonatomic, weak) UILabel *youpaipcontributionL;
  20. @property (nonatomic, weak) UIButton *youpaipfollowBtn;
  21. @property (nonatomic, strong) YOUPAILZLiveMemberModel *youpaipmemberModel;
  22. @property (nonatomic, strong) UIColor *youpaipthemeColor;
  23. @end
  24. @implementation YOUPAILZLiveOnlineMemberCell
  25. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  26. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  27. self.selectionStyle = UITableViewCellSelectionStyleNone;
  28. self.backgroundColor = [UIColor clearColor];
  29. [self youpaifinitUI];
  30. }
  31. return self;
  32. }
  33. - (void)youpaifinitUI{
  34. UIImageView *youpaiprankImgV = [[UIImageView alloc] init];
  35. [self.contentView addSubview:youpaiprankImgV];
  36. self.youpaiprankImgV = youpaiprankImgV;
  37. [youpaiprankImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.offset(7.0f);
  39. make.centerY.equalTo(self.contentView);
  40. make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
  41. }];
  42. UILabel *youpaiprankL = [[UILabel alloc] init];
  43. youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5);
  44. youpaiprankL.textAlignment = NSTextAlignmentCenter;
  45. youpaiprankL.font = LCFont12;
  46. [self.contentView addSubview:youpaiprankL];
  47. self.youpaiprankL = youpaiprankL;
  48. [youpaiprankL mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.offset(7.0f);
  50. make.centerY.equalTo(self.centerY);
  51. make.size.mas_offset(CGSizeMake(38.0f, 28.0f));
  52. }];
  53. YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 40, 40) avatarURL:nil personalityBoxURL:nil];
  54. [self.contentView addSubview:youpaipavatarView];
  55. self.youpaipavatarView = youpaipavatarView;
  56. [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.offset(52.0f);
  58. make.centerY.equalTo(self.contentView.mas_centerY);
  59. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  60. }];
  61. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  62. youpaipnicknameL.font = LCBoldFont(14.0f);
  63. youpaipnicknameL.textColor = [UIColor whiteColor];
  64. [self.contentView addSubview:youpaipnicknameL];
  65. self.youpaipnicknameL = youpaipnicknameL;
  66. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  68. make.top.offset(15.0f);
  69. }];
  70. UIImageView *youpaipsexV = [[UIImageView alloc] init];
  71. [self.contentView addSubview:youpaipsexV];
  72. self.youpaipsexV = youpaipsexV;
  73. [youpaipsexV mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  75. make.centerY.equalTo(youpaipnicknameL);
  76. make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
  77. }];
  78. UIImageView *youpaipvipImgV = [[UIImageView alloc] init];
  79. [self.contentView addSubview:youpaipvipImgV];
  80. self.youpaipvipImgV = youpaipvipImgV;
  81. [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.equalTo(youpaipsexV.mas_right).offset(3.0f);
  83. make.centerY.equalTo(youpaipnicknameL);
  84. }];
  85. YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  86. [self.contentView addSubview:youpaiplevelView];
  87. self.youpaiplevelView = youpaiplevelView;
  88. [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.equalTo(youpaipsexV.mas_right).offset(3.0f);
  90. make.centerY.equalTo(youpaipnicknameL);
  91. }];
  92. UILabel *youpaipcontributionL = [[UILabel alloc] init];
  93. youpaipcontributionL.font = LCFont(10.0f);
  94. youpaipcontributionL.textColor = [UIColor whiteColor];
  95. [self.contentView addSubview:youpaipcontributionL];
  96. self.youpaipcontributionL = youpaipcontributionL;
  97. [youpaipcontributionL mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f);
  99. make.top.equalTo(youpaipnicknameL.mas_bottom).offset(2.0f);
  100. }];
  101. UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  102. youpaipfollowBtn.layer.cornerRadius = 11.0f;
  103. youpaipfollowBtn.clipsToBounds = YES;
  104. youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0xFFDD8D).CGColor;
  105. youpaipfollowBtn.layer.borderWidth = 0.5f;
  106. [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  107. [youpaipfollowBtn setTitleColor:HexColorFromRGB(0xFFDD8D) forState:UIControlStateNormal];
  108. youpaipfollowBtn.titleLabel.font = LCFont12;
  109. [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside];
  110. [self.contentView addSubview:youpaipfollowBtn];
  111. self.youpaipfollowBtn = youpaipfollowBtn;
  112. [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.centerY.equalTo(self.contentView);
  114. make.right.offset(-12.0f);
  115. make.size.mas_offset(CGSizeMake(56.0f, 22.0f));
  116. }];
  117. }
  118. - (void)youpaifreloadWithModel:(YOUPAILZLiveMemberModel *)member indexPath:(NSIndexPath *)indexPath type:(LZLiveMemberListType)type youpaipthemeColor:(UIColor *)youpaipthemeColor{
  119. self.youpaipmemberModel = member;
  120. self.youpaipthemeColor = youpaipthemeColor;
  121. if (indexPath.row + 1 <= 3 && type != LZLiveMemberListTypeOnline) {
  122. self.youpaiprankImgV.hidden = NO;
  123. self.youpaiprankL.hidden = YES;
  124. self.youpaiprankImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_L_live_rank_consumption_%@",@(indexPath.row + 1)]];
  125. NSArray <UIColor *>*colors = @[HexColorFromRGB(0xF5C686),HexColorFromRGB(0xDFF6FF),HexColorFromRGB(0xB8CC8B)];
  126. self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = colors[indexPath.row].CGColor;
  127. }else{
  128. self.youpaiprankImgV.hidden = YES;
  129. self.youpaiprankL.hidden = NO;
  130. self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor;
  131. }
  132. self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(indexPath.row + 1)];
  133. self.youpaipfollowBtn.hidden = NO;
  134. if (member.youpaipis_follow == 1){
  135. self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  136. [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
  137. [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
  138. }else if (member.youpaipis_follow == 0){
  139. self.youpaipfollowBtn.layer.borderColor = youpaipthemeColor.CGColor;
  140. [self.youpaipfollowBtn setTitleColor:youpaipthemeColor forState:UIControlStateNormal];
  141. [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  142. }else{
  143. self.youpaipfollowBtn.hidden = YES;
  144. }
  145. self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:member.youpaipavatar];
  146. self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:member.youpaipavatar_frame];
  147. self.youpaipnicknameL.text = member.youpaipnickname;
  148. if (member.youpaipgender == 1) {//0未知 1女 2男
  149. self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
  150. }else{
  151. self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
  152. }
  153. self.youpaipvipImgV.hidden = YES;
  154. self.youpaiplevelView.hidden = YES;
  155. UIView *frontV;
  156. if (member.youpaipvip_icon.length != 0) {
  157. self.youpaipvipImgV.hidden = NO;
  158. [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:member.youpaipvip_icon]];
  159. [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  160. if (frontV == nil) {
  161. make.left.equalTo(self.youpaipsexV.mas_right).offset(3.0f);
  162. }else{
  163. make.left.equalTo(frontV.mas_right).offset(3.0f);
  164. }
  165. make.centerY.equalTo(self.youpaipnicknameL);
  166. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  167. }];
  168. frontV = self.youpaipvipImgV;
  169. }
  170. self.youpaiplevelView.hidden = NO;
  171. [self.youpaiplevelView youpaifreloadWithIcon:member.youpaipgrade.youpaipimg1 iconWidth:member.youpaipgrade.youpaipicon_width bgImg:member.youpaipgrade.youpaipimg2 bgImgWidth:member.youpaipgrade.youpaipicon1_width levelName:member.youpaipgrade.youpaipgrade_name level:member.youpaipgrade.youpaipgrade];
  172. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  173. if (frontV == nil) {
  174. make.left.equalTo(self.youpaipsexV.mas_right).offset(3.0f);
  175. }else{
  176. make.left.equalTo(frontV.mas_right).offset(3.0f);
  177. }
  178. make.centerY.equalTo(self.youpaipnicknameL);
  179. make.size.mas_offset(self.youpaiplevelView.mj_size);
  180. }];
  181. self.youpaipcontributionL.attributedText = [LCTools setRichTextWithTitle:@"贡献值:" subTitle:[NSString stringWithFormat:@"%@",member.youpaipscore] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:10.0f subTitleFontSize:10.0f];
  182. }
  183. - (void)youpaiffollowBtnClick{
  184. self.youpaipmemberModel.youpaipis_follow = self.youpaipmemberModel.youpaipis_follow == 1 ? 0 : 1;
  185. if (self.youpaipmemberModel.youpaipis_follow== 1){
  186. self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  187. [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal];
  188. [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal];
  189. }else{
  190. self.youpaipfollowBtn.layer.borderColor = self.youpaipthemeColor.CGColor;
  191. [self.youpaipfollowBtn setTitleColor:self.youpaipthemeColor forState:UIControlStateNormal];
  192. [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  193. }
  194. [LCCommonHttp followUserId:self.youpaipmemberModel.youpaipid];
  195. }
  196. @end