IVTMeUserView.m 23.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
//
//  IVTMeUserView.m
//  IVTMeLive
//
//  Created by XRG on 16/5/13.
//  Copyright © 2016年 Joky. All rights reserved.
//

#import "IVTMeUserView.h"
#import "Masonry.h"
#import "UIColor+IVTMeColor.h"
#import "UIFont+IVTMeFont.h"
#import "AppDelegate.h"
#import "IVTKSYLiveShowViewController.h"
#import "NameSexLevelView.h"
static IVTMeUserView *instance = nil;

@interface IVTMeUserView()<UIActionSheetDelegate,attentionClickDelegate>
{
    UIImageView *bgImageView;
    
    UIButton *close;
    UIButton *managementButton;
    UILabel *miJiaNum;

    UIImageView *backGround;
    UIImageView *userIcon;
    UILabel *name;
    UIImageView *sex;
    UIImageView *grade;
    UILabel *lelveNum;
    UILabel *signatureLabel;
    UIImageView *devote;//贡献最多
    UIButton *report;
    UIView* lineView_H1;
    UIView* lineView_H2;
    UIView* lineView_V1;
    UIView* lineView_V2;
    UILabel *fansNum;//粉丝数
    UILabel *attentionNum;//关注
    UILabel *giftNum;//送出礼物
    UILabel *miTang;//蜜糖数
    UILabel * fansNumLabel; //  粉丝label
    

    UIButton *follow;
    UIButton *message;
    UIButton *main;
    NameSexLevelView *nameSexLevelView;

}

@end

@implementation IVTMeUserView

#pragma mark - 初始化视图  (280,320)
+ (IVTMeUserView *)sharedInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc] init];
        [instance setupSubViews];
    });
    return instance;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [super allocWithZone:zone];
    });
    return instance;
}


