//
//  PrizeInfoCommitSuccessAlertView.m
//  Open
//
//  Created by 雷俊博 on 2020/1/15.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "PrizeInfoCommitSuccessAlertView.h"
#import "UIView+frameAdjust.h"
#import "UIImage+Custom.h"



//穿山甲
#import <BUAdSDK/BUAdSDK.h>

@interface PrizeInfoCommitSuccessAlertView ()<BUNativeExpressAdViewDelegate>

/** 弹窗主内容view */
@property (nonatomic,strong) UIView   *contentView;

@property (nonatomic, copy)NSString* number;

@property (nonatomic, copy)CTClickBlock block;

@property (nonatomic, copy) ClickExchangBlock ExchangBlock;

@property (nonatomic, assign) BOOL Exchang;

@property (strong, nonatomic) BUNativeExpressAdManager *nativeExpressAd3Manager;

@property (strong, nonatomic)UIViewController *vc;

@property (nonatomic, strong)UIView* xmADView;

@end

@implementation PrizeInfoCommitSuccessAlertView
- (instancetype)initWithNumber:(NSString *)number block:(nonnull CTClickBlock)block
{
    self = [super init];
    if (self) {
        self.number = number;
        self.block = block;
        //UI搭建
        [self setupUI];
        
        
    }
    return self;
}

- (instancetype)init2WithNumber:(NSString *)number block:(nonnull CTClickBlock)block
{
    self = [super init];
    if (self) {
        self.number = number;
        self.block = block;
        //UI搭建
        [self setupUI2];
        
        
    }
    return self;
}

- (instancetype)init3WithVC:(UIViewController *)vc Number:(NSString *)number block:(nonnull CTClickBlock)block
{
    self = [super init];
    if (self) {
        self.number = number;
        self.vc = vc;
        self.block = block;
        //UI搭建
        [self setupUI3];
        
        
    }
    return self;
}


- (instancetype)init4WithVC:(UIViewController *)vc  block:(nonnull CTClickBlock)block
{
    self = [super init];
    if (self) {
        self.vc = vc;
        self.block = block;
        //UI搭建
        [self setupUI4];
        
        
    }
    return self;
}

- (instancetype)init3WithVC:(UIViewController *)vc Number:(NSString *)number block:(nonnull CTClickBlock)block ExchangBlock:(ClickExchangBlock)ExchangBlock
{
    self = [super init];
    if (self) {
        self.number = number;
        self.vc = vc;
        self.block = block;
        self.ExchangBlock = ExchangBlock;
        self.Exchang = YES;
        //UI搭建
        [self setupUI3];
    }
    return self;
}


