YOUPAIMyNetworkCell.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //
  2. // YOUPAIMyNetworkCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by xiaohaoran on 2022/3/11.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAIMyNetworkCell.h"
  9. #import "YOUPAISexView.h"
  10. @interface YOUPAIMyNetworkCell ()
  11. @property(nonatomic,strong)UIImageView *youpaipavatarImgV;
  12. @property(nonatomic,strong)UILabel *youpaipnicknameL;
  13. @property(nonatomic,strong)YOUPAISexView *youpaipsexView;
  14. @property(nonatomic,strong)UILabel *youpaiContent;
  15. @property(nonatomic,strong)UIImageView *personImageView;
  16. @property(nonatomic,strong)UILabel *youpaiTimeLabel;
  17. @property(nonatomic,strong)UILabel *youpaiPriceLabel;
  18. @end
  19. @implementation YOUPAIMyNetworkCell
  20. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  21. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  22. [self setSubView];
  23. }
  24. return self;
  25. }
  26. -(void)setSubView{
  27. //bg
  28. UIView *youpaiBgView = [UIView new];
  29. [self.contentView addSubview:youpaiBgView];
  30. [youpaiBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.mas_equalTo(0);
  32. make.left.mas_equalTo(12);
  33. make.right.mas_equalTo(-12);
  34. make.bottom.mas_equalTo(-8);
  35. }];
  36. youpaiBgView.backgroundColor = LCWhiteColor;
  37. youpaiBgView.layer.cornerRadius = 10;
  38. youpaiBgView.clipsToBounds = YES;
  39. //头像
  40. UIImageView *youpaipavatarImgV = [[UIImageView alloc]init];
  41. [youpaiBgView addSubview:youpaipavatarImgV];
  42. self.youpaipavatarImgV = youpaipavatarImgV;
  43. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(12.0f);
  45. make.top.mas_equalTo(15);
  46. make.size.mas_equalTo(CGSizeMake(40, 40));;
  47. }];
  48. youpaipavatarImgV.layer.cornerRadius = 20;
  49. youpaipavatarImgV.layer.masksToBounds = YES;
  50. //昵称
  51. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  52. youpaipnicknameL.font = LCBoldFont(14);
  53. youpaipnicknameL.textColor = [UIColor whiteColor];
  54. [youpaiBgView addSubview:youpaipnicknameL];
  55. self.youpaipnicknameL = youpaipnicknameL;
  56. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(youpaipavatarImgV.mas_right).offset(8.0f);
  58. make.top.mas_equalTo(youpaipavatarImgV).offset(2.5);
  59. }];
  60. youpaipnicknameL.textColor = LZ273145Color;
  61. youpaipnicknameL.font = LCBoldFont(14);
  62. // CGFloat width = 0;
  63. // if (youpaipmodel.nickname.length>5) {
  64. // NSString *str = [youpaipmodel.nickname substringToIndex:5];
  65. // width = [LCTools widthWithString:str withFont:LCBoldFont(14)]+5;
  66. // }else{
  67. // width = [LCTools widthWithString:youpaipmodel.nickname withFont:LCBoldFont(14)]+5;
  68. // }
  69. YOUPAISexView *sexView = [[YOUPAISexView alloc] init];
  70. [youpaiBgView addSubview:sexView];
  71. self.youpaipsexView = sexView;
  72. [sexView makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(youpaipnicknameL.right).offset(@2);
  74. make.centerY.equalTo(youpaipnicknameL);
  75. make.size.mas_equalTo(CGSizeMake(30, 15));
  76. }];
  77. [sexView youpaifreloadWithSex:1 age:18];
  78. //真人图标
  79. UIImageView *personImageView = [UIImageView new];
  80. self.personImageView = personImageView;
  81. [youpaiBgView addSubview:personImageView];
  82. [personImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.equalTo(sexView.right).offset(@2);
  84. make.centerY.equalTo(sexView);
  85. make.size.mas_equalTo(CGSizeMake(37, 16));
  86. }];
  87. personImageView.image = [UIImage imageNamed:@"vqu_images_zhenrentag"];
  88. //
  89. //内容
  90. UILabel *youpaiContent = [UILabel new];
  91. self.youpaiContent = youpaiContent;
  92. [youpaiBgView addSubview:youpaiContent];
  93. [youpaiContent mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.mas_equalTo(youpaipnicknameL);
  95. make.top.mas_equalTo(youpaipnicknameL.mas_bottom).offset(4);
  96. }];
  97. self.youpaiContent.textColor = LZA3AABEColor;
  98. self.youpaiContent.font = [UIFont systemFontOfSize:12];
  99. //拷贝按钮
  100. UIButton *youpaicopyBtn = [UIButton new];
  101. [youpaiBgView addSubview:youpaicopyBtn];
  102. [youpaicopyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.mas_equalTo(youpaiContent.mas_right).offset(2);
  104. make.centerY.mas_equalTo(youpaiContent);
  105. make.size.mas_equalTo(CGSizeMake(12, 12));
  106. }];
  107. [youpaicopyBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_ZY_copy"] forState:UIControlStateNormal];
  108. [youpaicopyBtn addTarget:self action:@selector(youpaicopyBtnClick) forControlEvents:UIControlEventTouchUpInside];
  109. //注册时间
  110. UILabel *youpaiTimeLabel = [UILabel new];
  111. self.youpaiTimeLabel= youpaiTimeLabel;
  112. [youpaiBgView addSubview:youpaiTimeLabel];
  113. [youpaiTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.left.mas_equalTo(youpaipnicknameL);
  115. make.top.mas_equalTo(youpaiContent.mas_bottom).offset(6);
  116. }];
  117. youpaiTimeLabel.textColor = LZA3AABEColor;
  118. youpaiTimeLabel.font = [UIFont systemFontOfSize:12];
  119. // youpaiTimeLabel.text = @"2021-11-22";
  120. //价格
  121. UILabel *youpaiPriceLabel = [UILabel new];
  122. self.youpaiPriceLabel = youpaiPriceLabel;
  123. [youpaiBgView addSubview:youpaiPriceLabel];
  124. [youpaiPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.centerY.mas_equalTo(personImageView);
  126. make.right.mas_equalTo(-12);
  127. }];
  128. youpaiPriceLabel.textColor = LZ7C69FEColor;
  129. youpaiPriceLabel.font = LZDinFont(15);
  130. //贡献label
  131. UILabel *youpaiPriceTitleLabel = [UILabel new];
  132. [youpaiBgView addSubview:youpaiPriceTitleLabel];
  133. [youpaiPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.top.mas_equalTo(youpaiPriceLabel.mas_bottom).offset(8.5);
  135. make.right.mas_equalTo(youpaiPriceLabel);
  136. }];
  137. youpaiPriceTitleLabel.text = @"贡献(元)";
  138. youpaiPriceTitleLabel.textColor = LZ273145Color;
  139. youpaiPriceTitleLabel.font = [UIFont systemFontOfSize:12];
  140. }
  141. -(void)youpaicopyBtnClick{
  142. NSString *inviteCode = [NSString stringWithFormat:@"%@",self.model.youpaiusercode];
  143. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  144. pasteboard.string = inviteCode;
  145. [ZCHUDHelper showTitle:@"复制成功,快去粘贴吧!"];
  146. }
  147. -(void)setModel:(YOUPAIMyNetworkModel *)model{
  148. _model = model;
  149. self.personImageView.hidden = YES;
  150. self.youpaipnicknameL.text = model.youpainickname;
  151. [self.youpaipsexView youpaifreloadWithSex:model.youpaigender age:model.youpaiage];
  152. if (model.youpaiis_anchor == 1) {
  153. self.personImageView.hidden = NO;
  154. }
  155. self.youpaiContent.text = [NSString stringWithFormat:@"ID:%@",model.youpaiusercode];
  156. self.youpaiTimeLabel.text = [NSString stringWithFormat:@"注册时间:%@",model.youpaicreatetime];
  157. self.youpaiPriceLabel.text = model.youpaicontribution;
  158. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaiavatar] placeholderImage:nil];
  159. }
  160. @end