123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- //
- // DRUserInfoView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/22.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRUserInfoView.h"
- @interface DRUserInfoView()
- @property (nonatomic, strong) UIImageView *iconView; //用户头像
- @property (nonatomic, strong) UILabel *nickName; //用户昵称
- @property (nonatomic, strong) UILabel *unLonginLabel;//未登录文字
- @property (nonatomic, strong) UILabel *unLoginDes;//未登录描述
- @end
- @implementation DRUserInfoView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self addSubview:self.iconView];
- [self addSubview:self.nickName];
- [self addSubview:self.unLonginLabel];
- [self addSubview:self.unLoginDes];
- // [self addSubview:self.vipGuideLabel];
- ;
-
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_offset(28);
- make.centerY.mas_equalTo(self);
- make.width.height.mas_equalTo(60);
- }];
- [self.unLonginLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.iconView.mas_right).mas_offset(14);
- make.top.mas_equalTo(self.iconView.mas_top).mas_offset(10);
- }];
-
- [self.unLoginDes mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.unLonginLabel);
- make.bottom.mas_equalTo(self.iconView.mas_bottom).mas_offset(-10);
- }];
-
- [self.nickName mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.iconView.mas_top).mas_offset(8);
- make.left.mas_equalTo(self.iconView.mas_right).mas_offset(14);
- make.width.mas_lessThanOrEqualTo(Fitsize(150));
- }];
-
-
-
- // [self.vipGuideLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(self.nickName);
- // make.width.mas_equalTo(250);
- // make.top.mas_equalTo(self.nickName.mas_bottom).mas_offset(10);
- // }];
-
-
- [self setIsLogInView];
-
-
- }
- -(void)clickWithDrawButton {
- if (self.clickDraw) {
- self.clickDraw();
- }
- }
- - (void)setUserInfo:(DRUserInfo *)userInfo {
- _userInfo = userInfo;
-
- [self setIsLogInView];
-
- self.nickName.text = userInfo.name;
- [self.iconView sd_setImageWithURL:[NSURL URLWithString:userInfo.img] placeholderImage:[UIImage imageNamed:@"login"]];
-
-
- }
- - (void)setIsLogInView {
-
- self.unLonginLabel.hidden = YES;
- self.unLoginDes.hidden = YES;
- self.nickName.hidden = NO;
- self.iconView.image = [UIImage imageNamed:@"login"];
- }
- - (void)setNologInView {
-
- self.unLonginLabel.hidden = NO;
- self.unLoginDes.hidden = NO;
- self.nickName.hidden = YES;
- self.iconView.image = [UIImage imageNamed:@"unlogin"];
- }
- #pragma mark ----
- /**
- 点击登录
- */
- - (void)goToLoginPage {
- if (self.loginClick) {
- self.loginClick();
- }
- }
- - (void)settingAction {
- if (self.settingClick) {
- self.settingClick();
- }
- }
- - (void)tapTypeIcon {
- if (self.tapUserType) {
- self.tapUserType();
- }
- }
- - (void)copyCodeAction {
- UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
- if (_userInfo.invite_code) {
- pastboard.string = _userInfo.invite_code;
- [MBProgressHUD showMessage:@"复制成功"];
- }else {
- [MBProgressHUD showMessage:@"复制失败"];
- }
-
- }
- - (void)gotoMyfansAction {
- if (self.gotoMyfans) {
- self.gotoMyfans();
- }
- }
- - (void)gotoMyIncommeAction {
- if (self.gotoMyIncome) {
- self.gotoMyIncome();
- }
- }
- #pragma mark ---
- - (UIImageView *)iconView {
- if (!_iconView) {
- _iconView = [[UIImageView alloc] init];
- _iconView.layer.cornerRadius = 30;
- _iconView.layer.masksToBounds = YES;
- NSString *imgStr = [AccountTool isLogin] ? @"login" : @"unlogin";
- _iconView.image = [UIImage imageNamed:imgStr];
- _iconView.userInteractionEnabled = YES;
- _iconView.layer.borderWidth = 2;
- _iconView.layer.borderColor = [UIColor whiteColor].CGColor;
- UITapGestureRecognizer *settingTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(settingAction)];
- [_iconView addGestureRecognizer:settingTap];
- }
- return _iconView;
- }
- - (UILabel *)nickName {
- if (!_nickName) {
- _nickName = [[UILabel alloc] init];
- _nickName.font = [UIFont systemFontOfSize:16];
- _nickName.textColor = [UIColor whiteColor];
- _nickName.userInteractionEnabled = YES;
- _nickName.text = @"昵称加载中...";
- UITapGestureRecognizer *settingTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(settingAction)];
- [_nickName addGestureRecognizer:settingTap];
- }
- return _nickName;
- }
- - (UILabel *)unLonginLabel {
- if (!_unLonginLabel) {
- _unLonginLabel = [[UILabel alloc] init];
- _unLonginLabel.text = @"点击登录";
- _unLonginLabel.textColor = [UIColor whiteColor];
- _unLonginLabel.font = [UIFont systemFontOfSize:15];
- _unLonginLabel.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToLoginPage)];
- [_unLonginLabel addGestureRecognizer:tap];
- }
- return _unLonginLabel;
- }
- - (UILabel *)unLoginDes {
- if (!_unLoginDes) {
- _unLoginDes = [[UILabel alloc] init];
- _unLoginDes.text = @"登录后可以领取更多优惠券哦";
- _unLoginDes.textColor = [UIColor whiteColor];
- _unLoginDes.font = [UIFont systemFontOfSize:13];
- _unLoginDes.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToLoginPage)];
- [_unLoginDes addGestureRecognizer:tap];
- }
- return _unLoginDes;
- }
- @end
|