// // HSQFansSuperView.m // YouHuiProject // // Created by 小花 on 2018/8/14. // Copyright © 2018年 kuxuan. All rights reserved. // #import "HSQFansSuperView.h" @interface HSQFansSuperView () @property (nonatomic, strong) UIView *rectView; @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UILabel *nickName; @property (nonatomic, strong) UILabel *dateLabel; @end @implementation HSQFansSuperView - (instancetype)initWithFrame:(CGRect)frame model:(HSQChildFansModel *)model{ self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor clearColor]; [self initSubViews]; [self loadDataWithModel:model]; } return self; } - (void)initSubViews { UIView *alphaView = [[UIView alloc] initWithFrame:self.bounds]; [self addSubview:alphaView]; self.rectView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FITSIZE(272), FITSIZE(139))]; self.rectView.backgroundColor = [UIColor whiteColor]; self.rectView.centerX = self.width/2; self.rectView.centerY = self.height/2-FITSIZE(30); self.rectView.layer.cornerRadius = Fitsize(4); [self addSubview:self.rectView]; self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, FITSIZE(70), FITSIZE(70))]; self.iconView.layer.cornerRadius = FITSIZE(35); self.iconView.clipsToBounds = YES; self.iconView.backgroundColor = [UIColor yhGrayColor]; [self.rectView addSubview:self.iconView]; self.iconView.centerX = self.rectView.width/2; self.iconView.layer.borderWidth = 1; self.iconView.layer.borderColor = [UIColor whiteColor].CGColor; self.iconView.centerY = 0; self.nickName = [[UILabel alloc] initWithFrame:CGRectMake(0, self.iconView.bottom+FITSIZE(20), self.rectView.width, FITSIZE(20))]; self.nickName.font = [UIFont systemFontOfSize:FITSIZE(18)]; self.nickName.textColor = [UIColor YHColorWithHex:0x383838]; self.nickName.textAlignment = NSTextAlignmentCenter; self.nickName.text = @"加载中..."; [self.rectView addSubview:self.nickName]; self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.nickName.bottom+Fitsize(15), self.rectView.width, Fitsize(15))]; self.dateLabel.textColor = [UIColor YHColorWithHex:0x666666]; self.dateLabel.textAlignment = NSTextAlignmentCenter; self.dateLabel.text = @"加载中..."; [self.rectView addSubview:self.dateLabel]; UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(0, self.rectView.bottom+Fitsize(30), 40, 40)]; close.centerX = self.width/2; close.userInteractionEnabled = NO; [close setImage:[UIImage imageNamed:@"close_share"] forState:UIControlStateNormal]; [self addSubview:close]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDismiss)]; [alphaView addGestureRecognizer:tap]; } - (void)loadDataWithModel:(HSQChildFansModel *)model { NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/inviteInfo",BaseURL]; NSDictionary *para = @{@"parent_user_id":model.parent_user_id, @"user_id":model.user_id }; [HSQHttp post:url params:para success:^(id json) { NSString *img = json[@"img"]; [self.iconView sd_setImageWithURL:[NSURL URLWithString:img]]; self.nickName.text = json[@"name"]; self.dateLabel.text = [NSString stringWithFormat:@"邀请时间:%@",json[@"inviteTime"]]; } failure:^(NSError *error) { }]; } - (void)tapDismiss { if (self.tapDismissBlock) { self.tapDismissBlock(); } } @end