//
//  DropDownMenuView.m
//  KKCivilAd
//
//  Created by 雷俊博 on 2019/11/29.
//  Copyright © 2019 雷俊博. All rights reserved.
//

#import "DropDownMenuView.h"
#import "ZSButton.h"
#import "UIView+LXShadowPath.h"
#import "CYAddressSelectedView.h"
#import "UIView+frameAdjust.h"

@interface DropDownMenuView ()<UIGestureRecognizerDelegate,UITextFieldDelegate,CZHTagsViewDelegate, CZHTagsViewDataSource,UIScrollViewDelegate>
{
    ZSButton *customBtn;
    
    NSString *idNumber;
    NSString *verifyType;
    NSString *matchState;
    CZHTagsView* tagView1;
    CZHTagsView* tagView2;
    
    NSString* selectTypeStrs;
    
    NSString* selectResult;
    
}

@property (nonatomic, strong)UIScrollView *scrollView;

@property (nonatomic, strong)UIView *backgroundView;

@property (nonatomic, strong)UIView *whiteView;

@property (nonatomic, strong)UILabel *lb_IdTitle;

@property (nonatomic, strong)UITextField *tf_id;

@property (nonatomic, strong)UILabel *lb_type;

@property (nonatomic, strong)UITextField *tf_type;

@property (nonatomic, strong)UILabel *lb_result;

@property (nonatomic, strong)UITextField *tf_result;

@property (nonatomic, strong)UIButton *cancelBtn;

@property (nonatomic, strong)UIButton *confirmBtn;

@end

@implementation DropDownMenuView
#pragma mark - life cycle
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, cl_kNavigationBarHeight, ScreenWidth, 45);
        [self creatUI];
        [self LX_SetShadowPathWith:[UIColor colorWithHex:0xd9d9d9] shadowOpacity:0.5 shadowRadius:0 shadowSide:LXShadowPathBottom shadowPathWidth:1.5];
        idNumber = @"";
        verifyType = @"";
        matchState = @"";
    }
    return self;
}

- (void)creatUI
{
    ZSButton *btn = [ZSButton buttonWithType:UIButtonTypeCustom];
    btn.frame = self.bounds;
    [btn setTitle:@"条件筛选" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor colorWithHex:0x808080] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"pullDownImage"] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:15];
    btn.imageSize = CGSizeMake(13, 7);
    btn.customSpace = 4;
    btn.customstyle = ZSButtonCustomStylePicRight;
    [btn addTarget:self action:@selector(handleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    
    customBtn = btn;
}


#pragma mark - UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ([touch.view isDescendantOfView:self.whiteView]) {
    return NO;
}
return YES;
}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    WeakSelf
    if (textField == self.tf_id) {
        return YES;
    }else if(textField == self.tf_type){
//        Dialog().wTypeSet(DialogTypeSelect)
//        .wEventFinishSet(^(id anyID, NSIndexPath *path, DialogType type) {
//            NSLog(@"%@ %@",anyID,path);
//        })
//        .wTitleSet(@"认证类型").wTitleColorSet([UIColor redColor]).wTitleFontSet(16.0)
//        .wDataSet(@[@"游泳",@"打篮球",@"打羽毛球",@"爬山",@"踢足球",@"乒乓球"])
//        .wStart();
        
        [CYAddressSelectedView showAddressPickerWithTitle:@"请选择认证类型" data:self.types  addressType:AddressTypeAuthenticationType resultBlock:^(NSDictionary * _Nonnull selectValue) {
                   NSLog(@"认证类型:%@",selectValue);
                  weakSelf.tf_type.text = selectValue[@"value"];
            self->verifyType = [NSString stringWithFormat:@"%@",selectValue[@"code"]];

               }];
    }else if(textField == self.tf_result){
        
        NSArray *array = @[@{@"Id":@0,@"name":@"成功"},@{@"Id":@2,@"name":@"失败"},@{@"Id":@3,@"name":@"审核中"}];
        [CYAddressSelectedView showAddressPickerWithTitle:@"请选择认证结果" data:array addressType:AddressTypeAuthenticationResult resultBlock:^(NSDictionary * _Nonnull selectValue) {
            NSLog(@"认证结果:%@",selectValue);
           weakSelf.tf_result.text = selectValue[@"name"];
           self->matchState = [NSString stringWithFormat:@"%@",selectValue[@"Id"]];
        }];
    }
    
    [self.superview endEditing:YES];
    
    return NO;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    
    [textField resignFirstResponder];
    return YES;
}


