LearningCenterMainViewController.m 5.32 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9
//
//  LearningCenterMainViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/16.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "LearningCenterMainViewController.h"
10
#import "OnlineLearningViewController.h"
11
#import "ForumViewController.h"
12
#import "EmigratedMainViewController.h"
曹云霄's avatar
曹云霄 committed
13
#import "PerfectInformationViewController.h"
14
#import "ForumTypeViewController.h"
曹云霄's avatar
曹云霄 committed
15

16
@interface LearningCenterMainViewController ()
17

曹云霄's avatar
曹云霄 committed
18 19 20 21 22

@end

@implementation LearningCenterMainViewController

曹云霄's avatar
曹云霄 committed
23 24 25 26 27
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

28 29 30 31 32 33 34 35
#pragma mark -渲染完成
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
36
    [self queryIntegralDetails];
37 38 39 40 41 42 43 44 45 46 47 48 49
}

#pragma mark -视图即将消失
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    // 开启
    self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = YES;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

50 51 52 53 54
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

曹云霄's avatar
曹云霄 committed
55 56
- (void)viewDidLoad {
    [super viewDidLoad];
57
    
58
    [self uiConfigAction];
59 60 61
    [self addGestureRecognizer];
}

62 63
#pragma mark -UI
- (void)uiConfigAction
64
{
曹云霄's avatar
曹云霄 committed
65 66 67 68 69 70 71
    self.guideNameLabel.text = [NSString stringWithFormat:@"用户名: %@",[Shoppersmanager manager].Shoppers.employee.realName];
    //是否需要完善客户信息
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (![Shoppersmanager manager].Shoppers.employee.isComplete) {
            [self perfectGuideInformation];
        }
    });
72 73
}

74 75 76 77 78 79 80 81
#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:)]];
}

82 83 84 85
#pragma mark - 查询积分明细
- (void)queryIntegralDetails
{
    WS(weakSelf);
86
    [XBLoadingView showHUDViewWithDefault];;
87
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(INTEGRALQUERY),[Shoppersmanager manager].Shoppers.employee.fid];
曹云霄's avatar
曹云霄 committed
88
    [HTTP networkWithDictionaryRequestWithURL:url withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
89
        
90
        [XBLoadingView hideHUDViewWithDefault];
曹云霄's avatar
曹云霄 committed
91
        if (RESULT(returnValue)) {
曹云霄's avatar
曹云霄 committed
92
            RsScoreDetails *integralDatas = [[RsScoreDetails alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
93
            [weakSelf setUpIntegral:integralDatas];
94 95

        }else {
96
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
97 98
        }
        
99
    }withFailureBlock:^(NSError *error) {
100
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
101 102 103
    }];
}

104 105 106
#pragma mark - 积分信息
- (void)setUpIntegral:(RsScoreDetails *)entity
{
107 108 109 110
    if (entity.currentScore == 0) {
        entity.quarterlyRanking = 0;
        entity.annualRanking = 0;
    }
111
    self.currentScoreLabel.text = [NSString stringWithFormat:@"%.0lf",entity.currentScore];
112 113
    self.yearRankingLabel.text = [NSString stringWithFormat:@"%ld",(long)entity.annualRanking];
    [self.guideHeadImageView sd_setImageWithURL:[NSURL URLWithString:[Shoppersmanager manager].Shoppers.employee.picture] placeholderImage:ReplaceImage];
曹云霄's avatar
曹云霄 committed
114
    [self.guideHeadImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(guideHeaderViewClick:)]];
115
    self.quarterRankingLabel.text = [NSString stringWithFormat:@"%ld",(long)entity.quarterlyRanking];
116
}
117

曹云霄's avatar
曹云霄 committed
118 119 120 121 122 123
#pragma mark -导购头像点击事件
- (void)guideHeaderViewClick:(UITapGestureRecognizer *)tap
{
    [self perfectGuideInformation];
}

124 125 126
#pragma mark - 综合讨论
- (void)comprehensiveDiscussionViewClickAction:(UITapGestureRecognizer *)sender
{
127
    ForumTypeViewController *forum = [[[self class] getLearningCenterStoryboardClass]instantiateViewControllerWithIdentifier:@"ForumTypeViewController"];
128
    [self.navigationController pushViewController:forum animated:YES];
129 130 131 132 133 134 135
}

#pragma mark - 在线学习
- (void)onlineLearningViewClickAction:(UITapGestureRecognizer *)sender
{
    OnlineLearningViewController *onlineLearning = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"OnlineLearningViewController"];
    [self.navigationController pushViewController:onlineLearning animated:YES];
曹云霄's avatar
曹云霄 committed
136 137
}

138 139 140
#pragma mark - 闯关
- (void)breakthroughViewClickAction:(UITapGestureRecognizer *)sender
{
141 142
    EmigratedMainViewController *emigrated = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"EmigratedMainViewController"];
    [self.navigationController pushViewController:emigrated animated:YES];
曹云霄's avatar
曹云霄 committed
143 144 145 146
}


@end