- (void)setupSubViews{
    self.frame = [[UIScreen mainScreen] bounds];
    __unsafe_unretained typeof (self) wself = self;

    /**
     *  背景灰色
     */
    bgImageView = [[UIImageView alloc]init];
    bgImageView.frame = self.bounds;
    bgImageView.backgroundColor = [UIColor blackColor];
    bgImageView.alpha = 0.7f;
    bgImageView.userInteractionEnabled = YES;

    [self addSubview:bgImageView];

    backGround = [[UIImageView alloc]initWithFrame:CGRectMake(30, (kScreenHeight - 270)/2, kScreenWidth - 60, 280)];

    backGround.image = [UIImage imageNamed:@"用户详情框--背景"];
    backGround.userInteractionEnabled  = YES;
    [self addSubview:backGround];
    
    managementButton = [UIButton buttonWithType: UIButtonTypeCustom];
    [managementButton addTarget:self action:@selector(managementClick:) forControlEvents:UIControlEventTouchUpInside];
    [backGround addSubview:managementButton];
    [managementButton setTitle:@"管理" forState:UIControlStateNormal];
    [managementButton setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    managementButton.titleLabel.font =[UIFont YXFontOfSize:13];
    [managementButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backGround.mas_top).with.offset(12);
        make.left.equalTo(backGround.mas_left).with.offset(15);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    
    userIcon = [[UIImageView alloc]init];
    userIcon.image = [UIImage imageNamed:@"用户详情--头像"];
    userIcon.clipsToBounds = YES;
    userIcon.layer.cornerRadius = 70/2;
    [backGround addSubview:userIcon];
    [userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(70, 70));
        make.centerX.equalTo(backGround);
        make.top.equalTo(backGround.mas_top).with.offset(-15);
    }];
    
    close  =[UIButton new];
    [close setImage:[UIImage imageNamed:@"用户详情--关闭"] forState:UIControlStateNormal];
    close.enabled  =YES;
    [close addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
    [backGround addSubview:close];
    [close mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backGround.mas_top).with.offset(12);
        make.right.equalTo(backGround.mas_right).with.offset(-15);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    
    nameSexLevelView = [[NameSexLevelView alloc]init];
    nameSexLevelView.userNickNameColor = UIColorFromRGBAlphaHex(0x343434, 1.0);
    [backGround addSubview:nameSexLevelView];
    [nameSexLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(userIcon.mas_bottom).offset(3);
        make.centerX.equalTo(backGround);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(18);
    }];
    
    
    miJiaNum = [[UILabel alloc]init];
    miJiaNum.backgroundColor = [UIColor clearColor];
    miJiaNum.alpha = 0.7f;
    miJiaNum.font = [UIFont IVTH3Font];
    miJiaNum.textAlignment = NSTextAlignmentCenter;
    [backGround addSubview:miJiaNum];
    [miJiaNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameSexLevelView.mas_bottom).offset(2);
        make.centerX.equalTo(backGround);
        make.size.mas_equalTo(CGSizeMake(140, 15));
    }];

    
    
    
    
    signatureLabel = [[UILabel alloc]init];
    [backGround addSubview:signatureLabel];
    signatureLabel.backgroundColor = [UIColor clearColor];
    signatureLabel.textColor = [UIColor YXColorWithHexCode:@"#343434"];
    signatureLabel.font = [UIFont YXFontOfSize:15];
    signatureLabel.textAlignment = NSTextAlignmentCenter;
    [signatureLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameSexLevelView.mas_bottom).offset(18);
        make.centerX.equalTo(backGround);

        make.height.mas_equalTo(15);
    }];
    
    devote = [[UIImageView alloc]init];
    devote.image = [UIImage imageNamed:@"用户详情---贡献最多的关联头像"];
    devote.layer.cornerRadius = 45 / 2;
    devote.clipsToBounds = YES;
    [backGround addSubview:devote];
    [devote mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(signatureLabel.mas_bottom).with.offset(8);
        make.centerX.equalTo(backGround);
        make.size.mas_equalTo(CGSizeMake(45, 45));
    }];
    
    //线
    lineView_H1 = [[UIView alloc] init];
    lineView_H1.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
    [backGround addSubview:lineView_H1];
    [lineView_H1 mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(devote.mas_bottom).with.offset(5);
        make.left.equalTo(backGround.mas_left);
        make.right.equalTo(backGround.mas_right);
        make.height.equalTo(@0.5);
    }];
    
    CGFloat widthForLabel = (kScreenWidth - 60)/4;
    fansNum = [[UILabel alloc]init];
    [backGround addSubview:fansNum];
    fansNum.text = @"4212";
    fansNum.textAlignment = NSTextAlignmentCenter;
    fansNum.font = [UIFont YXFontOfSize:13];
    fansNum.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [fansNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView_H1.mas_bottom).with.offset(20);
        make.left.equalTo(backGround.mas_left).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));

    }];
    UILabel *fansNameLabel = [[UILabel alloc]init];
    fansNameLabel.text = @"粉丝";
    fansNameLabel.textAlignment = NSTextAlignmentCenter;
    fansNameLabel.font = [UIFont YXFontOfSize:13];
    fansNameLabel.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [backGround addSubview:fansNameLabel];
    [fansNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(fansNum.mas_bottom).offset(5);
        make.left.equalTo(fansNum.mas_left);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    
    attentionNum = [[UILabel alloc]init];
    [backGround addSubview:attentionNum];
    attentionNum.textAlignment = NSTextAlignmentCenter;
    attentionNum.text = @"7.4万";
    attentionNum.font = [UIFont YXFontOfSize:13];
    attentionNum.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [attentionNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView_H1.mas_bottom).with.offset(20);
        make.left.equalTo(fansNum.mas_right).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    UILabel *attentionNameLabel = [[UILabel alloc]init];
    attentionNameLabel.text = @"关注";
    attentionNameLabel.textAlignment = NSTextAlignmentCenter;
    attentionNameLabel.font = [UIFont YXFontOfSize:13];
    attentionNameLabel.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [backGround addSubview:attentionNameLabel];
    [attentionNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(attentionNum.mas_bottom).offset(5);
        make.left.equalTo(attentionNum.mas_left);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    
    giftNum = [[UILabel alloc]init];
    [backGround addSubview:giftNum];
    giftNum.textAlignment = NSTextAlignmentCenter;
    giftNum.text = @"42";
    giftNum.font = [UIFont YXFontOfSize:13];
    giftNum.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [giftNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView_H1.mas_bottom).with.offset(20);
        make.left.equalTo(attentionNum.mas_right);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    UILabel *giftNameLabel = [[UILabel alloc]init];
    giftNameLabel.text = @"送出";
    giftNameLabel.textAlignment = NSTextAlignmentCenter;
    giftNameLabel.font = [UIFont YXFontOfSize:13];
    giftNameLabel.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [backGround addSubview:giftNameLabel];
    [giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(giftNum.mas_bottom).offset(5);
        make.left.equalTo(giftNum.mas_left);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    
    miTang = [[UILabel alloc]init];
    [backGround addSubview:miTang];
    miTang.textAlignment = NSTextAlignmentCenter;
    miTang.text = @"745";
    miTang.font = [UIFont YXFontOfSize:13];
    miTang.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [miTang mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView_H1.mas_bottom).with.offset(20);
        make.left.equalTo(giftNum.mas_right);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];
    UILabel *miTangNameLabel = [[UILabel alloc]init];
    miTangNameLabel.text = @"蜜糖";
    miTangNameLabel.textAlignment = NSTextAlignmentCenter;
    miTangNameLabel.font = [UIFont YXFontOfSize:13];
    miTangNameLabel.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [backGround addSubview:miTangNameLabel];
    [miTangNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(miTang.mas_bottom).offset(5);
        make.left.equalTo(miTang.mas_left);
        make.size.mas_equalTo(CGSizeMake(widthForLabel, 15));
    }];

    fansNumLabel = [[UILabel alloc] init];
    [backGround addSubview:fansNumLabel];
    fansNumLabel.textAlignment = NSTextAlignmentCenter;
    fansNumLabel.font = [UIFont YXFontOfSize:13];
    fansNumLabel.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
    [fansNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(attentionNum.mas_bottom).with.offset(20);
        make.left.equalTo(attentionNum.mas_left);
        make.size.mas_equalTo(CGSizeMake(140, 15));
    }];

    
    