#pragma mark - CZHTagsViewDataSource
- (NSArray *)czh_tagsArrayInTagsView:(CZHTagsView *)tagsView {
    
    if (tagsView == tagView1) {
        NSMutableArray* messageArray = [NSMutableArray array];
        for (NSDictionary* dic in self.types) {
            [messageArray addObject:dic[@"value"]];
        }
        
        return messageArray;
    }
    
    NSMutableArray* messageArray = [NSMutableArray array];
     NSArray *array = @[@{@"Id":@500,@"name":@"全部"},@{@"Id":@0,@"name":@"成功"},@{@"Id":@2,@"name":@"失败"},@{@"Id":@3,@"name":@"审核中"}];
    for (NSDictionary* dic in array) {
        [messageArray addObject:dic[@"name"]];
    }
    
    return messageArray;
    
}



#pragma mark - CZHTagsViewDelegate
- (CGFloat)czh_heightForItemInTagsView:(CZHTagsView *)tagsView {
    return 30;
}

- (CGFloat)czh_marginHeightForRowInTagsView:(CZHTagsView *)tagsView {
    return 10;
}

- (CGFloat)czh_marginWithForItemInTagsView:(CZHTagsView *)tagsView {
    return 15;
}

- (UIEdgeInsets)czh_insetForTagsView:(CZHTagsView *)tagsView {
    return UIEdgeInsetsMake(10, 20, 10, 10);
}


- (UIColor *)czh_selectBackgroundColorForItemInTagsView:(CZHTagsView *)tagsView {
    return K_MainColor;
}

- (UIColor *)czh_selectTextColorForItemInTagsView:(CZHTagsView *)tagsView {
    return [UIColor whiteColor];
}

- (UIColor *)czh_selectBorderColorForItemInTagsView:(CZHTagsView *)tagsView {
    return [UIColor clearColor];
}

- (void)czh_tagsView:(CZHTagsView *)tagsView didSelectItemWithSelectTagsArray:(NSArray *)selectTagsArray {
    
    NSString *string = [selectTagsArray componentsJoinedByString:@","];
    
    NSLog(@"---选中的字符串==%@", string);
    
    
    if (tagsView == tagView1) {
        NSMutableArray* slectArray = [NSMutableArray array];
        for (int i = 0; i < selectTagsArray.count; i++) {
           NSString*tagTitle = selectTagsArray[i];
            for (NSDictionary* dic in self.types) {
                if ([tagTitle isEqualToString:dic[@"value"]]) {
                    [slectArray addObject:dic];
                    break;
                }
            }
            
        }
        
        selectTypeStrs = nil;
        for (NSDictionary* dic in slectArray) {
            if (selectTypeStrs == nil) {
                selectTypeStrs =[NSString stringWithFormat:@"%@",dic[@"code"]];
            }else{
                selectTypeStrs =[NSString stringWithFormat:@"%@,%@",selectTypeStrs,dic[@"code"]];
            }
            
        }
        
        NSLog(@"认证类型:%@",slectArray);
        NSLog(@"认证类型code:%@",selectTypeStrs);
    }
    
    if (tagsView == tagView2) {
        NSArray *array = @[@{@"Id":@500,@"name":@"全部"},@{@"Id":@0,@"name":@"成功"},@{@"Id":@2,@"name":@"失败"},@{@"Id":@3,@"name":@"审核中"}];
        NSMutableArray* slectArray = [NSMutableArray array];
               for (int i = 0; i < selectTagsArray.count; i++) {
                  NSString*tagTitle = selectTagsArray[i];
                   for (NSDictionary* dic in array) {
                       if ([tagTitle isEqualToString:dic[@"name"]]) {
                           [slectArray addObject:dic];
                           break;
                       }
                   }
                   
               }
        
        
        selectResult = nil;
        for (NSDictionary* dic in slectArray) {
            if (selectResult == nil) {
                selectResult =[NSString stringWithFormat:@"%@",dic[@"Id"]];
            }else{
                selectResult =[NSString stringWithFormat:@"%@,%@",selectResult,dic[@"Id"]];
            }
            
        }
        if ([selectResult isEqualToString:@"500"]) {
            selectResult = @"";
        }
               NSLog(@"认证结果:%@",slectArray);
               NSLog(@"认证结果code:%@",selectResult);
    }
}

- (BOOL)czh_shouldSelectItemIntagsView:(CZHTagsView *)tagsView
{
    return YES;
}


#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGPoint point = scrollView.contentOffset;
    if (point.y <= 0) {
        scrollView.contentOffset = CGPointMake(point.x, 0);
    }
}