- (void)setupUI
{
    self.frame = [UIScreen mainScreen].bounds;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBackClcik:)];
    [self addGestureRecognizer:tap];
    
    
    
    
     //------- 弹窗主内容 -------//
    self.contentView = [[UIView alloc] init];
    
    self.contentView.frame = CGRectMake((ScreenWidth - 295) / 2, (ScreenHeight - 357.5) / 2 - 20, 295, 357.5);
    [self addSubview:self.contentView];
    self.contentView.backgroundColor = [UIColor clearColor];
    
    
    UIImageView *BackImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.width, self.contentView.height)];
      BackImg.image = [UIImage imageNamed:@"prizeAlertView_bg"];
      [self.contentView addSubview:BackImg];
    
    UILabel *titleLab = [[UILabel alloc]init];
    titleLab.textColor = [UIColor whiteColor];
    titleLab.text = @"信息提交成功";
    titleLab.textAlignment = NSTextAlignmentCenter;
    titleLab.font = [UIFont systemFontOfSize:23];
    [self.contentView addSubview:titleLab];
    
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.offset(23.5);
    }];
    
    
    UILabel *lb_message = [[UILabel alloc]init];
    lb_message.textColor = [UIColor colorWithHex:0x666666];
    lb_message.text = @"奖品会在1~7个工作日内发货";
    lb_message.textAlignment = NSTextAlignmentCenter;
    lb_message.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:lb_message];
    
    [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.offset(82.5);
    }];
    
    UIImageView *packImg = [[UIImageView alloc]init];
    packImg.image = [UIImage imageNamed:@"prize_bag"];
    [self.contentView addSubview:packImg];
    
    [packImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.equalTo(lb_message.mas_bottom).offset(12.5);
    }];
    
    UILabel *lb_message2 = [[UILabel alloc]init];
    lb_message2.textColor = [UIColor colorWithHex:0x808080];
    lb_message2.text = [NSString stringWithFormat:@"分享好友免费赠您%@金币",self.number];
    lb_message2.textAlignment = NSTextAlignmentCenter;
    lb_message2.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:lb_message2];
    
    [lb_message2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.centerY.equalTo(BackImg.mas_bottom).offset(-106);
    }];
    
    UIView* leftLine = [[UIView alloc]init];
    leftLine.backgroundColor = [UIColor colorWithHex:0xb3b3b3];
    [self.contentView addSubview:leftLine];
    
    [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lb_message2);
        make.left.offset(20);
        make.right.equalTo(lb_message2.mas_left).offset(-10);
        make.height.offset(0.5);
    }];
    
    UIView* rightLine = [[UIView alloc]init];
    rightLine.backgroundColor = [UIColor colorWithHex:0xb3b3b3];
    [self.contentView addSubview:rightLine];
    
    [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lb_message2);
        make.right.offset(-20);
        make.left.equalTo(lb_message2.mas_right).offset(10);
        make.height.offset(0.5);
    }];
    
    
    UIButton* wxBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [wxBtn setImage:[UIImage imageNamed:@"wx"] forState:UIControlStateNormal];
    [wxBtn setTitle:@"微信" forState:UIControlStateNormal];
    [wxBtn setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
    wxBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    [wxBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleTop imageTitleSpace:8];
    
    [self.contentView addSubview:wxBtn];
    
    [wxBtn addTarget:self action:@selector(wxBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    wxBtn.tag = 200;
    
    
    
    UIButton* wxFBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [wxFBtn setImage:[UIImage imageNamed:@"pengyouquan"] forState:UIControlStateNormal];
    [wxFBtn setTitle:@"朋友圈" forState:UIControlStateNormal];
    [wxFBtn setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
    wxFBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [wxFBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleTop imageTitleSpace:8];
    wxFBtn.tag = 201;
    [self.contentView addSubview:wxFBtn];
    
     [wxFBtn addTarget:self action:@selector(wxBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [wxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_message2.mas_bottom).offset(28);
        make.centerX.equalTo(self.contentView.mas_centerX).offset(-47.5);
    }];
    
    [wxFBtn mas_makeConstraints:^(MASConstraintMaker *make) {
           make.top.equalTo(lb_message2.mas_bottom).offset(28);
           make.centerX.equalTo(self.contentView.mas_centerX).offset(47.5);
       }];
    
}

- (void)setupUI2
{
    self.frame = [UIScreen mainScreen].bounds;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBackClcik:)];
        [self addGestureRecognizer:tap];
    //------- 弹窗主内容 -------//
     self.contentView = [[UIView alloc] init];
     
     self.contentView.frame = CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20, 299, 288);
     [self addSubview:self.contentView];
     self.contentView.backgroundColor = [UIColor clearColor];
    
    UIImageView *BackImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.width, self.contentView.height)];
    BackImg.image = [UIImage imageNamed:@"prizepackage_bg"];
    [self.contentView addSubview:BackImg];
    
    UIView *sendView = [[UIView alloc]init];
    sendView.backgroundColor = [UIColor clearColor];
    [BackImg addSubview:sendView];
    
    UILabel* lb_send = [[UILabel alloc]init];
    lb_send.font = [UIFont systemFontOfSize:18];
    lb_send.textColor = [UIColor colorWithHex:0xa65327];
    lb_send.numberOfLines = 0;
    lb_send.textAlignment = NSTextAlignmentCenter;
    [sendView addSubview:lb_send];
    NSString* str = @"赠您\n金币";
   lb_send.attributedText = [NSString getAttributedWithString:str WithLineSpace:6 kern:3 font:[UIFont systemFontOfSize:18]];
    
    
    UILabel *lb_number = [[UILabel alloc]init];
    lb_number.font = [UIFont boldSystemFontOfSize:61];
    lb_number.text = self.number;
    lb_number.textColor = [UIColor colorWithHex:0xef2f27];
    [sendView addSubview:lb_number];
    lb_number.textAlignment = NSTextAlignmentCenter;
    
    [sendView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.offset(40);
    }];
    
    [lb_send mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.offset(0);
        make.right.equalTo(lb_number.mas_left).offset(-6);
    }];
    
    [lb_number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(0);
        make.centerY.equalTo(sendView);
    }];
    
    UILabel *lb_message = [[UILabel alloc]init];
    lb_message.font = [UIFont systemFontOfSize:16];
    lb_message.textColor = [UIColor colorWithHex:0xa65327];
    lb_message.numberOfLines = 0;
    lb_message.text = @"每天首次分享即可领取";
    lb_message.textAlignment = NSTextAlignmentCenter;
    [BackImg addSubview:lb_message];
    
    [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sendView.mas_bottom).offset(20);
        make.centerX.equalTo(sendView);
    }];
    
    
    
    UIButton* wxBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [wxBtn setImage:[UIImage imageWithImage:[UIImage imageNamed:@"wx"] scale:0.5] forState:UIControlStateNormal];
    [wxBtn setTitle:@"分享给好友" forState:UIControlStateNormal];
    [wxBtn setTitleColor:[UIColor colorWithHex:0xa65327] forState:UIControlStateNormal];
    wxBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    wxBtn.backgroundColor = [UIColor colorWithHex:0xfbf7d4];
    wxBtn.layer.cornerRadius = 20;
       
    [wxBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:2];
       
    [self.contentView addSubview:wxBtn];
       
    [wxBtn addTarget:self action:@selector(wxBtnClick:) forControlEvents:UIControlEventTouchUpInside];
       wxBtn.tag = 200;
       
       
       
     UIButton* wxFBtn = [UIButton buttonWithType:UIButtonTypeCustom];
       [wxFBtn setImage:[UIImage imageWithImage:[UIImage imageNamed:@"pengyouquan"] scale:0.5   ] forState:UIControlStateNormal];
       [wxFBtn setTitle:@"分享朋友圈" forState:UIControlStateNormal];
       [wxFBtn setTitleColor:[UIColor colorWithHex:0xa65327] forState:UIControlStateNormal];
       wxFBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    wxFBtn.backgroundColor = [UIColor colorWithHex:0xfbf7d4];
    wxFBtn.layer.cornerRadius = 20;
       [wxFBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:2];
       
       [self.contentView addSubview:wxFBtn];
       
        [wxBtn addTarget:self action:@selector(wxBtnClick:) forControlEvents:UIControlEventTouchUpInside];
       
       [wxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
           make.left.offset(15);
           make.right.equalTo(wxFBtn.mas_left).offset(-12);
           make.width.equalTo(wxFBtn);
           make.height.offset(40);
           make.bottom.offset(-20);
       }];
       
       [wxFBtn mas_makeConstraints:^(MASConstraintMaker *make) {
           make.right.offset(-15);
           make.centerY.equalTo(wxBtn);
           make.height.offset(40);
          }];
    
    [wxFBtn addTarget:self action:@selector(wxBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    wxFBtn.tag = 201;
    
}
- (void)setupUI4{
    self.frame = [UIScreen mainScreen].bounds;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBackClcik:)];
    [self addGestureRecognizer:tap];
    //------- 弹窗主内容 -------//
     self.contentView = [[UIView alloc] init];
    if (self.Exchang) {
        self.contentView.frame = CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20, 299, 318);
    }else{
        self.contentView.frame = CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20, 299, 288);
    }
    
     [self addSubview:self.contentView];
     self.contentView.backgroundColor = [UIColor clearColor];
    
    UIImageView *BackImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.width, self.contentView.height)];
    BackImg.image = [UIImage imageNamed:@"prizepackage_bg"];
    [self.contentView addSubview:BackImg];
    
    
    
    UILabel *lb_number = [[UILabel alloc]init];
    lb_number.font = [UIFont boldSystemFontOfSize:51];
    lb_number.text = @"提现成功";
    lb_number.textColor = [UIColor colorWithHex:0xef2f27];
    [self.contentView addSubview:lb_number];
    lb_number.textAlignment = NSTextAlignmentCenter;
    
    [lb_number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.offset(40);
    }];
    
    
    UILabel *lb_message = [[UILabel alloc]init];
    lb_message.font = [UIFont systemFontOfSize:16];
    lb_message.textColor = [UIColor colorWithHex:0xa65327];
    lb_message.numberOfLines = 0;
    lb_message.text = @"";
    lb_message.textAlignment = NSTextAlignmentCenter;
    [BackImg addSubview:lb_message];
    
    [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_number.mas_bottom).offset(15);
        make.centerX.equalTo(lb_number);
    }];
    
    
    
    UIButton* receiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [receiveBtn setTitle:@"确认" forState:UIControlStateNormal];
    [receiveBtn setTitleColor:[UIColor colorWithHex:0xa65327] forState:UIControlStateNormal];
    receiveBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    receiveBtn.backgroundColor = [UIColor colorWithHex:0xfbf7d4];
    receiveBtn.layer.cornerRadius = 20;
    [self.contentView addSubview:receiveBtn];
    [receiveBtn addTarget:self action:@selector(receiveBtnClick:) forControlEvents:UIControlEventTouchUpInside];
   
    
    if (self.Exchang) {
        [receiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(40);
            make.bottom.offset(-40);
        }];
        
        UIButton* ExchangBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [ExchangBtn setTitle:@"兑换好物>>" forState:UIControlStateNormal];
        [ExchangBtn setTitleColor:[UIColor colorWithHex:0xfbf7d4] forState:UIControlStateNormal];
        ExchangBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:ExchangBtn];
        [ExchangBtn addTarget:self action:@selector(ExchangBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [ExchangBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(30);
            make.bottom.offset(-5);
        }];
    }else{
        [receiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(40);
            make.bottom.offset(-20);
        }];
    }
    
}