#pragma mark - 下面的线
    //下面的线
    lineView_H2 = [[UIView alloc] init];
    lineView_H2.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
    [backGround addSubview:lineView_H2];
    [lineView_H2 mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(miTangNameLabel.mas_bottom).with.offset(20);
        make.left.equalTo(wself.mas_left).offset(wself.bounds.size.width / 3);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(22));
    }];
    
    lineView_V1 = [[UIView alloc] init];
    lineView_V1.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
    [backGround addSubview:lineView_V1];
    [lineView_V1 mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(miTangNameLabel.mas_bottom).with.offset(20);
        make.right.equalTo(wself.mas_right).offset(-wself.frame.size.width / 3);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(22));
    }];
    
    follow  = [UIButton buttonWithType: UIButtonTypeCustom];
    [follow addTarget:self action:@selector(followClick:) forControlEvents:UIControlEventTouchUpInside];
    [backGround addSubview:follow];
    [follow setTitle:@"关注" forState:UIControlStateNormal];
    follow.titleLabel.textAlignment = 1;
    [follow setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    follow.titleLabel.font =[UIFont YXFontOfSize:13];
    [follow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backGround.mas_left).offset(15);
        make.top.equalTo(miTangNameLabel.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(60, 35));
    }];
    
    message = [UIButton buttonWithType: UIButtonTypeCustom];
    [message addTarget:self action:@selector(messageClick:) forControlEvents:UIControlEventTouchUpInside];
    [backGround addSubview:message];
    [message setTitle:@"私信" forState:UIControlStateNormal];
    [message setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    message.titleLabel.font =[UIFont YXFontOfSize:13];
    [message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(wself.mas_centerX);
        make.top.equalTo(miTangNameLabel.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(60, 35));
    }];
    
    main = [UIButton buttonWithType: UIButtonTypeCustom];
    [main addTarget:self action:@selector(mainClick:) forControlEvents:UIControlEventTouchUpInside];
    [backGround addSubview:main];
    [main setTitle:@"主页" forState:UIControlStateNormal];
    main.titleLabel.textAlignment = 1;
    [main setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
    main.titleLabel.font =[UIFont YXFontOfSize:13];
    [main mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(backGround.mas_right).offset(-15);
        make.top.equalTo(miTangNameLabel.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(60, 35));
    }];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doChangeFollowStatus) name:@"followedChanged" object:nil];
}