#pragma mark - event response
- (void)handleBtnAction:(ZSButton *)sender {
    
     sender.selected = !sender.selected;
     [sender imageViewAnimateRotateWithState:sender.selected];
    
    if (sender.selected) {
        
    [self.superview addSubview:self.scrollView];
      
//           CGRect frame = self.whiteView.frame;
//           frame.size.height = 350;
//           self.whiteView.frame = frame;
        
//        [_whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.right.offset(0);
//            make.bottom.equalTo(self.confirmBtn.mas_bottom).offset(30);
//        }];
       // _scrollView.contentSize = CGSizeMake(ScreenWidth, _whiteView.maxY + 50);
    }else{
//        [self.whiteView removeFromSuperview];
//        [self.scrollView removeFromSuperview];
//        self.whiteView = nil;
//        self.scrollView = nil;
        [UIView animateWithDuration:0.1 animations:^{
            CGRect frame = self.whiteView.frame;
            frame.size.height = 0;
            self.whiteView.frame = frame;
            
            self.backgroundView.alpha = 0;
            self.lb_IdTitle.alpha = 0;
            self.tf_id.alpha = 0;
            self.lb_type.alpha = 0;
            self.tf_type.alpha = 0;
            self.lb_result.alpha = 0;
            self.tf_result.alpha = 0;
            self.cancelBtn.alpha = 0;
            self.confirmBtn.alpha = 0;
        } completion:^(BOOL finished) {
            [self.lb_IdTitle removeFromSuperview];
            [self.tf_id removeFromSuperview];
            [self.lb_type removeFromSuperview];
            [self.tf_type removeFromSuperview];
            [self.lb_result removeFromSuperview];
            [self.tf_result removeFromSuperview];
            [self.cancelBtn removeFromSuperview];
            [self.confirmBtn removeFromSuperview];
            [self.whiteView removeFromSuperview];
            [self.backgroundView removeFromSuperview];
            [self.scrollView removeFromSuperview];
            self.whiteView = nil;
            self.scrollView = nil;
            self.backgroundView = nil;
            self.lb_IdTitle = nil;
            self.tf_id = nil;
            self.lb_type = nil;
            self.tf_type = nil;
            self.lb_result = nil;
            self.tf_result = nil;
            self.confirmBtn = nil;
            self.cancelBtn = nil;

        }];
    }
    
    
}
- (void)didTapBackgroundView:(UITapGestureRecognizer *)sender
{
    [self handleBtnAction:customBtn];
}
- (void)didTapWhiteView:(UITapGestureRecognizer *)sender
{
    [self.superview endEditing:YES];
}

- (void)btnClick:(UIButton *)sender
{
    
    if (sender == self.confirmBtn) {
        if (self.tf_id.text.length != 0) {
            if (![IDCardNumber_Validate isValidateIDCardString:self.tf_id.text]) {
                [SVProgressHUD showErrorWithStatus:@"请输入规范的身份证号码"];
                return;
            }
        }
        idNumber = self.tf_id.text;
        sender.userInteractionEnabled = NO;
        
        NSLog(@"thread:%@",[NSThread currentThread]);
        if (self.delegate && [self.delegate respondsToSelector:@selector(queryDataWithIdNumber:verifyType:matchState:)]) {
            
            if (selectTypeStrs == nil) {
                for (NSDictionary* dic in self.types) {
                        if (selectTypeStrs == nil) {
                                selectTypeStrs =[NSString stringWithFormat:@"%@",dic[@"code"]];
                            }else{
                                selectTypeStrs =[NSString stringWithFormat:@"%@,%@",selectTypeStrs,dic[@"code"]];
                        }
                }
            }
            
            [self.delegate queryDataWithIdNumber:idNumber verifyType:selectTypeStrs ?selectTypeStrs :@"" matchState:selectResult?selectResult:@""];
        }
        
        
        idNumber = @"";
        verifyType = @"";
        matchState = @"";
        selectTypeStrs = nil;
        selectResult = nil;
        
    }
    
    [self handleBtnAction:customBtn];
}

#pragma mark - getters and setters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, cl_kNavigationBarHeight + 46.5, ScreenWidth, (ScreenHeight)-(cl_kNavigationBarHeight)-self.frame.size.height - 1.5)];
        _scrollView.backgroundColor = [UIColor colorWithHex:0x000000 alpha:0.5];
        [_scrollView addSubview:self.backgroundView];
        _scrollView.delegate = self;
        [self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
               make.top.offset(0);
               make.left.offset(0);
               make.right.offset(0);
               make.bottom.offset(0);
        }];
        
        
    }
    return _scrollView;
}

