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

#import "OnlineLearningViewController.h"
10
#import "OnlineLearningTableViewCell.h"
11
#import "VideoListViewController.h"
12
#import "OnlineLearningDetailViewController.h"
13

曹云霄's avatar
曹云霄 committed
14 15
@interface OnlineLearningViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

16 17 18 19 20 21

/**
 学习类别
 */
@property (nonatomic,strong) NSMutableArray *studyTypeArray;

曹云霄's avatar
曹云霄 committed
22 23 24 25 26 27 28 29
@end

@implementation OnlineLearningViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpCollectionView];
30
    [self getLearningModuleData];
曹云霄's avatar
曹云霄 committed
31 32 33 34 35
}

#pragma mark - UICollectionView
- (void)setUpCollectionView
{
曹云霄's avatar
曹云霄 committed
36
    self.onlineLearningFlowLayout.itemSize = CGSizeMake((ScreenWidth-60)/3.0, ((ScreenWidth-60)/3.0)*0.9);
37
    self.onlineLearningFlowLayout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);
曹云霄's avatar
曹云霄 committed
38 39
    self.onlineLearningFlowLayout.minimumLineSpacing = 10;
    self.onlineLearningFlowLayout.minimumInteritemSpacing = 10;
曹云霄's avatar
曹云霄 committed
40 41
}

42 43 44
#pragma mark - 学习模块数据
- (void)getLearningModuleData
{
45
  WS(weakSelf);
46
  [XBLoadingView showHUDViewWithDefault];;
曹云霄's avatar
曹云霄 committed
47
  [HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(STUDYTYPES) withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
48
      
49
      [XBLoadingView hideHUDViewWithDefault];
曹云霄's avatar
曹云霄 committed
50
      if (RESULT(returnValue)) {
曹云霄's avatar
曹云霄 committed
51
          StudyTypeResponse *response = [[StudyTypeResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
52
          [weakSelf.studyTypeArray addObjectsFromArray:response.types];
53
      }else {
54
          [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
55 56 57
      }
      [weakSelf.onlineLearningCollectionView reloadData];
      
58
  }withFailureBlock:^(NSError *error) {
59
      [XBLoadingView hideHUDViewWithDefault];
60
      [XBLoadingView showHUDViewWithText:error.localizedDescription];
61
  }];
62
}
曹云霄's avatar
曹云霄 committed
63

64 65 66
#pragma mark - <UICollectionViewDelegate,UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
67
    return self.studyTypeArray.count;
68
}
曹云霄's avatar
曹云霄 committed
69

70 71 72
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    OnlineLearningTableViewCell *learningCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"OnlineLearningTableViewCell" forIndexPath:indexPath];
73
    learningCell.studeType = self.studyTypeArray[indexPath.row];
74 75
    return learningCell;
}
曹云霄's avatar
曹云霄 committed
76

77 78
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    TOStudyTaskEntity *studyType = self.studyTypeArray[indexPath.row];;

    VideoListViewController *listView = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoListViewController"];
    listView.studyType = studyType;
    [self.navigationController pushViewController:listView animated:YES];
    
//    WS(weakSelf);
//    StudyTaskCondition *studyListModel = [[StudyTaskCondition alloc]init];
//    studyListModel.employeeIdEquals = [Shoppersmanager manager].shoppers.employee.fid;
//    studyListModel.typeEquals = studyType.fid;
//    DataPage *page = [[DataPage alloc] init];
//    page.page = ONE;
//    page.rows = 9999;
//    studyListModel.page = page;
//    [XBLoadingView showHUDViewWithDefault];
//    [HTTP networkRequestWithURL:SERVERREQUESTURL(STUDYLIST) withRequestType:ZERO withParameter:studyListModel withReturnValueBlock:^(id returnValue) {
//        
//        [XBLoadingView hideHUDViewWithDefault];
//        if (RESULT(returnValue)) {
//            StudyTaskResponse *responeseEty = [[StudyTaskResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
//            if (responeseEty.studyEntity.count == 0) {
//                [XBLoadingView showHUDViewWithText:@"学习内容为空!"];
//                return;
//            }
//            
//            VideoListViewController *listView = [[[weakSelf class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoListViewController"];
//            [listView view];
//            
//            listView.datasArray = [NSMutableArray arrayWithArray:responeseEty.studyEntity];
//            listView.studyTypeEntity = responeseEty;
//            [weakSelf.navigationController pushViewController:listView animated:YES];
//        }else {
//            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
//        }
//        
//    }withFailureBlock:^(NSError *error) {
//        [XBLoadingView showHUDViewWithText:error.localizedDescription];
//    }];
117
}
曹云霄's avatar
曹云霄 committed
118 119


120 121 122 123 124 125 126
#pragma mark - lazy
- (NSMutableArray *)studyTypeArray
{
    if (!_studyTypeArray) {
        _studyTypeArray = [NSMutableArray array];
    }
    return _studyTypeArray;
曹云霄's avatar
曹云霄 committed
127 128 129
}

@end