//
//  WeiJianQueryViewController.m
//  KKCivilAd
//
//  Created by 雷俊博 on 2020/4/15.
//  Copyright © 2020 雷俊博. All rights reserved.
//

#import "WeiJianQueryViewController.h"
//#import "ApplyStateQueryViewController.h"

#import "AuthenticationListViewController.h"

#import "DistrictAuthenticationPersonalInfoController.h"

@interface WeiJianQueryViewController ()<UIScrollViewDelegate>

@property (nonatomic, strong)UIScrollView* scrollView;

@property (nonatomic, strong)UIImageView* img_ShenBao;

@property (nonatomic, strong)UIImageView* img_RenZheng;

@property (nonatomic, strong)UIImageView* img_BuTie;

@end

@implementation WeiJianQueryViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [self.navigationController.navigationBar navBarBackGroundColor:K_MainColor image:nil isOpaque:YES];//颜色
    [self.navigationController.navigationBar navBarBottomLineHidden:YES];
    
    [GTCountSDK trackCountEvent:@"home_zhengwu_authQuery" withArgs:@{}];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self.view addSubview:self.scrollView];
    
    [self configUI];
    
    [self configNav];
}
- (void)configUI
{
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    [self.scrollView addSubview:self.img_ShenBao];
    
    [self.scrollView addSubview:self.img_RenZheng];
    
    [self.scrollView addSubview:self.img_BuTie];
    
    UIImageView*topImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 13 * WIDTHRADIU)];
    topImg.image = [UIImage imageNamed:@"jingtie_topbg"];
    
    [self.scrollView addSubview:topImg];
    
    [self.img_ShenBao mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topImg.mas_bottom).offset(40 * WIDTHRADIU);
        make.width.offset(300 * WIDTHRADIU);
        make.height.offset(160 * WIDTHRADIU);
        make.centerX.equalTo(self.view);
    }];
    
    [self.img_BuTie mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.img_ShenBao.mas_bottom).offset(40 * WIDTHRADIU);
        make.width.offset(300 * WIDTHRADIU);
        make.height.offset(160 * WIDTHRADIU);
        make.centerX.equalTo(self.view);
    }];
    
    
    [self.img_RenZheng mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.img_BuTie.mas_bottom).offset(40 * WIDTHRADIU);
        make.width.offset(300 * WIDTHRADIU);
        make.height.offset(160 * WIDTHRADIU);
        make.centerX.equalTo(self.view);
        make.bottom.offset(-20 * WIDTHRADIU);
    }];
}

- (void)configNav
{
//    UIBarButtonItem * backButtonItem = [[UIBarButtonItem alloc] init];
//    backButtonItem.title = @"返回";
//    self.navigationItem.backBarButtonItem = backButtonItem;
    
    
    UIView*nav = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cl_kNavigationBarHeight)];
    nav.backgroundColor = K_MainColor;
    [self.view addSubview:nav];
    
    UIButton*backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [backBtn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [backBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:4];
    [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    [nav addSubview:backBtn];
    
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.offset(cl_kStatusBarHeight);
        make.width.offset(80);
        make.height.offset(cl_kNavBarHeight);
    }];
    
    UILabel*titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = self.title;
    titleLabel.font = [UIFont boldSystemFontOfSize:17];
    [nav addSubview:titleLabel];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(cl_kStatusBarHeight);
        make.width.offset(80);
        make.height.offset(cl_kNavBarHeight);
    }];
    
}

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



#pragma mark - event response
- (void)backClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)tapClick:(UITapGestureRecognizer *)tap
{
    if (tap.view  == self.img_ShenBao) {
        
        UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        socialRecord*vc=[sb instantiateViewControllerWithIdentifier:@"socialRecord"];
        vc.hidesBottomBarWhenPushed =YES;
        vc.isHomeVC = YES;
        [self.navigationController pushViewController:vc animated:YES];
        //[self searchProgress];
        NSLog(@"申报");
//        ApplyStateQueryViewController* vc = [ApplyStateQueryViewController new];
//        vc.title = @"申报进度查询";
//        [self.navigationController pushViewController:vc animated:YES];
    }else if (tap.view  == self.img_RenZheng){
        NSLog(@"认证");
        AuthenticationListViewController *vc = [[AuthenticationListViewController alloc]init];
        vc.title = @"认证记录";
        vc.hidesBottomBarWhenPushed = YES;

        [self.navigationController pushViewController:vc animated:YES];
    }else if (tap.view == self.img_BuTie) {
        AuthenticationListViewController *vc = [[AuthenticationListViewController alloc]init];
        vc.title = @"认证记录";
        vc.hidesBottomBarWhenPushed = YES;
        vc.type = @"butie";

        [self.navigationController pushViewController:vc animated:YES];
    }
}


