//
//  LearningCenterMainViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/16.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "LearningCenterMainViewController.h"
#import "OnlineLearningViewController.h"
#import "ForumViewController.h"

@interface LearningCenterMainViewController ()

@end

@implementation LearningCenterMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addGestureRecognizer];
    [self queryIntegralDetails];
}

#pragma mark - 添加点击
- (void)addGestureRecognizer
{
    [self.comprehensiveDiscussionView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(comprehensiveDiscussionViewClickAction:)]];
    [self.onlineLearningView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onlineLearningViewClickAction:)]];
    [self.breakthroughView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(breakthroughViewClickAction:)]];
}

#pragma mark - 查询积分明细
- (void)queryIntegralDetails
{
    WS(weakSelf);
    [self CreateMBProgressHUDLoding];
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(INTEGRALQUERY),[Shoppersmanager manager].Shoppers.employee.fid];
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithCallClass:weakSelf WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf RemoveMBProgressHUDLoding];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {

            RsScoreDetails *integralDatas = [[RsScoreDetails alloc]initWithDictionary:returnValue[@"data"] error:nil];
            [weakSelf setUpIntegral:integralDatas];

        }else {
            [weakSelf ErrorMBProgressView:returnValue[@"message"]];
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:NETWORK];
    } WithFailureBlock:^(NSError *error) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:error.localizedDescription];
    }];
}

#pragma mark - 积分信息
- (void)setUpIntegral:(RsScoreDetails *)entity
{
    self.currentScoreLabel.text = [NSString stringWithFormat:@"%.0lf",entity.currentScore];
    self.yearRankingLabel.text = [NSString stringWithFormat:@"%ld",entity.annualRanking];
    self.quarterRankingLabel.text = [NSString stringWithFormat:@"%ld",entity.quarterlyRanking];
}

#pragma mark - 综合讨论
- (void)comprehensiveDiscussionViewClickAction:(UITapGestureRecognizer *)sender
{
    ForumViewController *forum = [[[self class] getMainStoryboardClass]instantiateViewControllerWithIdentifier:@"ForumViewController"];
    [self.navigationController pushViewController:forum animated:YES];
}

#pragma mark - 在线学习
- (void)onlineLearningViewClickAction:(UITapGestureRecognizer *)sender
{
    OnlineLearningViewController *onlineLearning = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"OnlineLearningViewController"];
    [self.navigationController pushViewController:onlineLearning animated:YES];
}

#pragma mark - 闯关
- (void)breakthroughViewClickAction:(UITapGestureRecognizer *)sender
{
    
}

















- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end