- (void)setupUI3{
    self.frame = [UIScreen mainScreen].bounds;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBackClcik:)];
    [self addGestureRecognizer:tap];
    //------- 弹窗主内容 -------//
     self.contentView = [[UIView alloc] init];
    if (self.Exchang) {
        self.contentView.frame = CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20, 299, 318);
    }else{
        self.contentView.frame = CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20, 299, 288);
    }
    
     [self addSubview:self.contentView];
     self.contentView.backgroundColor = [UIColor clearColor];
    
    UIImageView *BackImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.width, self.contentView.height)];
    BackImg.image = [UIImage imageNamed:@"prizepackage_bg"];
    [self.contentView addSubview:BackImg];
    
    
    
    UILabel *lb_number = [[UILabel alloc]init];
    lb_number.font = [UIFont boldSystemFontOfSize:61];
    lb_number.text = self.number;
    lb_number.textColor = [UIColor colorWithHex:0xef2f27];
    [self.contentView addSubview:lb_number];
    lb_number.textAlignment = NSTextAlignmentCenter;
    
    [lb_number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(BackImg);
        make.top.offset(40);
    }];
    
    
    UILabel *lb_message = [[UILabel alloc]init];
    lb_message.font = [UIFont systemFontOfSize:16];
    lb_message.textColor = [UIColor colorWithHex:0xa65327];
    lb_message.numberOfLines = 0;
    lb_message.text = [NSString stringWithFormat:@"分享成功赠您%@金币",self.number];
    lb_message.textAlignment = NSTextAlignmentCenter;
    [BackImg addSubview:lb_message];
    
    [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_number.mas_bottom).offset(15);
        make.centerX.equalTo(lb_number);
    }];
    
    
    
    UIButton* receiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [receiveBtn setTitle:@"立即领取" forState:UIControlStateNormal];
    [receiveBtn setTitleColor:[UIColor colorWithHex:0xa65327] forState:UIControlStateNormal];
    receiveBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    receiveBtn.backgroundColor = [UIColor colorWithHex:0xfbf7d4];
    receiveBtn.layer.cornerRadius = 20;
    [self.contentView addSubview:receiveBtn];
    [receiveBtn addTarget:self action:@selector(receiveBtnClick:) forControlEvents:UIControlEventTouchUpInside];
   
    
    if (self.Exchang) {
        [receiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(40);
            make.bottom.offset(-40);
        }];
        
        UIButton* ExchangBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [ExchangBtn setTitle:@"兑换好物>>" forState:UIControlStateNormal];
        [ExchangBtn setTitleColor:[UIColor colorWithHex:0xfbf7d4] forState:UIControlStateNormal];
        ExchangBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:ExchangBtn];
        [ExchangBtn addTarget:self action:@selector(ExchangBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [ExchangBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(30);
            make.bottom.offset(-5);
        }];
    }else{
        [receiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(40);
            make.bottom.offset(-20);
        }];
    }
    
}

