//
//  WatchLoginViewController.m
//  Car
//
//  Created by Javen on 2017/1/10.
//  Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//

#import "WatchLoginViewController.h"
#import "HttpCilent.h"
@interface WatchLoginViewController ()

@end

@implementation WatchLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"授权登录";
    // Do any additional setup after loading the view.
}
- (IBAction)actionLogin:(id)sender {
    [self httpAllowLogin];
}

- (void)httpAllowLogin {
    
    NSDictionary *param = @{@"deviceId":self.device,
                            @"token":self.token};
    WS(weakSelf);
    [kHttp GET:kWatchLogin parameters:param complete:^(id  _Nullable response, NSError * _Nullable error) {
        if (kRsSuccess(response)) {
            [MBProgressHUD j_success:@"登录成功！" complete:^{
                //连续返回两级
                long index = [[weakSelf.navigationController viewControllers] indexOfObject:weakSelf];
                [weakSelf.navigationController popToViewController:[weakSelf.navigationController.viewControllers objectAtIndex:index - 2]
                                                          animated:YES];
            }];
            
        }else{
            kShowRsMsg(response);
            
        }
        
    }];
}

- (IBAction)actionCancel:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}



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