YOUPAIHRGuildCenterDetailHeaderView.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. //
  2. // YOUPAIHRGuildCenterDetailHeaderView.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/4.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRGuildCenterDetailHeaderView.h"
  9. #import "YOUPAIHRGuildCenterBtn.h"
  10. #import "YOUPAIHRChatRoomGuildBalanceVC.h"
  11. #import "YOUPAIHRGuildDetailVC.h"
  12. #import "YOUPAIHRGuildCenterSearchVC.h"
  13. @interface YOUPAIHRGuildCenterDetailHeaderView ()
  14. @property(nonatomic,strong)UIImageView *youpaipavatarImgV;
  15. @property(nonatomic,strong)UIImageView *youpaipiconImageView;
  16. @property(nonatomic,strong)UILabel *youpaipnameLabel;
  17. @property(nonatomic,strong)UIButton *youpaipIDBtn;
  18. @property(nonatomic,strong)UILabel *youpaipcontentLabel;
  19. @property(nonatomic,strong)UILabel *youpaiptitleLabel;
  20. @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaipTotalBtn; // 总收益
  21. @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaiptodayRoomBtn; // 今天房间分成
  22. @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaiptodayGuildBtn; // 今天公会分成
  23. @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaipwithdrawBtn; // 余额/提现
  24. @property(nonatomic,strong)YOUPAIHRGuildCenterDetailModel *youpaipmodel;
  25. @property(nonatomic,strong)UIView *youpaipmoreView;
  26. @end
  27. @implementation YOUPAIHRGuildCenterDetailHeaderView
  28. -(instancetype)initWithFrame:(CGRect)frame{
  29. if (self = [super initWithFrame:frame]) {
  30. [self youpaifsetSubView];
  31. }
  32. return self;
  33. }
  34. -(void)youpaifsetSubView{
  35. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  36. self.youpaipavatarImgV = youpaipavatarImgV;
  37. [self addSubview:youpaipavatarImgV];
  38. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  39. youpaipavatarImgV.clipsToBounds = YES;
  40. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.mas_equalTo(0);
  42. make.top.mas_equalTo(0);
  43. make.right.mas_equalTo(0);
  44. make.height.mas_equalTo(210);
  45. }];
  46. youpaipavatarImgV.image = [UIImage imageNamed:@"vqu_images_chatroom_bg"];
  47. // [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[LCSaveModel getUserModel].userinfo.avatar]];
  48. UIView *avatarColorV = [[UIView alloc] init];
  49. [youpaipavatarImgV addSubview:avatarColorV];
  50. [avatarColorV mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.edges.mas_equalTo(0);
  52. }];
  53. avatarColorV.backgroundColor = [HexColorFromRGB(0x1C1D23) colorWithAlphaComponent:0.9f];
  54. //头像
  55. UIImageView *youpaipiconImageView = [UIImageView new];
  56. self.youpaipiconImageView = youpaipiconImageView;
  57. [self addSubview:youpaipiconImageView];
  58. [youpaipiconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.mas_equalTo(18);
  60. make.centerX.mas_equalTo(0);
  61. make.size.mas_equalTo(CGSizeMake(84, 84));
  62. }];
  63. youpaipiconImageView.contentMode = UIViewContentModeScaleAspectFill;
  64. youpaipiconImageView.layer.cornerRadius = 84/2;
  65. youpaipiconImageView.layer.masksToBounds = YES;
  66. // youpaipiconImageView.image = [UIImage imageNamed:@"AppIcon"];
  67. //公会名称
  68. UILabel *youpaipnameLabel = [UILabel new];
  69. self.youpaipnameLabel = youpaipnameLabel;
  70. [self addSubview:youpaipnameLabel];
  71. [youpaipnameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.centerX.mas_equalTo(youpaipiconImageView);
  73. make.top.mas_equalTo(youpaipiconImageView.mas_bottom).offset(21.5);
  74. }];
  75. youpaipnameLabel.font = LCBoldFont(17);
  76. youpaipnameLabel.textColor = [UIColor whiteColor];
  77. //公会ID
  78. UIButton *youpaipIDBtn = [UIButton new];
  79. self.youpaipIDBtn = youpaipIDBtn;
  80. [self addSubview:youpaipIDBtn];
  81. [youpaipIDBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.centerX.mas_equalTo(0);
  83. make.top.mas_equalTo(youpaipnameLabel.mas_bottom).offset(9);
  84. }];
  85. [youpaipIDBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  86. youpaipIDBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  87. [youpaipIDBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_copy"] forState:UIControlStateNormal];
  88. [youpaipIDBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
  89. //内容
  90. UILabel *contentLabel = [UILabel new];
  91. self.youpaipcontentLabel = contentLabel;
  92. [self addSubview:contentLabel];
  93. [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.mas_equalTo(14);
  95. make.right.mas_equalTo(-14);
  96. make.top.mas_equalTo(youpaipIDBtn.mas_bottom).offset(0);
  97. make.height.mas_equalTo(60);
  98. }];
  99. contentLabel.textColor = HexColorFromRGB(0x9F9DA5);
  100. contentLabel.font = [UIFont systemFontOfSize:12];
  101. contentLabel.numberOfLines = 3;
  102. contentLabel.textAlignment = NSTextAlignmentCenter;
  103. contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  104. //下面收益|分成|提现
  105. UIView *youpaipmoreView = [UIView new];
  106. self.youpaipmoreView = youpaipmoreView;
  107. [self addSubview:youpaipmoreView];
  108. [youpaipmoreView mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.top.mas_equalTo(contentLabel.mas_bottom).offset(5);
  110. make.left.mas_equalTo(12);
  111. make.right.mas_equalTo(-12);
  112. make.height.mas_equalTo(70);
  113. }];
  114. youpaipmoreView.backgroundColor = HexColorFromRGBA(0x4F4B5B, 0.4);
  115. youpaipmoreView.layer.cornerRadius = 4;
  116. youpaipmoreView.layer.masksToBounds = YES;
  117. youpaipmoreView.hidden = YES;
  118. UIView *countBtnBgV = [[UIView alloc] init];
  119. [youpaipmoreView addSubview:countBtnBgV];
  120. [countBtnBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.offset(0);
  122. make.right.offset(0);
  123. make.centerY.equalTo(0);
  124. make.height.offset(40.0f);
  125. }];
  126. //4个
  127. NSArray *btnContents = @[
  128. @{@"title":LCStr(word12),@"count":@"0"},//今日总收益
  129. @{@"title":LCStr(word13),@"count":@"0"},//今日房间分成
  130. @{@"title":LCStr(word14),@"count":@"0"},//今日公会分成
  131. @{@"title":LCStr(word15),@"count":@"0"},//公会分成收益
  132. ];
  133. NSMutableArray *btns = [NSMutableArray array];
  134. for (NSInteger i = 0; i < btnContents.count; i ++) {
  135. NSDictionary *dict = btnContents[i];
  136. YOUPAIHRGuildCenterBtn *badgeBtn = [[YOUPAIHRGuildCenterBtn alloc] init];
  137. badgeBtn.youpaipcount = dict[@"count"] ;
  138. badgeBtn.youpaiptitleStr = dict[@"title"];
  139. badgeBtn.tag = 6000+i;
  140. [countBtnBgV addSubview:badgeBtn];
  141. [badgeBtn addTarget:self action:@selector(youpaifguildyoupaifcenterBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  142. [btns addObject:badgeBtn];
  143. if (i == 0) {
  144. self.youpaipTotalBtn = badgeBtn;
  145. }else if (i == 1){
  146. self.youpaiptodayRoomBtn = badgeBtn;
  147. }else if (i == 2){
  148. self.youpaiptodayGuildBtn = badgeBtn;
  149. }else{
  150. self.youpaipwithdrawBtn = badgeBtn;
  151. }
  152. }
  153. [btns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
  154. [btns mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.top.bottom.offset(0.0f);
  156. }];
  157. for (NSInteger i = 1; i < btns.count; i ++) {
  158. YOUPAIHRGuildCenterBtn *badgeBtn = btns[i];
  159. UIView *line = [[UIView alloc] init];
  160. line.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.22f];
  161. [countBtnBgV addSubview:line];
  162. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.right.equalTo(badgeBtn.mas_left);
  164. make.centerY.equalTo(badgeBtn);
  165. make.size.mas_offset(CGSizeMake(1.0f, 10.0f));
  166. }];
  167. }
  168. UIView *bottomView = [[UIView alloc]init];
  169. [self addSubview:bottomView];
  170. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.left.mas_equalTo(0);
  172. make.right.mas_equalTo(0);
  173. make.top.mas_equalTo(youpaipmoreView.mas_bottom);
  174. make.height.mas_equalTo(69);
  175. }];
  176. //centerView
  177. UIView *centerView = [UIView new];
  178. [bottomView addSubview:centerView];
  179. [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.center.mas_equalTo(0);
  181. make.top.mas_equalTo(0);
  182. make.bottom.mas_equalTo(0);
  183. make.width.mas_equalTo(250);
  184. }];
  185. //title
  186. UILabel *titleLabel = [UILabel new];
  187. self.youpaiptitleLabel = titleLabel;
  188. [centerView addSubview:titleLabel];
  189. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.centerY.mas_equalTo(0);
  191. make.centerX.mas_equalTo(0);
  192. }];
  193. titleLabel.textColor = [UIColor whiteColor];
  194. //leftImage
  195. UIImageView *leftImage = [UIImageView new];
  196. [centerView addSubview:leftImage];
  197. [leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
  198. make.right.mas_equalTo(titleLabel.mas_left).offset(-6);
  199. make.centerY.mas_equalTo(0);
  200. make.size.mas_equalTo(CGSizeMake(28.5, 5));
  201. }];
  202. leftImage.image = [UIImage imageNamed:@"vqu_images_guild_line_left"];
  203. //rightImage
  204. UIImageView *rightImage = [UIImageView new];
  205. [centerView addSubview:rightImage];
  206. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  207. make.left.mas_equalTo(titleLabel.mas_right).offset(-2);
  208. make.centerY.mas_equalTo(0);
  209. make.size.mas_equalTo(CGSizeMake(28.5, 5));
  210. }];
  211. rightImage.image = [UIImage imageNamed:@"vqu_images_guild_line_right"];
  212. //事件
  213. [youpaipIDBtn addTarget:self action:@selector(youpaifIDBtnClick) forControlEvents:UIControlEventTouchUpInside];
  214. }
  215. -(void)youpaifIDBtnClick{
  216. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  217. pasteboard.string = [NSString stringWithFormat:@"%ld",self.youpaipmodel.guild_number];
  218. [ZCHUDHelper showTitle:@"复制成功"];
  219. }
  220. -(void)setYoupaipguild:(NSInteger)youpaipguild{
  221. _youpaipguild = youpaipguild;
  222. if (youpaipguild == 2) {
  223. self.youpaipmoreView.hidden = NO;
  224. [self.youpaipmoreView mas_remakeConstraints:^(MASConstraintMaker *make) {
  225. make.top.mas_equalTo(self.youpaipcontentLabel.mas_bottom).offset(5);
  226. make.left.mas_equalTo(12);
  227. make.right.mas_equalTo(-12);
  228. make.height.mas_equalTo(70);
  229. }];
  230. }else{
  231. self.youpaipmoreView.hidden = YES;
  232. [self.youpaipmoreView mas_remakeConstraints:^(MASConstraintMaker *make) {
  233. make.top.mas_equalTo(self.youpaipcontentLabel.mas_bottom).offset(5);
  234. make.left.mas_equalTo(12);
  235. make.right.mas_equalTo(-12);
  236. make.height.mas_equalTo(0);
  237. }];
  238. }
  239. }
  240. -(void)youpaifreloadHeaderViewWith:(YOUPAIHRGuildCenterDetailModel *)model{
  241. self.youpaipmodel = model;
  242. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.img] placeholderImage:nil];
  243. [self.youpaipiconImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.img] placeholderImage:nil];
  244. self.youpaipnameLabel.text = model.name;
  245. [self.youpaipIDBtn setTitle:[NSString stringWithFormat:@"公会ID:%ld",(long)model.guild_number] forState:UIControlStateNormal];
  246. self.youpaipcontentLabel.text = model.des;
  247. self.youpaipTotalBtn.youpaipcount = model.toDay;
  248. self.youpaiptodayRoomBtn.youpaipcount =model.toDayRoom ;
  249. self.youpaiptodayGuildBtn.youpaipcount =model.toDayGuild;
  250. self.youpaipwithdrawBtn.youpaipcount =model.money;
  251. self.youpaiptitleLabel.text = [NSString stringWithFormat:@"公会成员(%ld)",(long)model.memberNumber];
  252. }
  253. -(void)youpaifguildyoupaifcenterBtnClick:(UIButton*)sender{
  254. if (sender.tag == 6003) {
  255. if (self.youpaipguild == 2) {
  256. YOUPAIHRGuildDetailVC *vc = [YOUPAIHRGuildDetailVC new];
  257. [[LCTools getCurrentVC].navigationController pushViewController:vc animated:YES];
  258. }else{
  259. YOUPAIHRGuildCenterSearchVC *vc = [YOUPAIHRGuildCenterSearchVC new];
  260. [[LCTools getCurrentVC].navigationController pushViewController:vc animated:YES];
  261. }
  262. }
  263. }
  264. @end