- (UIView *)backgroundView
{
    if (!_backgroundView) {
        _backgroundView = [[UIView alloc]init];
        _backgroundView.backgroundColor = [UIColor clearColor];
        [_backgroundView addSubview:self.whiteView];
        [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);
            make.left.offset(0);
            make.right.offset(0);
            make.bottom.offset(0);
        }];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapBackgroundView:)];
        tap.delegate = self;
        [_backgroundView addGestureRecognizer:tap];
        
    }
    return _backgroundView;
}

- (UIView *)whiteView
{
    if (!_whiteView) {
        _whiteView = [[UIView alloc]init];
        _whiteView.backgroundColor = [UIColor whiteColor];
        _whiteView.userInteractionEnabled = YES;
        [_whiteView addSubview:self.lb_IdTitle];
        [_whiteView addSubview:self.tf_id];
        [_whiteView addSubview:self.lb_type];
       // [_whiteView addSubview:self.tf_type];
        [_whiteView addSubview:self.lb_result];
        [_whiteView addSubview:self.tf_result];
        [_whiteView addSubview:self.cancelBtn];
        [_whiteView addSubview:self.confirmBtn];
        
        
        
        [self.lb_IdTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(20);
            make.left.offset(15);
        }];
        
        [self.tf_id mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.lb_IdTitle.mas_bottom).offset(10);
            make.left.offset(10);
            make.width.offset(ScreenWidth - 20);
            make.right.offset(-10);
            make.height.offset(40);
        }];
        
        [self.lb_type mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.tf_id.mas_bottom).offset(20);
            make.left.offset(10);
        }];
        
//        [self.tf_type mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.lb_type.mas_bottom).offset(10);
//            make.left.offset(10);
//            make.right.offset(-10);
//            make.height.offset(40);
//        }];
        
        CZHTagsView *tags = [[CZHTagsView alloc] initWithFrame:CGRectMake(0, 130, ScreenWidth, 0) style:CZHTagsViewStyleFit selectMode:CZHTagsViewSelectModeMulti displayMode:CZHTagsViewDisplayModePaddingFirst];
        tags.backgroundColor = [UIColor whiteColor];
        tags.dataSource = self;
        tags.delegate = self;
        tagView1 = tags;
        [_whiteView addSubview:tags];
        
        [tags reloadData];
        
        
        
        [self.lb_result mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(tags.mas_bottom).offset(20);
            make.left.offset(10);
        }];
        
        CZHTagsView *tags1 = [[CZHTagsView alloc] initWithFrame:CGRectMake(0, tags.maxY + 45, ScreenWidth, 0) style:CZHTagsViewStyleDefault];
        tags1.backgroundColor = [UIColor whiteColor];
        tags1.dataSource = self;
        tags1.delegate = self;
        tagView2 = tags1;
        [_whiteView addSubview:tags1];
        
        
        [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(tags1.mas_bottom).offset(20);
             make.left.offset(10);
             make.width.equalTo(self.confirmBtn.mas_width).multipliedBy(0.5);
             make.height.offset(45);
             make.bottom.offset(-30);
        }];
        
        [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(tags1.mas_bottom).offset(20);
            make.left.equalTo(self.cancelBtn.mas_right).offset(20);
            make.right.offset(-10);
            make.height.offset(45);
            make.bottom.offset(-30);
        }];
        
        
        
        
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapWhiteView:)];
              
        [_whiteView addGestureRecognizer:tap];
        
        
    }
    return _whiteView;
}

- (UILabel *)lb_IdTitle
{
    if (!_lb_IdTitle) {
        _lb_IdTitle = [[UILabel alloc]init];
        _lb_IdTitle.text = @"身份证号";
        _lb_IdTitle.textColor = [UIColor colorWithHex:0x4d4d4d];
        _lb_IdTitle.font = [UIFont systemFontOfSize:16];
    }
    return _lb_IdTitle;
}

- (UITextField *)tf_id
{
    if (!_tf_id) {
        _tf_id = [[UITextField alloc]init];
        _tf_id.borderStyle = UITextBorderStyleRoundedRect;
        if (@available(iOS 13.0,*)) {
            NSMutableAttributedString *placeholderFont = [[NSMutableAttributedString alloc] initWithString:@"请输入您要查询的身份证号" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0 * WIDTHRADIU],NSForegroundColorAttributeName : [UIColor colorWithHex:0xb3b3b3]}];
                   
                _tf_id.attributedPlaceholder = placeholderFont;
        }else{
             _tf_id.placeholder = @"请输入您要查询的身份证号";
             [_tf_id setValue:[UIFont systemFontOfSize:14.0 * WIDTHRADIU] forKeyPath:@"_placeholderLabel.font"];
            [_tf_id setValue:[UIColor colorWithHex:0xb3b3b3] forKeyPath:@"_placeholderLabel.textColor"];
        }
        _tf_id.delegate = self;
    }
    return _tf_id;
}
- (UILabel *)lb_type
{
    if (!_lb_type) {
        _lb_type = [[UILabel alloc]init];
        _lb_type.text = @"认证类型";
        _lb_type.textColor = [UIColor colorWithHex:0x4d4d4d];
        _lb_type.font = [UIFont systemFontOfSize:16];
    }
    return _lb_type;
}

