YOUPAILCOnlineCell.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // YOUPAILCOnlineCell.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/11.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCOnlineCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. #import "YOUPAIHRAgeSexView.h"
  11. @interface YOUPAILCOnlineCell()
  12. @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
  13. @property(nonatomic,strong)UILabel* youpaipnickLab;
  14. @property (nonatomic,strong)UIImageView *youpaipsexImgV;
  15. @property (nonatomic,strong)UIImageView *youpaipvipV;
  16. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  17. @property (nonatomic, weak) YOUPAIHRAgeSexView *youpaipsexView;
  18. //@property(nonatomic,strong)UILabel* tagLabel;//标签
  19. //@property(nonatomic,strong)UILabel* ageLab;
  20. @property(nonatomic,strong)UILabel* youpaipcityLab;
  21. //@property(nonatomic,strong)UILabel* timeLab;
  22. @property(nonatomic,strong)UILabel* youpaipsignL;
  23. @property(nonatomic,strong)UIButton* youpaifollowBtn;
  24. @end
  25. @implementation YOUPAILCOnlineCell
  26. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  27. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  28. self.selectionStyle = UITableViewCellSelectionStyleNone;
  29. self.backgroundColor = [UIColor clearColor];
  30. [self youpaifinitUI];
  31. }
  32. return self;
  33. }
  34. - (void)youpaifinitUI{
  35. self.youpaipavatarImgV = [[UIImageView alloc]init];
  36. self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  37. self.youpaipavatarImgV.layer.masksToBounds = YES;
  38. self.youpaipavatarImgV.layer.cornerRadius = 51/2;
  39. [self.contentView addSubview:self.youpaipavatarImgV];
  40. [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.offset(14.0f);
  42. make.centerY.equalTo(self.contentView);
  43. make.size.mas_equalTo(CGSizeMake(51.0f, 51.0f));
  44. }];
  45. UILabel* nickLab = [[UILabel alloc]init];
  46. nickLab.textColor = LZ273145Color;
  47. nickLab.font = LCBoldFont(14);
  48. [self.contentView addSubview:nickLab];
  49. self.youpaipnickLab = nickLab;
  50. [nickLab makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self.youpaipavatarImgV.right).offset(@10);
  52. make.top.mas_equalTo(self.youpaipavatarImgV).offset(5);
  53. }];
  54. YOUPAIHRAgeSexView *sexView = [YOUPAIHRAgeSexView new];
  55. self.youpaipsexView = sexView;
  56. [self.contentView addSubview:sexView];
  57. [sexView makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(nickLab);
  59. make.top.equalTo(nickLab.mas_bottom).offset(2);
  60. make.size.mas_equalTo(CGSizeMake(30, 14));
  61. }];
  62. UIImageView *vipV = [[UIImageView alloc] init];
  63. [self.contentView addSubview:vipV];
  64. self.youpaipvipV = vipV;
  65. [vipV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(sexView.mas_right).offset(3.0f);
  67. make.centerY.equalTo(sexView);
  68. }];
  69. YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init];
  70. [self.contentView addSubview:levelView];
  71. self.youpaiplevelView = levelView;
  72. [levelView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(vipV.mas_right).offset(3.0f);
  74. make.centerY.equalTo(sexView);
  75. }];
  76. // UILabel* tagLabel = [[UILabel alloc]init];
  77. // tagLabel.textColor = HexColorFromRGB(0xA7A9FD);
  78. // // tagLabel.textAlignment = NSTextAlignmentCenter;
  79. // tagLabel.backgroundColor = HexColorFromRGB(0xF7F7FF);
  80. // tagLabel.layer.cornerRadius = 10;
  81. // tagLabel.layer.masksToBounds = YES;
  82. // tagLabel.font = LCFont(10);
  83. // [self addSubview:tagLabel];
  84. // self.tagLabel = tagLabel;
  85. // [self.tagLabel makeConstraints:^(MASConstraintMaker *make) {
  86. // make.right.equalTo(self.right).offset(@-12);
  87. // make.top.equalTo(@27);
  88. // make.height.equalTo(@20);
  89. // }];
  90. //关注
  91. UIButton *youpaifollowBtn = [UIButton new];
  92. self.youpaifollowBtn = youpaifollowBtn;
  93. [self.contentView addSubview:youpaifollowBtn];
  94. [youpaifollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.right.mas_equalTo(-12);
  96. make.centerY.mas_equalTo(0);
  97. make.size.mas_equalTo(CGSizeMake(60, 29));
  98. }];
  99. [youpaifollowBtn addTarget:self action:@selector(youpaifollowBtnCliock:) forControlEvents:UIControlEventTouchUpInside];
  100. [youpaifollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  101. youpaifollowBtn.layer.cornerRadius = 14.5;
  102. youpaifollowBtn.layer.masksToBounds = YES;
  103. youpaifollowBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  104. UILabel* signL = [[UILabel alloc]init];
  105. signL.font = LCFont12;
  106. signL.textColor = HexColorFromRGB(0x9F9DA5);
  107. [self.contentView addSubview:signL];
  108. self.youpaipsignL = signL;
  109. [signL makeConstraints:^(MASConstraintMaker *make) {
  110. make.left.equalTo(nickLab);
  111. make.top.equalTo(sexView.bottom).offset(@2);
  112. make.height.equalTo(@15);
  113. make.width.mas_equalTo(ScaleSize(230));
  114. }];
  115. signL.lineBreakMode = NSLineBreakByTruncatingTail;
  116. //分割线
  117. // UIView *lineView = [UIView new];
  118. // [self.contentView addSubview:lineView];
  119. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  120. // make.left.mas_equalTo(14);
  121. // make.right.mas_equalTo(-14);
  122. // make.bottom.mas_equalTo(0);
  123. // make.height.mas_equalTo(0.5);
  124. // }];
  125. // lineView.backgroundColor = HexColorFromRGB(0x28262D);
  126. }
  127. -(void)youpaifollowBtnCliock:(UIButton*)sender{
  128. sender.selected = !sender.selected;
  129. [LCCommonHttp followUserId:self.youpaiponlineModel.youpaipuserid];
  130. }
  131. - (void)setYoupaiponlineModel:(YOUPAILCOnlineModel *)onlineModel{
  132. _youpaiponlineModel = onlineModel;
  133. [self.youpaipsexView youpaifreloadWith:onlineModel.youpaipgender Age:onlineModel.youpaipage];
  134. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:onlineModel.youpaipavatar]];
  135. self.youpaipnickLab.text = onlineModel.youpaipnickname;
  136. self.youpaipcityLab.text = onlineModel.youpaipcity;
  137. self.youpaifollowBtn.selected = onlineModel.is_follow==1?YES:NO;
  138. [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal];
  139. [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZD3D1D7Color,LZD3D1D7Color] ByGradientType:1] forState:UIControlStateSelected];
  140. [self.youpaifollowBtn setTitle:@"已关注" forState:UIControlStateSelected];
  141. [self.youpaifollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  142. // if (onlineModel.is_follow ==1) {
  143. //
  144. // [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZD3D1D7Color,LZD3D1D7Color] ByGradientType:1] forState:UIControlStateSelected];
  145. // [self.youpaifollowBtn setTitle:@"已关注" forState:UIControlStateSelected];
  146. //
  147. // }else{
  148. // [self.youpaifollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  149. // [self.youpaifollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(60, 29) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal];
  150. // }
  151. self.youpaipvipV.hidden = YES;
  152. if (onlineModel.youpaipvip_icon.length != 0) {
  153. self.youpaipvipV.hidden = NO;
  154. [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:onlineModel.youpaipvip_icon]];
  155. [self.youpaipvipV mas_remakeConstraints:^(MASConstraintMaker *make) {
  156. make.left.equalTo(self.youpaipsexView.mas_right).offset(5.0f);
  157. make.centerY.equalTo(self.youpaipsexView);
  158. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  159. }];
  160. }
  161. [self.youpaiplevelView youpaifreloadWithIcon:onlineModel.youpaipgrade.youpaipimg1 iconWidth:onlineModel.youpaipgrade.youpaipicon_width bgImg:onlineModel.youpaipgrade.youpaipimg2 bgImgWidth:onlineModel.youpaipgrade.youpaipicon1_width levelName:onlineModel.youpaipgrade.youpaipgrade_name level:onlineModel.youpaipgrade.youpaipgrade];
  162. [self.youpaiplevelView mas_updateConstraints:^(MASConstraintMaker *make) {
  163. make.size.mas_offset(self.youpaiplevelView.mj_size);
  164. }];
  165. self.youpaipsignL.text = [NSString stringWithFormat:@"ID:%@",onlineModel.youpaipusercode.length == 0 ? @" " : onlineModel.youpaipusercode];
  166. }
  167. @end