-(void)searchProgress{
    
    
    [SearchProgressNet getgetBindIdCardsListHandle:^(SearchProgress *model, NSError *error) {
        
        if (model.code ==0) {
            
            if (model.result.count == 0) {
                UIStoryboard *sbs =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                startProgressViewcontroller *tc=[sbs instantiateViewControllerWithIdentifier:@"startProgressViewcontroller"];
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
            }else{
                UIStoryboard *sbs =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                SearchProgressViewController *tc=[sbs instantiateViewControllerWithIdentifier:@"SearchProgressViewController"];
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
                
            }
        }else
        {
            codeSelected *code = [codeSelected MustTakeReturn:model.code];
            [code returnCodeMethod];
        }
    }];
    
    
    
}

#pragma mark - getters and setters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, cl_kNavigationBarHeight, ScreenWidth, ScreenHeight - cl_kNavigationBarHeight)];
        _scrollView.delegate = self;
        _scrollView.contentSize = CGSizeMake(ScreenWidth,1);
        _scrollView.showsVerticalScrollIndicator = NO;
    }
    return _scrollView;
}

- (UIImageView *)img_ShenBao
{
    if (!_img_ShenBao) {
        _img_ShenBao = [[UIImageView alloc]init];
        _img_ShenBao.image = [UIImage imageNamed:@"shebaoAuthBg"];
        _img_ShenBao.userInteractionEnabled = YES;
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick:)];
        
        [_img_ShenBao addGestureRecognizer:tap];
        
        //双引号图片
        UIImageView* arrImg = [[UIImageView alloc]init];
        arrImg.image = [UIImage imageNamed:@"yinhao"];
        
        //title
        UILabel* lb_title = [[UILabel alloc]init];
        lb_title.text = @"社保认证查询";
        lb_title.textColor = [UIColor whiteColor];
        lb_title.font = [UIFont systemFontOfSize:20 * WIDTHRADIU];
        
        //message
         UILabel* lb_message = [[UILabel alloc]init];
         lb_message.text = @"社保认证结果查询";
         lb_message.textColor = [UIColor whiteColor];
         lb_message.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        //anniu
        UIButton* queryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [queryBtn setTitle:@"立即查看" forState:UIControlStateNormal];
        [queryBtn setTitleColor:K_MainColor forState:UIControlStateNormal];
        queryBtn.backgroundColor = [UIColor whiteColor];
        queryBtn.layer.cornerRadius = 15 * WIDTHRADIU;
        queryBtn.userInteractionEnabled = NO;
        queryBtn.titleLabel.font =[UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        
        [_img_ShenBao addSubview:arrImg];
        [_img_ShenBao addSubview:lb_title];
        [_img_ShenBao addSubview:lb_message];
        [_img_ShenBao addSubview:queryBtn];
        
        [arrImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15 * WIDTHRADIU);
            make.top.offset(15 * WIDTHRADIU);
            make.width.offset(12 * WIDTHRADIU);
            make.height.offset(10 * WIDTHRADIU);
        }];
        
        [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(arrImg.mas_bottom).offset(4 * WIDTHRADIU);
            make.left.equalTo(arrImg.mas_right);
        }];
        
        [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lb_title.mas_bottom).offset(19 * WIDTHRADIU);
            make.left.equalTo(lb_title);
        }];
        
        [queryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lb_title);
            make.top.equalTo(lb_message.mas_bottom).offset(19 * WIDTHRADIU);
            make.width.offset(100 * WIDTHRADIU);
            make.height.offset(30 * WIDTHRADIU);
        }];
        
    }
    return _img_ShenBao;
}

