//
//  KKActivityRedPackageBaseView.m
//  Open
//
//  Created by 雷俊博 on 2020/9/2.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "KKActivityRedPackageBaseView.h"
#import "UIImageView+WebCache.h"

@interface KKActivityRedPackageBaseView ()

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

@property (nonatomic, strong)UIView* unOpenView;

@property (nonatomic, strong)UIView* openedView;

@property (nonatomic, strong)UIView* openedView2;

@property (nonatomic, assign)KKActivityRedPackageType type;

@property (nonatomic, strong)KKActivityPackageModel* model;

@property (nonatomic, copy)KKActivityRedPackagBtnBlock block;

@end

@implementation KKActivityRedPackageBaseView

- (instancetype)initWithType:(KKActivityRedPackageType)type model:(KKActivityPackageModel *)model block:(KKActivityRedPackagBtnBlock)block
{
    self = [super init];
    if (self) {
        self.type = type;
        self.model = model;
        self.block = block;
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.frame = [UIScreen mainScreen].bounds;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    //UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick:)];
    //[self addGestureRecognizer:tap];
    
    //------- 弹窗主内容 -------//
    self.contentView = [[UIView alloc] init];
    self.contentView.bounds = CGRectMake(0, 0, 320*WIDTHRADIU, 341 * WIDTHRADIU);
    self.contentView.center = self.center;
    [self addSubview:self.contentView];
    self.contentView.backgroundColor = [UIColor clearColor];
    //self.contentView.layer.cornerRadius = 15 * WIDTHRADIU;
    
    
    //关闭按钮
    UIButton*closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [closeBtn setImage:[UIImage imageNamed:@"save_close"] forState:UIControlStateNormal];
    [closeBtn addTarget:self action:@selector(closeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_top).offset(-20 * WIDTHRADIU);
        make.left.equalTo(self.contentView.mas_right).offset(-40 * WIDTHRADIU);
        make.width.height.offset(45 * WIDTHRADIU);
    }];
    
    if (self.type == KKActivityRedPackageTypeSignSuccess) {
        [self.contentView addSubview:self.openedView2];
    }else{
        [self.contentView addSubview:self.openedView];
    }
    
    //[self.contentView addSubview:self.unOpenView];
    
}

#pragma mark - 显示弹框
+ (void)showMoneyWithVC:(UIViewController *)vc type:(KKActivityRedPackageType)type model:(KKActivityPackageModel *)model block:(KKActivityRedPackagBtnBlock)block
{
    KKActivityRedPackageBaseView*baseView = [[KKActivityRedPackageBaseView alloc]initWithType:type model:model block:block];
    UIWindow* keyWindow = vc.view.window;
    
    if (keyWindow == nil) {
        keyWindow = [UIApplication sharedApplication].keyWindow;
    }

    [keyWindow addSubview:baseView];
}
#pragma mark -隐藏弹框
- (void)dismissUI
{
     [self removeFromSuperview];
}


#pragma mark - event response
//拆红包
- (void)openBtnClick:(UIButton *)sender
{
    self.openedView.hidden = NO;
    [UIView transitionFromView:self.unOpenView toView:self.openedView duration:0.5f options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
                    NSLog(@"翻转到了列表页面");
        self.unOpenView.hidden = YES;
    }];
}
//关闭
- (void)closeBtnClick:(UIButton *)sender
{
    [self dismissUI];
}

- (void)confirmBtnClick:(UIButton *)sender
{
    if (self.block) {
        self.block();
    }
    [self dismissUI];
}

#pragma mark - 获取多少元富文本
- (NSAttributedString *)getAttStringWithString:(NSString *)number
{
    NSDictionary *attributesExtra = @{NSFontAttributeName:[UIFont systemFontOfSize:70 * WIDTHRADIU],//字号12
                                                     NSForegroundColorAttributeName: [UIColor colorWithHex:0xe5281d]};
       NSDictionary *attributesPrice = @{NSFontAttributeName:[UIFont systemFontOfSize:20 * WIDTHRADIU],//字号18
                                                      NSForegroundColorAttributeName: [UIColor colorWithHex:0xe5281d]};
    NSAttributedString *attributedString = [self attributedText:@[number, @"元"]
                                                        attributeAttay:@[attributesExtra,attributesPrice]];
    
    return attributedString;
}

