LearningCenterMainViewController.m 5.72 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 "BreakThroughViewController.h"
曹云霄's avatar
曹云霄 committed
13
#import "PerfectInformationViewController.h"
14
#import "DiscussMainViewController.h"
15
#import "ForumTypeViewController.h"
曹云霄's avatar
曹云霄 committed
16

17
@interface LearningCenterMainViewController ()
18

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

@end

@implementation LearningCenterMainViewController

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

29 30 31 32 33 34 35 36
#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;
    }
37
    [self queryIntegralDetails];
38 39 40 41 42 43 44 45 46 47 48 49 50
}

#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;
    }
}

51

曹云霄's avatar
曹云霄 committed
52 53
- (void)viewDidLoad {
    [super viewDidLoad];
54
    
55
    [self setUpGuideRealName];
56
    [self addGestureRecognizer];
57 58
    [self addNotification];
    [self improveCustomerInformation];
59 60
}

61
#pragma mark -UI
62
- (void)setUpGuideRealName
63
{
64
    self.guideNameLabel.text = [NSString stringWithFormat:@"用户名: %@",[Shoppersmanager manager].shoppers.employee.realName];
65 66 67 68 69
}

#pragma mark -是否需要完善客户信息
- (void)improveCustomerInformation
{
曹云霄's avatar
曹云霄 committed
70 71
    //是否需要完善客户信息
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
72
        if (![Shoppersmanager manager].shoppers.employee.isComplete) {
曹云霄's avatar
曹云霄 committed
73 74 75
            [self perfectGuideInformation];
        }
    });
76 77
}

78 79 80 81 82 83 84 85 86 87 88 89
#pragma mark -监听导购名字修改
- (void)addNotification
{
    [Notification addObserver:self selector:@selector(refreshGuideName:) name:CHANGEGUIDENAME object:nil];
}

#pragma mark -修改导购名字
- (void)refreshGuideName:(NSNotification *)object
{
    [self setUpGuideRealName];
}

90 91 92 93 94 95 96 97
#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:)]];
}

98 99 100 101
#pragma mark - 查询积分明细
- (void)queryIntegralDetails
{
    WS(weakSelf);
102
    [XBLoadingView showHUDViewWithDefault];;
103
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(INTEGRALQUERY),[Shoppersmanager manager].shoppers.employee.fid];
曹云霄's avatar
曹云霄 committed
104
    [HTTP networkWithDictionaryRequestWithURL:url withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
105
        
106
        [XBLoadingView hideHUDViewWithDefault];
曹云霄's avatar
曹云霄 committed
107
        if (RESULT(returnValue)) {
曹云霄's avatar
曹云霄 committed
108
            RsScoreDetails *integralDatas = [[RsScoreDetails alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
109
            [weakSelf setUpIntegral:integralDatas];
110 111

        }else {
112
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
113 114
        }
        
115
    }withFailureBlock:^(NSError *error) {
116
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
117 118 119
    }];
}

120 121 122
#pragma mark - 积分信息
- (void)setUpIntegral:(RsScoreDetails *)entity
{
123 124 125 126
    if (entity.currentScore == 0) {
        entity.quarterlyRanking = 0;
        entity.annualRanking = 0;
    }
127
    self.currentScoreLabel.text = [NSString stringWithFormat:@"%.0lf",entity.currentScore];
128
    self.yearRankingLabel.text = [NSString stringWithFormat:@"%ld",(long)entity.annualRanking];
129
    [self.guideHeadImageView sd_setImageWithURL:[NSURL URLWithString:[Shoppersmanager manager].shoppers.employee.picture] placeholderImage:GuideReplaceImage];
曹云霄's avatar
曹云霄 committed
130
    [self.guideHeadImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(guideHeaderViewClick:)]];
131
    self.quarterRankingLabel.text = [NSString stringWithFormat:@"%ld",(long)entity.quarterlyRanking];
132
}
133

曹云霄's avatar
曹云霄 committed
134 135 136 137 138 139
#pragma mark -导购头像点击事件
- (void)guideHeaderViewClick:(UITapGestureRecognizer *)tap
{
    [self perfectGuideInformation];
}

140 141 142
#pragma mark - 综合讨论
- (void)comprehensiveDiscussionViewClickAction:(UITapGestureRecognizer *)sender
{
143
    DiscussMainViewController *forum = [[[self class] getLearningCenterStoryboardClass]instantiateViewControllerWithIdentifier:@"DiscussMainViewController"];
144
    [self.navigationController pushViewController:forum animated:YES];
145 146 147 148 149 150 151
}

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

154 155 156
#pragma mark - 闯关
- (void)breakthroughViewClickAction:(UITapGestureRecognizer *)sender
{
157
    BreakThroughViewController *emigrated = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"BreakThroughViewController"];
158
    [self.navigationController pushViewController:emigrated animated:YES];
曹云霄's avatar
曹云霄 committed
159 160 161 162
}


@end