+(void)showSuccessViewWithNumber:(NSString *)number block:(nonnull CTClickBlock)block
{
   UIWindow *window = [UIApplication sharedApplication].delegate.window;
     
    
    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] initWithNumber:number block:block];

    [window addSubview:view];
         
     [view show];
}

+ (void)showShareViewWithNumber:(NSString *)number block:(nonnull CTClickBlock)block
{
    UIWindow *window = [UIApplication sharedApplication].delegate.window;
     
    
    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] init2WithNumber:number block:block];

    [window addSubview:view];
         
     [view show];
}
+ (void)showReceiveViewWithVC:(UIViewController *)vc Number:(NSString *)number block:(nonnull CTClickBlock)block ExchangBlock:(ClickExchangBlock)ExchangBlock{
    
    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] init3WithVC:vc Number:number block:block ExchangBlock:ExchangBlock];

    [vc.view addSubview:view];
         
    [view show];
}
+ (void)showReceiveViewWithVC:(UIViewController *)vc Number:(NSString *)number block:(nonnull CTClickBlock)block;
{

    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] init3WithVC:vc Number:number block:block];

    [vc.view addSubview:view];
         
    [view show];
    
}

+ (void)showReceiveViewWithVC:(UIViewController *)vc  block:(nonnull CTClickBlock)block;
{

    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] init4WithVC:vc block:block];

    [vc.view addSubview:view];
         
    [view show];
    
}

