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

#import "MyAcountViewController.h"
#import "JavenShopModel.h"
#import "MyAcountHelfViewController.h"
#import "MyBillViewController.h"
@interface MyAcountViewController ()
@property (nonatomic, strong) JavenShopModel *shopModel;
/** 待确认 */
@property (weak, nonatomic) IBOutlet UILabel *labelUnconfirmedBalance;
/** 可提现 */
@property (weak, nonatomic) IBOutlet UILabel *labelLalanc;
/** 已提现 */
@property (weak, nonatomic) IBOutlet UILabel *labelWithdrawAmount;
/** 累计收入 */
@property (weak, nonatomic) IBOutlet UILabel *labelAccumulatedIncome;
/** 账户余额 */
@property (weak, nonatomic) IBOutlet UILabel *labelTotalBalance;
/** 自销收入 */
@property (weak, nonatomic) IBOutlet UILabel *labelSelfSalesIncome;
/** 团队收入 */
@property (weak, nonatomic) IBOutlet UILabel *labelTeamIncome;

@end

@implementation MyAcountViewController

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

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)setUpdata {
    
    WS(weakSelf)
    [[HTTPCilent shareCilent] GET:[NSString stringWithFormat:@"commission/getAccount/%@", [UserInfo shareInstance].uuid] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (kIsResponseSuccess(responseObject)) {
            
            CLog(@"%p",weakSelf.shopModel);
            NSDictionary *dic = responseObject[@"commissionAccount"];
            weakSelf.labelLalanc.text = kMoneyFromIDNumber(dic[@"balance"]);
            weakSelf.labelWithdrawAmount.text = kMoneyFromIDNumber(dic[@"withdrawAmount"]);
            weakSelf.labelUnconfirmedBalance.text = kMoneyFromIDNumber(dic[@"unconfirmedBalance"]);
            weakSelf.labelAccumulatedIncome.text = kMoneyFromIDNumber(dic[@"accumulatedIncome"]);
            weakSelf.labelSelfSalesIncome.text = kMoneyFromIDNumber(dic[@"selfIncome"]);
            weakSelf.labelTeamIncome.text = kMoneyFromIDNumber(dic[@"teamIncome"]);
            double unconfirmBalance = [dic[@"unconfirmedBalance"] doubleValue];
            double balance = [dic[@"balance"] doubleValue];
            weakSelf.labelTotalBalance.text = [NSString stringWithFormat:@"%.2f", (balance + unconfirmBalance)];
        }else{
            
        }
        //[weakSelf.viewHomeTop updateTopViewInfo:weakSelf.shopModel];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}


- (IBAction)actionHelp:(id)sender {
    MyAcountHelfViewController *helpVC = [[MyAcountHelfViewController alloc] init];
    helpVC.isShowNavigationBar = YES;
    [self.navigationController pushViewController:helpVC animated:YES];
    
}

- (IBAction)actionGoBill:(id)sender {
    MyBillViewController *billVC = [[MyBillViewController alloc] init];
    billVC.isShowNavigationBar = YES;
    [self.navigationController pushViewController:billVC animated:YES];
}


- (IBAction)actionBac:(id)sender {
    [self popAction];
}
- (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