- (UIImageView *)img_RenZheng
{
    if (!_img_RenZheng) {
        _img_RenZheng = [[UIImageView alloc]init];
        _img_RenZheng.image = [UIImage imageNamed:@"tuiyiAuthBg"];
        _img_RenZheng.userInteractionEnabled = YES;
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick:)];
        
        [_img_RenZheng addGestureRecognizer:tap];
        
        //双引号图片
        UIImageView* arrImg = [[UIImageView alloc]init];
        arrImg.image = [UIImage imageNamed:@"yinhao"];
        
        //title
        UILabel* lb_title = [[UILabel alloc]init];
        lb_title.text = @"优抚核查查询(军人)";
        lb_title.textColor = [UIColor whiteColor];
        lb_title.font = [UIFont systemFontOfSize:20 * WIDTHRADIU];
        
        //message
         UILabel* lb_message = [[UILabel alloc]init];
         lb_message.text = @"优抚核查结果查询";
         lb_message.textColor = [UIColor whiteColor];
         lb_message.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        //anniu
        UIButton* queryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [queryBtn setTitle:@"立即查看" forState:UIControlStateNormal];
        [queryBtn setTitleColor:K_MainColor forState:UIControlStateNormal];
        queryBtn.backgroundColor = [UIColor whiteColor];
        queryBtn.layer.cornerRadius = 15 * WIDTHRADIU;
        queryBtn.userInteractionEnabled = NO;
        queryBtn.titleLabel.font =[UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        
        [_img_RenZheng addSubview:arrImg];
        [_img_RenZheng addSubview:lb_title];
        [_img_RenZheng addSubview:lb_message];
        [_img_RenZheng addSubview:queryBtn];
        
        [arrImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15 * WIDTHRADIU);
            make.top.offset(15 * WIDTHRADIU);
            make.width.offset(12 * WIDTHRADIU);
            make.height.offset(10 * WIDTHRADIU);
        }];
        
        [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(arrImg.mas_bottom).offset(4 * WIDTHRADIU);
            make.left.equalTo(arrImg.mas_right);
        }];
        
        [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lb_title.mas_bottom).offset(19 * WIDTHRADIU);
            make.left.equalTo(lb_title);
        }];
        
        [queryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lb_title);
            make.top.equalTo(lb_message.mas_bottom).offset(19 * WIDTHRADIU);
            make.width.offset(100 * WIDTHRADIU);
            make.height.offset(30 * WIDTHRADIU);
        }];
    }
    return _img_RenZheng;
}


- (UIImageView *)img_BuTie
{
    if (!_img_BuTie) {
        _img_BuTie = [[UIImageView alloc]init];
        _img_BuTie.image = [UIImage imageNamed:@"butieQuerybg"];
        _img_BuTie.userInteractionEnabled = YES;
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick:)];
        
        [_img_BuTie addGestureRecognizer:tap];
        
        //双引号图片
        UIImageView* arrImg = [[UIImageView alloc]init];
        arrImg.image = [UIImage imageNamed:@"yinhao"];
        
        //title
        UILabel* lb_title = [[UILabel alloc]init];
        lb_title.text = @"补贴认证查询";
        lb_title.textColor = [UIColor whiteColor];
        lb_title.font = [UIFont systemFontOfSize:20 * WIDTHRADIU];
        
        //message
         UILabel* lb_message = [[UILabel alloc]init];
         lb_message.text = @"补贴认证结果查询";
         lb_message.textColor = [UIColor whiteColor];
         lb_message.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        //anniu
        UIButton* queryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [queryBtn setTitle:@"立即查看" forState:UIControlStateNormal];
        [queryBtn setTitleColor:K_MainColor forState:UIControlStateNormal];
        queryBtn.backgroundColor = [UIColor whiteColor];
        queryBtn.layer.cornerRadius = 15 * WIDTHRADIU;
        queryBtn.userInteractionEnabled = NO;
        queryBtn.titleLabel.font =[UIFont systemFontOfSize:15 * WIDTHRADIU];
        
        
        [_img_BuTie addSubview:arrImg];
        [_img_BuTie addSubview:lb_title];
        [_img_BuTie addSubview:lb_message];
        [_img_BuTie addSubview:queryBtn];
        
        [arrImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15 * WIDTHRADIU);
            make.top.offset(15 * WIDTHRADIU);
            make.width.offset(12 * WIDTHRADIU);
            make.height.offset(10 * WIDTHRADIU);
        }];
        
        [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(arrImg.mas_bottom).offset(4 * WIDTHRADIU);
            make.left.equalTo(arrImg.mas_right);
        }];
        
        [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lb_title.mas_bottom).offset(19 * WIDTHRADIU);
            make.left.equalTo(lb_title);
        }];
        
        [queryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lb_title);
            make.top.equalTo(lb_message.mas_bottom).offset(19 * WIDTHRADIU);
            make.width.offset(100 * WIDTHRADIU);
            make.height.offset(30 * WIDTHRADIU);
        }];
    }
    return _img_BuTie;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