- (UITextField *)tf_type
{
    if (!_tf_type) {
        _tf_type = [[UITextField alloc]init];
        _tf_type.borderStyle = UITextBorderStyleRoundedRect;
        if (@available(iOS 13.0,*)) {
            NSMutableAttributedString *placeholderFont = [[NSMutableAttributedString alloc] initWithString:@"请输入您要查询的类型" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0 * WIDTHRADIU],NSForegroundColorAttributeName : [UIColor colorWithHex:0xb3b3b3]}];
                   
                _tf_type.attributedPlaceholder = placeholderFont;
        }else{
             _tf_type.placeholder = @"请输入您要查询的类型";
             [_tf_type setValue:[UIFont systemFontOfSize:14.0 * WIDTHRADIU] forKeyPath:@"_placeholderLabel.font"];
            [_tf_type setValue:[UIColor colorWithHex:0xb3b3b3] forKeyPath:@"_placeholderLabel.textColor"];
        }
        UIView *rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 53, 40)];
               
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 16.5, 13, 7)];
        imageView.image = [UIImage imageNamed:@"pullDownImage"];
               
        [rightView addSubview:imageView];
        
        _tf_type.rightView = rightView;
        _tf_type.rightViewMode =  UITextFieldViewModeAlways;
        
        _tf_type.delegate = self;
    }
    return _tf_type;
}

- (UILabel *)lb_result
{
    if (!_lb_result) {
        _lb_result = [[UILabel alloc]init];
        _lb_result.text = @"认证结果";
        _lb_result.textColor = [UIColor colorWithHex:0x4d4d4d];
        _lb_result.font = [UIFont systemFontOfSize:16];
    }
    return _lb_result;
}

- (UITextField *)tf_result
{
    if (!_tf_result) {
        _tf_result = [[UITextField alloc]init];
        _tf_result.borderStyle = UITextBorderStyleRoundedRect;
        if (@available(iOS 13.0,*)) {
            NSMutableAttributedString *placeholderFont = [[NSMutableAttributedString alloc] initWithString:@"请输入您要查询的结果" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0 * WIDTHRADIU],NSForegroundColorAttributeName : [UIColor colorWithHex:0xb3b3b3]}];
                   
                _tf_result.attributedPlaceholder = placeholderFont;
        }else{
             _tf_result.placeholder = @"请输入您要查询的结果";
             [_tf_result setValue:[UIFont systemFontOfSize:14.0 * WIDTHRADIU] forKeyPath:@"_placeholderLabel.font"];
            [_tf_result setValue:[UIColor colorWithHex:0xb3b3b3] forKeyPath:@"_placeholderLabel.textColor"];
        }
        
        UIView *rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 53, 40)];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 16.5, 13, 7)];
        imageView.image = [UIImage imageNamed:@"pullDownImage"];
        
        [rightView addSubview:imageView];
 
        _tf_result.rightView = rightView;
        _tf_result.rightViewMode =  UITextFieldViewModeAlways;
        
        _tf_result.delegate = self;
    }
    return _tf_result;
}

- (UIButton *)cancelBtn
{
    if (!_cancelBtn) {
        _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelBtn setTitle:@"取消筛选" forState:UIControlStateNormal];
        [_cancelBtn setTitleColor:[UIColor colorWithHex:0x808080] forState:UIControlStateNormal];
        [_cancelBtn setBackgroundColor:[UIColor colorWithHex:0xf3f3f3]];
        _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        _cancelBtn.layer.cornerRadius  = 5;
        _cancelBtn.layer.borderWidth = 0.5;
        _cancelBtn.layer.borderColor = [UIColor colorWithHex:0xcccccc].CGColor;
        
        [_cancelBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelBtn;
}

- (UIButton *)confirmBtn
{
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_confirmBtn setTitle:@"确定筛选" forState:UIControlStateNormal];
        [_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_confirmBtn setBackgroundColor:K_MainColor];
        _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        _confirmBtn.layer.cornerRadius  = 5;
        [_confirmBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _confirmBtn;
}

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

@end