- (void)doChangeFollowStatus{
    [follow setTitle:@"关注" forState:UIControlStateNormal];
    NSArray *followedListArray = [[NSUserDefaults standardUserDefaults] valueForKey:@"followListArray"];
    for (NSInteger i=0; i<followedListArray.count; i++) {
        NSDictionary *followdDic =[followedListArray objectAtIndex:i];
        if ([[_entity valueForKey:@"id"] integerValue] == [[followdDic valueForKey:@"id"] integerValue]) {
            [follow setTitle:@"已关注" forState:UIControlStateNormal];
            break;
        }
    }
    if (self.delegate && [self.delegate respondsToSelector:@selector(isFollow:meUserView:)]) {
        if ([follow.titleLabel.text isEqualToString:@"关注"]) {
            [self.delegate isFollow:NO meUserView:self];
        }
        else{
            [self.delegate isFollow:YES meUserView:self];
        }
    }
}


- (void)setUI{
    managementButton.hidden = NO;
    if (_isPullStream) {//进入别人的房间
        if (_isZhuBo) {
            [managementButton setTitle:@"举报" forState:UIControlStateNormal];
        }
        else{
            if (_isSetManager && !_isManager) {
                [managementButton setTitle:@"管理" forState:UIControlStateNormal];
            }
            else{
                managementButton.hidden = YES;
            }
        }
    }
    else{//主播
        [managementButton setTitle:@"管理" forState:UIControlStateNormal];
    }
}

- (void)setEntity:(NSDictionary *)entity{
    _entity = entity;
    
    NSString *avatar  =[NSString stringWithFormat:@"%@",[_entity objectForKey:@"avatar"]];
    [userIcon sd_setImageWithURL:[NSURL URLWithString:avatar] placeholderImage:[UIImage imageNamed:@"占位头像"]];


    nameSexLevelView.userNickName = _entity[@"name"];
    nameSexLevelView.userSex = _entity[@"sex"];
    nameSexLevelView.userLevel = _entity[@"level"];
    
    NSString *mejia =[NSString stringWithFormat:@"蜜家号:%@",[_entity objectForKey:@"id"]];
    miJiaNum.text = mejia;
    
    if ([_entity objectForKey:@"signature"] != nil) {
        signatureLabel.text = [[_entity objectForKey:@"signature"] base64DecodedToString];
    }else{
        signatureLabel.text = @"我很懒,所以什么都没写";
    }

    NSString *level = [_entity objectForKey:@"level"];
    lelveNum.text = level;
    grade.image = [IVTAccountTool showLevel:level].image;


    NSString *firstavatar  =[NSString stringWithFormat:@"%@",[_entity objectForKey:@"firstavatar"]];
    if ([firstavatar isEqualToString:@"http://api.me.cnlive.com/avatar.png"]) {
        devote.image = [UIImage imageNamed:@"用户详情--用户--占位头像"];
    }else{
        [devote sd_setImageWithURL:[NSURL URLWithString:firstavatar] placeholderImage:[UIImage imageNamed:@"占位头像"]];
    }
    
    NSInteger followercount = [[_entity objectForKey:@"followercount"] integerValue];
    NSString *followCount = [IVTAccountTool numberFormat:followercount];
    NSInteger fanscount = [[_entity objectForKey:@"fanscount"] integerValue];
    NSString *fanCount = [IVTAccountTool numberFormat:fanscount];
    
    attentionNum.text =followCount;
    fansNum.text = fanCount;
    
    NSInteger sentgiftmoneycount = [[_entity objectForKey:@"sentgiftmoneycount"] integerValue]/ 100;
    NSString *giftNumString = [IVTAccountTool numberFormat:sentgiftmoneycount];
    giftNum.text = giftNumString;
    
    
    NSInteger miTangNumber = [[_entity objectForKey:@"mecointotal"] integerValue];
    NSString *mitangNum = [IVTAccountTool numberFormat:miTangNumber];

    miTang.text =mitangNum;
    
    
//    BOOL isFollowed = [IVTAccountTool isFollowedToUserId:[_entity valueForKey:@"id"]];

    [follow setTitle:@"关注" forState:UIControlStateNormal];
    NSArray *followedListArray = [[NSUserDefaults standardUserDefaults] valueForKey:@"followListArray"];
    for (NSInteger i=0; i<followedListArray.count; i++) {
        NSDictionary *followdDic =[followedListArray objectAtIndex:i];
        if ([[_entity valueForKey:@"id"] integerValue] == [[followdDic valueForKey:@"id"] integerValue]) {
            [follow setTitle:@"已关注" forState:UIControlStateNormal];
            break;
        }
    }
}

