//
//  AgreementViewController.m
//  ALand
//
//  Created by Z on 16/5/9.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "AgreementViewController.h"
#import <WebKit/WebKit.h>

@interface AgreementViewController ()<WKNavigationDelegate>

@end

@implementation AgreementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"经营者入驻协议";
    
    
    WS(weakSelf)
    [[HTTPCilent shareCilent] GET:[NSString stringWithFormat:@"app/getAppConfig/%@", kDomain] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        [weakSelf setUpWebView:responseObject[@"webShopBaseUrl"]];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
    
}

- (void)setUpWebView:(NSString *)url {
    
    NSString *inviteWebUrl = [NSString stringWithFormat:@"%@Wap/visitorXy.html", url];
    
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:inviteWebUrl]];
    WKWebView *webView = [WKWebView new];
    webView.navigationDelegate = self;
    [webView loadRequest:request];
    [self.view addSubview:webView];
    webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    webView.sd_layout.topSpaceToView(self.view, 0).leftSpaceToView(self.view, 0).rightSpaceToView(self.view, 0).bottomSpaceToView(self.view, 0);
}

// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
}

// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
    self.title = webView.title;
    
    [MBProgressHUD hideHUDForView:self.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#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
