口袋优选

KBFansHeaderView.m 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // KBFansHeaderView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBFansHeaderView.h"
  9. @interface KBFansHeaderView()
  10. @property(nonatomic,strong)UIView *content;
  11. @property(nonatomic,strong)UILabel *title;
  12. @property(nonatomic,strong)UILabel *fansCount;
  13. @property(nonatomic,strong)UILabel *SVip;
  14. @property(nonatomic,strong)UILabel *vip;
  15. @end
  16. @interface KBFansHeaderView ()
  17. @end
  18. @implementation KBFansHeaderView
  19. - (instancetype)initWithFrame:(CGRect)frame {
  20. self = [super initWithFrame:frame];
  21. if (self) {
  22. self.backgroundColor = [UIColor yhGrayColor];
  23. self.layer.cornerRadius = 6;
  24. [self initSubViews];
  25. [self request];
  26. }
  27. return self;
  28. }
  29. -(void)request{
  30. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/fansNum",BaseURL];
  31. [KBHttp post:url params:nil success:^(id json) {
  32. if (json[@"data"]) {
  33. self.fansCount.text =[NSString stringWithFormat:@"%@",json[@"data"][@"allNum"]];
  34. self.SVip.text =[NSString stringWithFormat:@"直属粉丝:%@",json[@"data"][@"firstNum"]];
  35. self.vip.text =[NSString stringWithFormat:@"推荐粉丝:%@",json[@"data"][@"secondNum"]];
  36. }
  37. } failure:^(NSError *error) {
  38. }];
  39. }
  40. - (void)initSubViews {
  41. self.content= [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.width-20, self.height-20)];
  42. self.content.backgroundColor = [UIColor changeColor];
  43. [self addSubview:self.content];
  44. _title= [[UILabel alloc] initWithFrame:CGRectMake(0, 15, self.content.width, 20)];
  45. self.title.font = [UIFont systemFontOfSize:12];
  46. self.title.textColor = [UIColor whiteColor];
  47. self.title.text = @"粉丝数";
  48. self.title.centerX = self.width/2;
  49. self.title.textAlignment = NSTextAlignmentCenter;
  50. [self.content addSubview:self.title];
  51. self.fansCount= [[UILabel alloc] initWithFrame:CGRectMake(0, self.title.bottom+5, self.content.width, 40)];
  52. self.fansCount.textColor = [UIColor whiteColor];
  53. self.fansCount.font = [UIFont systemFontOfSize:32];
  54. self.fansCount.textAlignment = NSTextAlignmentCenter;
  55. self.fansCount.text = @"----";
  56. [self.content addSubview:self.fansCount];
  57. self.SVip= [[UILabel alloc] initWithFrame:CGRectMake(10, self.content.height-17-20,self.content.width/2, 20)];
  58. self.SVip.font = [UIFont systemFontOfSize:12];
  59. self.SVip.textColor = [UIColor whiteColor];
  60. self.SVip.text = @"直属粉丝:--";
  61. [self.content addSubview:self.SVip];
  62. self.vip= [[UILabel alloc] initWithFrame:CGRectMake(self.SVip.right, self.SVip.top, self.content.width/2-20, 20)];
  63. self.vip.font = [UIFont systemFontOfSize:12];
  64. self.vip.textAlignment = NSTextAlignmentRight;
  65. self.vip.textColor = [UIColor whiteColor];
  66. self.vip.text = @"推荐粉丝:--";
  67. [self.content addSubview:self.vip];
  68. }
  69. @end