#pragma mark - 获取自定义富文本
// 获取带有不同样式的文字内容
//stringArray 字符串数组
//attributeAttay 样式数组
- (NSAttributedString *)attributedText:(NSArray*)stringArray attributeAttay:(NSArray *)attributeAttay{
　// 定义要显示的文字内容
    
    
   
    
    NSString * string = [stringArray componentsJoinedByString:@""];　　//拼接传入的字符串数组
　// 通过要显示的文字内容来创建一个带属性样式的字符串对象
    NSMutableAttributedString * result = [[NSMutableAttributedString alloc] initWithString:string];
        for(NSInteger i = 0; i < stringArray.count; i++){
　　　　// 将某一范围内的字符串设置样式
        [result setAttributes:attributeAttay[i] range:[string rangeOfString:stringArray[i]]];
    }
    // 返回已经设置好了的带有样式的文字
    return [[NSAttributedString alloc] initWithAttributedString:result];
}

#pragma mark - getters and setters
- (UIView *)unOpenView
{
    if (!_unOpenView) {
        _unOpenView = [[UIView alloc]initWithFrame:CGRectMake(20 * WIDTHRADIU, 0, 280*WIDTHRADIU, 341 * WIDTHRADIU)];
        UIImageView*backImg = [[UIImageView alloc]initWithFrame:_unOpenView.bounds];
        backImg.image = [UIImage imageNamed:@"save_unopen"];
        [_unOpenView addSubview:backImg];
        UIButton*openBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        openBtn.frame = CGRectMake(95 * WIDTHRADIU, 185 * WIDTHRADIU, 90 * WIDTHRADIU, 90 * WIDTHRADIU);
        [openBtn addTarget:self action:@selector(openBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_unOpenView addSubview:openBtn];
    }
    return _unOpenView;
}

- (UIView *)openedView
{
    if (!_openedView) {
        _openedView = [[UIView alloc]init];
        if (self.type == KKActivityRedPackageTypeMoney || self.type == KKActivityRedPackageTypeOilAndEgg) {
            _openedView.frame = CGRectMake(0, 0.5 * WIDTHRADIU, 320*WIDTHRADIU, 340 * WIDTHRADIU);
        }else if (self.type == KKActivityRedPackageTypeQRMoney || self.type == KKActivityRedPackageTypeQROilAndEgg){
            _openedView.frame = CGRectMake(0, 3 * WIDTHRADIU, 314*WIDTHRADIU, 341 * WIDTHRADIU);
        }
        
        _openedView.hidden = NO;
        UIImageView*backImg = [[UIImageView alloc]initWithFrame:_openedView.bounds];
        if (self.type == KKActivityRedPackageTypeMoney || self.type == KKActivityRedPackageTypeOilAndEgg) {
            backImg.image = [UIImage imageNamed:@"save_openedPackage"];
        }else if (self.type == KKActivityRedPackageTypeQRMoney || self.type == KKActivityRedPackageTypeQROilAndEgg){
            backImg.image = [UIImage imageNamed:@"save_qrOpenedPackage"];
        }
        
        [_openedView addSubview:backImg];
        
        CGFloat topPadding = 0.0;
        if (self.type == KKActivityRedPackageTypeMoney ||  self.type == KKActivityRedPackageTypeOilAndEgg) {
            topPadding = 30 * WIDTHRADIU;
        }else if (self.type == KKActivityRedPackageTypeQRMoney || self.type == KKActivityRedPackageTypeQROilAndEgg){
            
            topPadding = 25 * WIDTHRADIU;
        }
        
        //标题
        UILabel* lb_title = [UILabel new];
        lb_title.text = @"存钱罐全新上线，回馈认证用户";
        lb_title.textColor = [UIColor colorWithHex:0xcb9836];
        lb_title.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
        lb_title.textAlignment = NSTextAlignmentCenter;
        [_openedView addSubview:lb_title];
        [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(topPadding);
            make.centerX.equalTo(self->_openedView);
        }];
        
        if (self.type == KKActivityRedPackageTypeMoney) {
            //金额元
            UILabel*lb_money = [UILabel new];
            lb_money.attributedText = [self getAttStringWithString:self.model.activeMoney];
            lb_money.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_money];
            [lb_money mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lb_title.mas_bottom).offset(10 * WIDTHRADIU);
                make.centerX.equalTo(self->_openedView);
            }];
        }else if (self.type == KKActivityRedPackageTypeOilAndEgg){
            UIImageView* plusImg = [[UIImageView alloc]init];
            plusImg.image = [UIImage imageNamed:@"save_plus"];
            [_openedView addSubview:plusImg];
            [plusImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lb_title.mas_bottom).offset(35 * WIDTHRADIU);
                make.centerX.equalTo(self->_openedView);
                make.width.offset(27 * WIDTHRADIU);
                make.height.offset(27 * WIDTHRADIU);
            }];
            
            UIImageView* eggImg = [[UIImageView alloc]init];
            eggImg.image = [UIImage imageNamed:@"save_egg"];
            [_openedView addSubview:eggImg];
            [eggImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(plusImg.mas_left).offset(-13 * WIDTHRADIU);
                make.top.equalTo(plusImg.mas_top).offset(-15 * WIDTHRADIU);
                make.width.offset(59 * WIDTHRADIU);
                make.height.offset(42 * WIDTHRADIU);
            }];
            
            UILabel* lb_egg = [UILabel new];
            lb_egg.text = [NSString stringWithFormat:@"%@个鸡蛋",self.model.eggNum];
            lb_egg.textColor = [UIColor colorWithHex:0xe5281d];
            lb_egg.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
            lb_egg.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_egg];
            [lb_egg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(eggImg.mas_bottom).offset(4 * WIDTHRADIU);
                make.centerX.equalTo(eggImg);
            }];
            
            UIImageView* oilImg = [[UIImageView alloc]init];
            oilImg.image = [UIImage imageNamed:@"save_oil"];
            [_openedView addSubview:oilImg];
            [oilImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(plusImg.mas_right).offset(20 * WIDTHRADIU);
                make.top.equalTo(plusImg.mas_top).offset(-15 * WIDTHRADIU);
                make.width.offset(42 * WIDTHRADIU);
                make.height.offset(42 * WIDTHRADIU);
            }];
            
            UILabel* lb_oil = [UILabel new];
            lb_oil.text = [NSString stringWithFormat:@"%@桶食用油",self.model.oilnum];
            lb_oil.textColor = [UIColor colorWithHex:0xe5281d];
            lb_oil.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
            lb_oil.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_oil];
            [lb_oil mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(oilImg.mas_bottom).offset(4 * WIDTHRADIU);
                make.centerX.equalTo(oilImg);
            }];
        }else if (self.type == KKActivityRedPackageTypeQRMoney){
            //金额元
            UILabel*lb_money = [UILabel new];
            lb_money.attributedText = [self getAttStringWithString:self.model.activeMoney];
            lb_money.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_money];
            [lb_money mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lb_title.mas_bottom);
                make.centerX.equalTo(self->_openedView.mas_centerX).offset(-6.5 * WIDTHRADIU);
            }];
            UIImageView *topImg = [[UIImageView alloc]init];
            topImg.image = [UIImage imageNamed:@"save_top"];
            [_openedView addSubview:topImg];
            [topImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(lb_money.mas_right).offset(-20 * WIDTHRADIU);
                make.top.equalTo(lb_title.mas_bottom).offset(20 * WIDTHRADIU);
                make.width.offset(33 * WIDTHRADIU);
                make.height.offset(18 * WIDTHRADIU);
            }];
            
            
            
        }else if (self.type == KKActivityRedPackageTypeQROilAndEgg){\
            UIImageView* plusImg = [[UIImageView alloc]init];
            plusImg.image = [UIImage imageNamed:@"save_plus"];
            [_openedView addSubview:plusImg];
            [plusImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lb_title.mas_bottom).offset(25 * WIDTHRADIU);
                make.centerX.equalTo(self->_openedView);
                make.width.offset(27 * WIDTHRADIU);
                make.height.offset(27 * WIDTHRADIU);
            }];
            
            UIImageView* eggImg = [[UIImageView alloc]init];
            eggImg.image = [UIImage imageNamed:@"save_egg"];
            [_openedView addSubview:eggImg];
            [eggImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(plusImg.mas_left).offset(-13 * WIDTHRADIU);
                make.top.equalTo(plusImg.mas_top).offset(-15 * WIDTHRADIU);
                make.width.offset(59 * WIDTHRADIU);
                make.height.offset(42 * WIDTHRADIU);
            }];
            
            UILabel* lb_egg = [UILabel new];
            lb_egg.text = [NSString stringWithFormat:@"%@个鸡蛋",self.model.eggNum];
            lb_egg.textColor = [UIColor colorWithHex:0xe5281d];
            lb_egg.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
            lb_egg.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_egg];
            [lb_egg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(eggImg.mas_bottom).offset(4 * WIDTHRADIU);
                make.centerX.equalTo(eggImg);
            }];
            
            UIImageView* oilImg = [[UIImageView alloc]init];
            oilImg.image = [UIImage imageNamed:@"save_oil"];
            [_openedView addSubview:oilImg];
            [oilImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(plusImg.mas_right).offset(20 * WIDTHRADIU);
                make.top.equalTo(plusImg.mas_top).offset(-15 * WIDTHRADIU);
                make.width.offset(42 * WIDTHRADIU);
                make.height.offset(42 * WIDTHRADIU);
            }];
            
            UILabel* lb_oil = [UILabel new];
            lb_oil.text = [NSString stringWithFormat:@"%@桶食用油",self.model.oilnum];
            lb_oil.textColor = [UIColor colorWithHex:0xe5281d];
            lb_oil.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
            lb_oil.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:lb_oil];
            [lb_oil mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(oilImg.mas_bottom).offset(4 * WIDTHRADIU);
                make.centerX.equalTo(oilImg);
            }];
        }
        
        if (self.type == KKActivityRedPackageTypeMoney || self.type == KKActivityRedPackageTypeOilAndEgg) {
            //领福利按钮
                   UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                   confirmBtn.backgroundColor = [UIColor colorWithHex:0xfcdb93];
                   [confirmBtn setTitle:@"领福利" forState:UIControlStateNormal];
                   [confirmBtn setTitleColor:[UIColor colorWithHex:0xa41d1f] forState:UIControlStateNormal];
                   confirmBtn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
                   confirmBtn.layer.cornerRadius = 15 * WIDTHRADIU;
                   [confirmBtn addTarget:self action:@selector(confirmBtnClick:) forControlEvents:UIControlEventTouchUpInside];
                   [_openedView addSubview:confirmBtn];
                   [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                       make.bottom.offset(-25 * WIDTHRADIU);
                       make.centerX.equalTo(self->_openedView);
                       make.width.offset(230 * WIDTHRADIU);
                       make.height.offset(50 * WIDTHRADIU);
                   }];
                   
                   //活动时间
                   UILabel* timeLabel = [UILabel new];
                   timeLabel.text = [NSString stringWithFormat:@"活动时间：%@",self.model.activeTime];
                   timeLabel.textColor = [UIColor colorWithHex:0xfff2c3];
                   timeLabel.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
                   timeLabel.textAlignment = NSTextAlignmentCenter;
                   [_openedView addSubview:timeLabel];
                   [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                       make.bottom.equalTo(confirmBtn.mas_top).offset(-28 * WIDTHRADIU);
                       make.centerX.equalTo(self->_openedView);
                   }];
                   
                   //提示
                   UILabel* messageLabel = [UILabel new];
                   messageLabel.text = self.model.activeDes;
                   messageLabel.textColor = [UIColor colorWithHex:0xfff2c3];
                   messageLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
                   messageLabel.textAlignment = NSTextAlignmentCenter;
                   [_openedView addSubview:messageLabel];
                   [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                       make.bottom.equalTo(timeLabel.mas_top).offset(-8 * WIDTHRADIU);
                       make.centerX.equalTo(self->_openedView);
                   }];
        }else if (self.type == KKActivityRedPackageTypeQRMoney || self.type == KKActivityRedPackageTypeQROilAndEgg){
            
            //领福利按钮
            UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            confirmBtn.backgroundColor = [UIColor colorWithHex:0xfcdb93];
            [confirmBtn setTitle:@"领福利" forState:UIControlStateNormal];
            [confirmBtn setTitleColor:[UIColor colorWithHex:0xa41d1f] forState:UIControlStateNormal];
            confirmBtn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
            confirmBtn.layer.cornerRadius = 15 * WIDTHRADIU;
            [confirmBtn addTarget:self action:@selector(confirmBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [_openedView addSubview:confirmBtn];
            [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.offset(- 10 * WIDTHRADIU);
                make.centerX.equalTo(self->_openedView);
                make.width.offset(230 * WIDTHRADIU);
                make.height.offset(50 * WIDTHRADIU);
            }];
            
            //提示
            UILabel* messageLabel = [UILabel new];
            messageLabel.text = @"微信扫码进群领福利";
            messageLabel.textColor = [UIColor colorWithHex:0xfff2c3];
            messageLabel.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
            messageLabel.textAlignment = NSTextAlignmentCenter;
            [_openedView addSubview:messageLabel];
            [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(confirmBtn.mas_top).offset(-13 * WIDTHRADIU);
                make.centerX.equalTo(self->_openedView);
            }];
            
            UIImageView *qrImg = [[UIImageView alloc]init];
            //qrImg.image = [UIImage imageNamed:@"save_qrcode"];
            [qrImg sd_setImageWithURL:[NSURL URLWithString:self.model.activeImagePath] placeholderImage:[UIImage imageNamed:@"save_qrcode"]];
            [_openedView addSubview:qrImg];
            [qrImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.equalTo(self->_openedView);
                make.bottom.equalTo(messageLabel.mas_top).offset(-8 * WIDTHRADIU);
                make.width.offset(120 * WIDTHRADIU);
                make.height.offset(120 * WIDTHRADIU);
            }];
            
            
            
        }
        
       
        

        
    }
    return _openedView;
}

