猎豆优选

LDFansSuperView.m 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // LDFansSuperView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/8/14.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDFansSuperView.h"
  9. @interface LDFansSuperView ()
  10. @property (nonatomic, strong) UIView *rectView;
  11. @property (nonatomic, strong) UIImageView *iconView;
  12. @property (nonatomic, strong) UILabel *nickName;
  13. @property (nonatomic, strong) UILabel *dateLabel;
  14. @end
  15. @implementation LDFansSuperView
  16. - (instancetype)initWithFrame:(CGRect)frame model:(LDChildFansModel *)model{
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = [UIColor clearColor];
  20. [self initSubViews];
  21. [self loadDataWithModel:model];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. UIView *alphaView = [[UIView alloc] initWithFrame:self.bounds];
  27. [self addSubview:alphaView];
  28. self.rectView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FITSIZE(272), FITSIZE(139))];
  29. self.rectView.backgroundColor = [UIColor whiteColor];
  30. self.rectView.centerX = self.width/2;
  31. self.rectView.centerY = self.height/2-FITSIZE(30);
  32. self.rectView.layer.cornerRadius = Fitsize(4);
  33. [self addSubview:self.rectView];
  34. self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, FITSIZE(70), FITSIZE(70))];
  35. self.iconView.layer.cornerRadius = FITSIZE(35);
  36. self.iconView.clipsToBounds = YES;
  37. self.iconView.backgroundColor = [UIColor yhGrayColor];
  38. [self.rectView addSubview:self.iconView];
  39. self.iconView.centerX = self.rectView.width/2;
  40. self.iconView.layer.borderWidth = 1;
  41. self.iconView.layer.borderColor = [UIColor whiteColor].CGColor;
  42. self.iconView.centerY = 0;
  43. self.nickName = [[UILabel alloc] initWithFrame:CGRectMake(0, self.iconView.bottom+FITSIZE(20), self.rectView.width, FITSIZE(20))];
  44. self.nickName.font = [UIFont systemFontOfSize:FITSIZE(18)];
  45. self.nickName.textColor = [UIColor YHColorWithHex:0x383838];
  46. self.nickName.textAlignment = NSTextAlignmentCenter;
  47. self.nickName.text = @"加载中...";
  48. [self.rectView addSubview:self.nickName];
  49. self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.nickName.bottom+Fitsize(15), self.rectView.width, Fitsize(15))];
  50. self.dateLabel.textColor = [UIColor YHColorWithHex:0x666666];
  51. self.dateLabel.textAlignment = NSTextAlignmentCenter;
  52. self.dateLabel.text = @"加载中...";
  53. [self.rectView addSubview:self.dateLabel];
  54. UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(0, self.rectView.bottom+Fitsize(30), 40, 40)];
  55. close.centerX = self.width/2;
  56. close.userInteractionEnabled = NO;
  57. [close setImage:[UIImage imageNamed:@"close_share"] forState:UIControlStateNormal];
  58. [self addSubview:close];
  59. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDismiss)];
  60. [alphaView addGestureRecognizer:tap];
  61. }
  62. - (void)loadDataWithModel:(LDChildFansModel *)model {
  63. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/inviteInfo",BaseURL];
  64. NSDictionary *para = @{@"parent_user_id":model.parent_user_id,
  65. @"user_id":model.user_id
  66. };
  67. [LDHttp post:url params:para success:^(id json) {
  68. NSString *img = json[@"img"];
  69. [self.iconView sd_setImageWithURL:[NSURL URLWithString:img]];
  70. self.nickName.text = json[@"name"];
  71. self.dateLabel.text = [NSString stringWithFormat:@"邀请时间:%@",json[@"inviteTime"]];
  72. } failure:^(NSError *error) {
  73. }];
  74. }
  75. - (void)tapDismiss {
  76. if (self.tapDismissBlock) {
  77. self.tapDismissBlock();
  78. }
  79. }
  80. @end