//
//  InvoiceRecordWebVC.m
//  Open
//
//  Created by qinxuyang on 2021/12/1.
//  Copyright © 2021 QXY. All rights reserved.
//

#import "InvoiceRecordWebVC.h"
#import <WebKit/WebKit.h>
@interface InvoiceRecordWebVC ()<WKUIDelegate, WKNavigationDelegate, UIScrollViewDelegate>

@property (nonatomic, retain) WKWebView *wkWebView;

@end

@implementation InvoiceRecordWebVC
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithHex:0xf2f2f2];
    
    [self configNav];
    
    [self webviewStart];
}
- (void)configNav
{
   UIView*nav = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cl_kNavigationBarHeight)];
    nav.backgroundColor = [UIColor colorWithHex:0x086ed7];
    [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(44);
    }];
    
    UILabel*titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"发票信息";
    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(44);
    }];
}
- (void)backClick{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)webviewStart
{
    UIImageView *invoimage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, ScreenWidth - 20, 200)];
    invoimage.center = self.view.center;
    [invoimage sd_setImageWithURL:[NSURL URLWithString:self.url]];
    [self.view addSubview:invoimage];
    
//    _wkWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-cl_kNavigationBarHeight)];
//    _wkWebView.UIDelegate = self;
//    _wkWebView.navigationDelegate = self;
//    _wkWebView.scrollView.scrollEnabled = YES;
//    _wkWebView.scrollView.delegate = self;
//    [self.wkWebView addSubview:_wkWebView];
//
//    // 加载本地PDF
//    [self loadDocument:self.url inView:self.wkWebView];
}
//#pragma mark  WKWebView代理
///* 页面开始加载 */
//- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
//  
//}
///* 开始返回内容 */
//- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{
//    
//}
///* 页面加载完成 */
//- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
//  
//}
///* 页面加载失败 */
//- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation{
//  
//    
//}
//-(void)loadDocument:(NSString *)documentName inView:(WKWebView *)webView
//{
//    documentName = [documentName stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
//    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:documentName]];
//    [webView loadRequest:request];
//}
@end