- (void)managementClick:(UIButton *)sender{
    if (_isPullStream) {//
        if (_isZhuBo) {
            if (self.delegate && [self.delegate respondsToSelector:@selector(showJuBao:)]) {
                [self.delegate showJuBao:self];
            }
        }
        else{
            if (self.delegate && [self.delegate respondsToSelector:@selector(showManagement:)]) {
                [self.delegate showManagement:self];
            }
        }
    }
    else{//主播
        if (self.delegate && [self.delegate respondsToSelector:@selector(showManagement:)]) {
            [self.delegate showManagement:self];
        }
    }
}

//关注点击
-(void)followClick:(id)sender{
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setObject:[IVTAccountTool getUserName] forKey:@"username"];
    [dict setObject:[IVTAccountTool getPassword]forKey:@"captcha"];
    [dict setObject:[NSString stringWithFormat:@"%ld",[_entity[@"id"] integerValue]] forKey:@"followerid"];
    
    if ([follow.titleLabel.text isEqualToString:@"关注"]) {
        [[IVTNetworkAPIClient sharedClient] doFollowUser:[NSString stringWithFormat:@"%ld",[_entity[@"id"] integerValue]] success:^(NSDictionary *successData) {
            [IVTAccountTool insertToMyFollowListArrayWithUserDict:_entity];
            
            [follow setTitle:@"已关注" forState:UIControlStateNormal];
            [follow setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
            follow.titleLabel.font =[UIFont YXFontOfSize:13];
            [SVProgressHUD setMinimumDismissTimeInterval:2];
            [SVProgressHUD showSuccessWithStatus:@"已关注"];
            
            [[NSNotificationCenter defaultCenter] postNotificationName:@"followedChangedByUserView" object:nil userInfo:_entity];
            if (self.delegate && [self.delegate respondsToSelector:@selector(isFollow:meUserView:)]) {
                [self.delegate isFollow:YES meUserView:self];
            }
        } error:^(NSDictionary *successData) {
            
        } failure:^(NSError *failureError) {
            LRLog(@"failureError:%@",failureError);
        }];

    }else{
        [[IVTNetworkAPIClient sharedClient] doCancelFollowUser:[NSString stringWithFormat:@"%zd",[_entity[@"id"] integerValue]] success:^(NSDictionary *successData) {
            [IVTAccountTool deleteMyFollowToUserId:_entity[@"id"]];

            [follow setTitle:@"关注" forState:UIControlStateNormal];
            [follow setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
            follow.titleLabel.font =[UIFont YXFontOfSize:13];
            [SVProgressHUD setMinimumDismissTimeInterval:2];
            [SVProgressHUD showSuccessWithStatus:@"已取消关注"];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"followedChangedByUserView" object:nil userInfo:_entity];
            
            if (self.delegate && [self.delegate respondsToSelector:@selector(isFollow:meUserView:)]) {
                [self.delegate isFollow:NO meUserView:self];
            }
        } error:^(NSDictionary *successData) {
            

        } failure:^(NSError *failureError) {
            LRLog(@"failureError:%@",failureError);

        }];
    }
}

//私信点击
-(void)messageClick:(id)sender{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(showmessage:)]) {
        
        [self.delegate showmessage:self];
    }
}



//主页点击
-(void)mainClick:(id)sender{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(showUserInfo:)]) {
        
        [self.delegate showUserInfo:self];
    }
    
    NSLog(@"主页");
}

-(void)hidden{
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = 0.4;
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    animation.values = values;
    
        [backGround.layer addAnimation:animation forKey:@"scale"];
        [UIView animateWithDuration:0.5 animations:^{
            bgImageView.alpha = 0;
        } completion:^(BOOL finished){
        }];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self removeFromSuperview];
    });
}

- (void)show{
    [((AppDelegate *)[[UIApplication sharedApplication] delegate]).window addSubview:self];//添加分享视图
    
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = 0.4;
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    animation.values = values;
    [backGround.layer addAnimation:animation forKey:@"scale"];
    [UIView animateWithDuration:0.5 animations:^{
        bgImageView.alpha = 0.7f;
    } completion:^(BOOL finished){
    }];
}

@end