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

#import "MineViewController.h"
#import "SettingViewController.h"
#import "MyAcountViewController.h"
#import "MyBandCardViewController.h"
#import "FeedBackViewController.h"
#import "UIImage+Helper.h"
#import "InvitePartnerViewController.h"
#import "JavencommissionAccountModel.h"



#import "JavenShopModel.h"
@interface MineViewController ()
@property (weak, nonatomic) IBOutlet UILabel *labelTotal;
@property (nonatomic, strong) JavenShopModel *shopModel;
@property (nonatomic, strong) JavencommissionAccountModel *accountModel;
@property (weak, nonatomic) IBOutlet UIImageView *imgViewIcon;
@property (weak, nonatomic) IBOutlet UILabel *labelSignature;
@property (weak, nonatomic) IBOutlet UILabel *labelName;



@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isShowNavigationBar = NO;
    // Do any additional setup after loading the view from its nib.
}

- (void)setUpdata {
    
    WS(weakSelf)
    NSString *strGetResseller = [NSString stringWithFormat:@"commission/getAccount/%@", [UserInfo shareInstance].reseller.uuid];
    [[HTTPCilent shareCilent] GET:strGetResseller parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([responseObject[@"code"] isEqualToNumber:@0]) {
            
            weakSelf.accountModel = [JavencommissionAccountModel modelObjectWithDictionary:responseObject[@"commissionAccount"]];
            self.labelTotal.text = kMoneyFromDouble(weakSelf.accountModel.accumulatedIncome);
        }
        CLog(@"d");
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}

- (IBAction)myAcount:(id)sender {
    CLog(@"myAcount");
    
    MyAcountViewController *acountVC = [[MyAcountViewController alloc] init];
    acountVC.isShowNavigationBar = NO;
    acountVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:acountVC animated:YES];
    
}


//我的银行卡
- (IBAction)myBankCardAction:(id)sender {
    MyBandCardViewController *myBankCardVC = [[MyBandCardViewController alloc] init];
    myBankCardVC.isShowNavigationBar = YES;
    myBankCardVC.hidesBottomBarWhenPushed = YES;
//    myBankCardVC.reseller = self.reseller;
    [self.navigationController pushViewController:myBankCardVC animated:YES];
}

- (IBAction)invitePartner:(id)sender {
    
    InvitePartnerViewController *inviteVC = [[InvitePartnerViewController alloc] init];
    inviteVC.isShowNavigationBar = YES;
    inviteVC.title = @"邀请合伙人";
    inviteVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:inviteVC animated:YES];
}

- (IBAction)actionFeedBack:(id)sender {
    FeedBackViewController *feedbackVC = [[FeedBackViewController alloc] init];
    feedbackVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:feedbackVC animated:YES];
}


//设置
- (IBAction)actionSetting:(id)sender {
    SettingViewController *settingVC = [[SettingViewController alloc] init];
    settingVC.isShowNavigationBar = YES;
    settingVC.reseller = self.reseller;
    settingVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:settingVC animated:YES];
    
}

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

- (void)getReseller{
    WS(weakSelf)
    [[HTTPCilent shareCilent] GET:[NSString stringWithFormat:@"reseller/get/%@", [UserInfo shareInstance].reseller.uuid] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([responseObject[@"code"] isEqualToNumber:@0]) {
            weakSelf.reseller = [JavenResellerBigModel modelObjectWithDictionary:responseObject[@"reseller"]];
            
            [weakSelf.imgViewIcon sd_setImageWithURL:[NSURL URLWithString:weakSelf.reseller.portrait] placeholderImage:kUserIconPlaceHolderImage];
            weakSelf.labelSignature.text = weakSelf.reseller.internalBaseClassDescription;
            weakSelf.labelName.text = weakSelf.reseller.name;
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self setUpdata];
    [self getReseller];
}
/*
#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
