//
//  InvitePartnerViewController.m
//  ALand
//
//  Created by Z on 16/4/21.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "InvitePartnerViewController.h"
#import "SeeMoreViewController.h"
@interface InvitePartnerViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *btnInvite;

@end

@implementation InvitePartnerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpWebView];
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"更多" style:UIBarButtonItemStyleDone target:self action:@selector(actionSeeMore)];
    rightBtn.tintColor = kTextColorDarkGray;
    self.navigationItem.rightBarButtonItem = rightBtn;
    
}

- (void)setUpWebView {
    NSString *inviteWebUrl = [NSString stringWithFormat:@"%@Wap/visit.html", [UserInfo shareInstance].webShopBaseUrl];
//    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:inviteWebUrl]];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:inviteWebUrl] cachePolicy:NSURLRequestReloadRevalidatingCacheData timeoutInterval:10];
    UIWebView *webView = [UIWebView new];
    webView.delegate = self;
    webView.backgroundColor = kBacroundColor;
    [webView loadRequest:request];
    [self.view addSubview:webView];
    webView.sd_layout.topSpaceToView(self.view, 0).leftSpaceToView(self.view, 0).rightSpaceToView(self.view, 0).bottomSpaceToView(self.btnInvite, 0);
}

#pragma mark =========== webView delegate ===========
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [MBProgressHUD showHUDAddedTo:webView animated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [MBProgressHUD hideHUDForView:webView];
}

- (void)actionSeeMore {
    SeeMoreViewController *seeMoreVC = [[SeeMoreViewController alloc] init];
    seeMoreVC.isShowNavigationBar = YES;
    [self.navigationController pushViewController:seeMoreVC animated:YES];
}


- (IBAction)invitePartner:(id)sender {
    
    [[ShareInstance shareInstace] invitePartner];
    
}

- (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