- (UIView *)openedView2
{
    if (!_openedView2) {
         _openedView2 = [[UIView alloc]init];
        _openedView2.frame = CGRectMake(14.5 * WIDTHRADIU, 8 * WIDTHRADIU, 291 * WIDTHRADIU, 325 * WIDTHRADIU);
        //背景图
        UIImageView*backImg = [[UIImageView alloc]initWithFrame:_openedView2.bounds];
        backImg.image = [UIImage imageNamed:@"save_signSuccess"];
        
        [_openedView2 addSubview:backImg];
        
        //标题
       UILabel* lb_title = [UILabel new];
       lb_title.text = @"报名成功";
       lb_title.textColor = [UIColor whiteColor];
       lb_title.font = [UIFont boldSystemFontOfSize:28 * WIDTHRADIU];
       lb_title.textAlignment = NSTextAlignmentCenter;
       [_openedView2 addSubview:lb_title];
       [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
           make.top.offset(136 * WIDTHRADIU);
           make.centerX.equalTo(self->_openedView2);
       }];
    
        //提示
        UILabel* messageLabel = [UILabel new];
        messageLabel.text = @"稍后会有工作人员加您微信";
        messageLabel.textColor = [UIColor whiteColor];
        messageLabel.font = [UIFont systemFontOfSize:16 * WIDTHRADIU];
        messageLabel.textAlignment = NSTextAlignmentCenter;
        [_openedView2 addSubview:messageLabel];
        [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lb_title.mas_bottom).offset(16 * WIDTHRADIU);
            make.centerX.equalTo(self->_openedView2);
        }];
        
        UILabel* messageLabel2 = [UILabel new];
        messageLabel2.text = @"拉您进入福利领取群";
        messageLabel2.textColor = [UIColor whiteColor];
        messageLabel2.font = [UIFont systemFontOfSize:16 * WIDTHRADIU];
        messageLabel2.textAlignment = NSTextAlignmentCenter;
        [_openedView2 addSubview:messageLabel2];
        [messageLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(messageLabel.mas_bottom).offset(8 * WIDTHRADIU);
            make.centerX.equalTo(self->_openedView2);
        }];
        
        //领福利按钮
        UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        confirmBtn.backgroundColor = [UIColor colorWithHex:0xfcdb93];
        [confirmBtn setTitle:@"查看活动" forState:UIControlStateNormal];
        [confirmBtn setTitleColor:[UIColor colorWithHex:0xa41d1f] forState:UIControlStateNormal];
        confirmBtn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
        confirmBtn.layer.cornerRadius = 15 * WIDTHRADIU;
        [confirmBtn addTarget:self action:@selector(confirmBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_openedView2 addSubview:confirmBtn];
        [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.offset(- 15 * WIDTHRADIU);
            make.centerX.equalTo(self->_openedView2);
            make.width.offset(230 * WIDTHRADIU);
            make.height.offset(50 * WIDTHRADIU);
        }];
        
    }
    return _openedView2;
}

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

@end