+ (void)showReceiveViewInWindowWithVC:(UIViewController *)vc Number:(NSString *)number block:(CTClickBlock)block
{
    PrizeInfoCommitSuccessAlertView* view = [[PrizeInfoCommitSuccessAlertView alloc] init3WithVC:vc Number:number block:block];
    
    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    
    [keyWindow addSubview:view];
    
    [view show];
}


- (void)show
{
    self.contentView.transform=CGAffineTransformMakeScale(0.02, 0.02);
    
    
    [UIView animateWithDuration:0.4f animations:^{
        self.contentView.transform=CGAffineTransformMakeScale(1.0, 1.0);
        self.contentView.alpha=1;
      
    }];
}

- (void)dismiss
{
    self.contentView.transform=CGAffineTransformMakeScale(1.0, 1.0);
    
    
    
    [UIView animateWithDuration:0.4f animations:^{
        self.contentView.transform=CGAffineTransformMakeScale(0.02, 0.02);
        self.contentView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.contentView removeFromSuperview];
        [self removeFromSuperview];
    }];
}


#pragma mark - 穿山甲广告 任务弹框
- (void)loadBUADData3
{
    BUAdSlot *slot1 = [[BUAdSlot alloc] init];
    slot1.adSize = CGSizeMake(300, 300/375.0 * 123.5);
    slot1.ID = @"946421253";
    slot1.AdType = BUAdSlotAdTypeFeed;
    
    BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Feed228_150];
    slot1.imgSize = imgSize;
    slot1.position = BUAdSlotPositionFeed;
    
    
    self.nativeExpressAd3Manager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:CGSizeMake(300, 300/375.0 * 123.5)];
    self.nativeExpressAd3Manager.delegate = self;
    
    [self.nativeExpressAd3Manager loadAdDataWithCount:1];
}


