YOUPAIHRMembershipApplicationCell.m 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // YOUPAIHRMembershipApplicationCell.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRMembershipApplicationCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. @interface YOUPAIHRMembershipApplicationCell ()
  11. @property(nonatomic,strong)UIImageView *youpaipavatarImgV;
  12. @property(nonatomic,strong)UILabel * youpaipnicknameL;
  13. @property(nonatomic,strong)UIImageView *youpaipvipV;
  14. @property(nonatomic,strong)UIImageView *youpaipbadgeImgV;
  15. @property(nonatomic,strong)YOUPAILZLevelView *youpaiplevelView;
  16. @property(nonatomic,strong)UILabel *youpaipIDLabel;
  17. @property(nonatomic,strong)UILabel *youpaiptimeLabel;
  18. @end
  19. @implementation YOUPAIHRMembershipApplicationCell
  20. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  21. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  22. [self youpaifsetSubView];
  23. }
  24. return self;
  25. }
  26. -(void)youpaifsetSubView{
  27. //头像
  28. UIImageView *youpaipavatarImgV = [[UIImageView alloc]init];
  29. [self.contentView addSubview:youpaipavatarImgV];
  30. self.youpaipavatarImgV = youpaipavatarImgV;
  31. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.offset(14.0f);
  33. make.centerY.mas_equalTo(0);
  34. make.size.mas_equalTo(CGSizeMake(40, 40));;
  35. }];
  36. // youpaipavatarImgV.image = [UIImage imageNamed:@"AppIcon"];
  37. youpaipavatarImgV.layer.cornerRadius = 20;
  38. youpaipavatarImgV.layer.masksToBounds = YES;
  39. //V
  40. youpaipavatarImgV.userInteractionEnabled = YES;
  41. //昵称
  42. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  43. youpaipnicknameL.font = LCBoldFont(14);
  44. youpaipnicknameL.textColor = [UIColor whiteColor];
  45. [self.contentView addSubview:youpaipnicknameL];
  46. self.youpaipnicknameL = youpaipnicknameL;
  47. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.equalTo(youpaipavatarImgV.mas_right).offset(8.0f);
  49. make.top.offset(10.0f);
  50. make.height.offset(24.5f);
  51. }];
  52. youpaipnicknameL.text = @"傻孩子";
  53. //Vip
  54. UIImageView *youpaipvipV = [[UIImageView alloc] init];
  55. [self addSubview:youpaipvipV];
  56. self.youpaipvipV = youpaipvipV;
  57. [youpaipvipV mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  59. make.centerY.equalTo(youpaipnicknameL);
  60. }];
  61. UIImageView *youpaipbadgeImgV = [[UIImageView alloc] init];
  62. [self addSubview:youpaipbadgeImgV];
  63. self.youpaipbadgeImgV = youpaipbadgeImgV;
  64. [youpaipbadgeImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(youpaipvipV.mas_right).offset(3.0f);
  66. make.centerY.equalTo(youpaipnicknameL);
  67. }];
  68. //等级
  69. UIImageView *leveImgV = [[UIImageView alloc] init];
  70. [self addSubview:leveImgV];
  71. [leveImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.equalTo(youpaipbadgeImgV.mas_right).offset(3.0f);
  73. make.centerY.equalTo(youpaipnicknameL);
  74. }];
  75. // YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  76. // [self addSubview:youpaiplevelView];
  77. // self.youpaiplevelView = youpaiplevelView;
  78. // youpaiplevelView.hidden = YES;
  79. // [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. // make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f);
  81. // make.centerY.equalTo(youpaipnicknameL);
  82. // }];
  83. //年份月份
  84. UILabel *youpaiptimeLabel = [UILabel new];
  85. self.youpaiptimeLabel = youpaiptimeLabel;
  86. [self.contentView addSubview:youpaiptimeLabel];
  87. [youpaiptimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.right.mas_equalTo(-14);
  89. make.top.mas_equalTo(12);
  90. }];
  91. youpaiptimeLabel.text = @"2021-11-22 08:56";
  92. youpaiptimeLabel.textColor = HexColorFromRGB(0x9F9DA5);
  93. youpaiptimeLabel.font = [UIFont systemFontOfSize:11];
  94. //同意
  95. UIButton *agreeBtn = [UIButton new];
  96. [self.contentView addSubview:agreeBtn];
  97. [agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.right.mas_equalTo(-14);
  99. make.top.mas_equalTo(youpaiptimeLabel.mas_bottom).offset(10);
  100. make.size.mas_equalTo(CGSizeMake(56, 22));
  101. }];
  102. [agreeBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56, 22) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal];
  103. [agreeBtn setTitle:@"同意" forState:UIControlStateNormal];
  104. [agreeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  105. agreeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  106. agreeBtn.layer.cornerRadius = 12;
  107. agreeBtn.clipsToBounds = YES;
  108. //拒绝
  109. UIButton *RefuseBtn = [UIButton new];
  110. [self.contentView addSubview:RefuseBtn];
  111. [RefuseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.right.mas_equalTo(agreeBtn.mas_left).offset(-10);
  113. make.top.mas_equalTo(youpaiptimeLabel.mas_bottom).offset(10);
  114. make.size.mas_equalTo(CGSizeMake(56, 22));
  115. }];
  116. [RefuseBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56, 22) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:1] forState:UIControlStateNormal];
  117. [RefuseBtn setTitle:@"拒绝" forState:UIControlStateNormal];
  118. [RefuseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  119. RefuseBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  120. RefuseBtn.layer.cornerRadius = 12;
  121. RefuseBtn.clipsToBounds = YES;
  122. //id
  123. UILabel *youpaipIDLabel = [UILabel new];
  124. self.youpaipIDLabel = youpaipIDLabel;
  125. [self.contentView addSubview:youpaipIDLabel];
  126. [youpaipIDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.left.mas_equalTo(youpaipavatarImgV.mas_right).offset(8);
  128. make.top.mas_equalTo(youpaipnicknameL.mas_bottom).offset(6);
  129. }];
  130. youpaipIDLabel.text = @"花舞号:54332";
  131. youpaipIDLabel.textColor = HexColorFromRGB(0x9F9DA5);
  132. youpaipIDLabel.font = [UIFont systemFontOfSize:12];
  133. //分割线
  134. UIView *lineView = [UIView new];
  135. [self.contentView addSubview:lineView];
  136. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.mas_equalTo(14);
  138. make.right.mas_equalTo(-14);
  139. make.bottom.mas_equalTo(0);
  140. make.height.mas_equalTo(0.5);
  141. }];
  142. lineView.backgroundColor = HexColorFromRGB(0x28262D);
  143. //事件
  144. [agreeBtn addTarget:self action:@selector(youpaifagreeBtnClick) forControlEvents:UIControlEventTouchUpInside];
  145. [RefuseBtn addTarget:self action:@selector(youpaifRefuseBtnClick) forControlEvents:UIControlEventTouchUpInside];
  146. }
  147. //同意
  148. -(void)youpaifagreeBtnClick{
  149. if (self.youpaipagreeBlock) {
  150. self.youpaipagreeBlock(self.youpaipmodel);
  151. }
  152. }
  153. //拒绝
  154. -(void)youpaifRefuseBtnClick{
  155. if (self.youpaiprefuseBlock) {
  156. self.youpaiprefuseBlock(self.youpaipmodel);
  157. }
  158. }
  159. -(void)setYoupaipmodel:(YOUPAIHRMembershipApplicationModel *)model{
  160. _youpaipmodel = model;
  161. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipavatar] placeholderImage:nil];
  162. self.youpaipnicknameL.text = model.youpaipnickname;
  163. self.youpaipIDLabel.text = [NSString stringWithFormat:@"花舞号:%@",model.youpaipusercode];
  164. self.youpaiptimeLabel.text = model.youpaipcreate_date;
  165. CGFloat width = 0;
  166. if (model.youpaipnickname.length>5) {
  167. NSString *str = [model.youpaipnickname substringToIndex:5];
  168. width = [LCTools widthWithString:str withFont:LCBoldFont(14)]+5;
  169. }else{
  170. width = [LCTools widthWithString:model.youpaipnickname withFont:LCBoldFont(14)]+5;
  171. }
  172. [self.youpaipnicknameL mas_remakeConstraints:^(MASConstraintMaker *make) {
  173. make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(8.0f);
  174. make.top.offset(10);
  175. make.height.offset(24.5f);
  176. }];
  177. UIView *frontV;
  178. self.youpaiplevelView.hidden = NO;
  179. [self.youpaiplevelView youpaifreloadWithIcon:model.youpaipgrade.youpaipimg1 iconWidth:model.youpaipgrade.youpaipicon_width bgImg:model.youpaipgrade.youpaipimg2 bgImgWidth:model.youpaipgrade.youpaipicon1_width levelName:model.youpaipgrade.youpaipgrade_name level:model.youpaipgrade.youpaipgrade];
  180. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  181. if (frontV == nil) {
  182. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  183. }else{
  184. make.left.equalTo(frontV.mas_right).offset(3.0f);
  185. }
  186. make.centerY.equalTo(self.youpaipnicknameL);
  187. make.size.mas_offset(self.youpaiplevelView.mj_size);
  188. }];
  189. frontV = self.youpaiplevelView;
  190. if (self.youpaipmodel.youpaipvip_icon.length != 0) {
  191. self.youpaipvipV.hidden = NO;
  192. [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipvip_icon]];
  193. [self.youpaipvipV mas_remakeConstraints:^(MASConstraintMaker *make) {
  194. if (frontV == nil) {
  195. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  196. }else{
  197. make.left.equalTo(frontV.mas_right).offset(3.0f);
  198. }
  199. make.centerY.equalTo(self.youpaipnicknameL);
  200. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  201. }];
  202. frontV = self.youpaipvipV;
  203. }
  204. if (self.youpaipmodel.youpaiprankInfo.youpaipimg.length != 0) {
  205. self.youpaipbadgeImgV.hidden = NO;
  206. [self.youpaipbadgeImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaiprankInfo.youpaipimg]];
  207. [self.youpaipbadgeImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
  208. if (frontV == nil) {
  209. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  210. }else{
  211. make.left.equalTo(frontV.mas_right).offset(3.0f);
  212. }
  213. make.centerY.equalTo(self.youpaipnicknameL);
  214. make.size.mas_offset(CGSizeMake(20, 17.0f));
  215. }];
  216. }
  217. }
  218. @end