#pragma mark - BUNativeExpressAdViewDelegate
- (void)nativeExpressAdSuccessToLoad:(BUNativeExpressAdManager *)nativeExpressAd views:(NSArray<__kindof BUNativeExpressAdView *> *)views {
    
    if (views.count > 0) {
        [views enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                    BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)obj;
                    expressView.rootViewController = self.vc;
                    // important: 此处会进行WKWebview的渲染，建议一次最多预加载三个广告，如果超过3个会很大概率导致WKWebview渲染失败。
                    [expressView render];
        }];
        
        BUNativeExpressAdView *adView = views[0];
        [self.xmADView addSubview:adView];
        [adView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.offset(0);
        }];
    }
    
   
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdFailToLoad:(BUNativeExpressAdManager *)nativeExpressAd error:(NSError *)error {
    
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"error:%@", error]];
    
    [self.xmADView removeFromSuperview];
    
}

- (void)nativeExpressAdViewRenderSuccess:(BUNativeExpressAdView *)nativeExpressAdView {
    //[self.tableView reloadData];
    
    self.xmADView.hidden = YES;
    
}


- (void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView stateDidChanged:(BUPlayerPlayState)playerState {
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"playerState:%ld", (long)playerState]];
}

- (void)nativeExpressAdViewRenderFail:(BUNativeExpressAdView *)nativeExpressAdView error:(NSError *)error {
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"error:%@  此广告将会从列表中移除", error]];
    
    [self.xmADView removeFromSuperview];
    
}

- (void)nativeExpressAdViewWillShow:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidClick:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewPlayerDidPlayFinish:(BUNativeExpressAdView *)nativeExpressAdView error:(NSError *)error {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterWords {
    
    
    [self.xmADView removeFromSuperview];
    
    
   
    
    //【重要】需要在点击叉以后 在这个回调中移除视图，否则，会出现用户点击叉无效的情况
//    [self.expressAdViews removeObject:nativeExpressAdView];
//
//    NSUInteger index = [self.expressAdViews indexOfObject:nativeExpressAdView];
//    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:index inSection:0];
//    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
//    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidClosed:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewWillPresentScreen:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidCloseOtherController:(BUNativeExpressAdView *)nativeExpressAdView interactionType:(BUInteractionType)interactionType {
    NSString *str;
    if (interactionType == BUInteractionTypePage) {
        str = @"ladingpage";
    } else if (interactionType == BUInteractionTypeVideoAdDetail) {
        str = @"videoDetail";
    } else {
        str = @"appstoreInApp";
    }
    [self pbud_logWithSEL:_cmd msg:str];
}


- (void)pbud_logWithSEL:(SEL)sel msg:(NSString *)msg {
    //BUD_Log(@"SDKDemoDelegate BUNativeExpressFeedAdView In VC (%@) extraMsg:%@", NSStringFromSelector(sel), msg);
}


#pragma mark - event response
- (void)wxBtnClick:(UIButton *)sender
{
    if (sender.tag == 200) {
        self.block(CTShareTypeWX);
    }else if (sender.tag == 201){
        self.block(CTShareTypeFriend);
    }
    
    [self dismiss];
}

- (void)receiveBtnClick:(UIButton *)sender{
    
    if (self.block) {
        self.block(CTShareTypeWX);
    }
    
    [self dismiss];
}
- (void)ExchangBtnClick:(UIButton *)button{
    if(self.ExchangBlock){
        self.ExchangBlock();
    }
    [self dismiss];
}
- (void)tapBackClcik:(UITapGestureRecognizer *)ges
{
    self.block(CTShareTypeNone);
    [self dismiss];
}

#pragma mark -  BUNativeExpressAdViewDelegate

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
