1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
//
// OnlineLearningDetailViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/11/25.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "OnlineLearningDetailViewController.h"
#import "VideoHelperViewController.h"
#import "VideoListViewController.h"
#import "VideoDetailViewController.h"
#import "CustomWKWebViewController.h"
#import "LearningCompleteViewController.h"
#import "AssessmentViewController.h"
@interface OnlineLearningDetailViewController ()<SelectStudyItemDelegate,VideoPlayerDelegate,BeginAssessmentDelegate>
/**
学习数据
*/
@property (nonatomic,strong) StudyTaskResponse *studyResult;
@property (nonatomic,strong) WYPopoverController *settingsPopoverController;
@end
@implementation OnlineLearningDetailViewController
#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;
}
}
#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;
}
}
- (void)viewDidLoad {
[super viewDidLoad];
[self addChildViewController];
[self getStudyItemDetailAction];
}
#pragma mark -
- (void)addChildViewController
{
//播放窗口
VideoHelperViewController *videoWindow = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoHelperViewController"];
videoWindow.view.frame = CGRectMake(0, NavigationHeight, ScreenWidth*2/3, ScreenHeight/2);
videoWindow.delegate = self;
[self addChildViewController:videoWindow];
[self.view addSubview:videoWindow.view];
//播放列表
VideoListViewController *playList = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoListViewController"];
playList.view.frame = CGRectMake(ScreenWidth*2/3 + 5, NavigationHeight, ScreenWidth/3-5, ScreenHeight-64);
playList.studyItemTitleLabel.text = self.studyTypeEntity.name;
playList.delegate = self;
[self addChildViewController:playList];
[self.view addSubview:playList.view];
//播放简介
VideoDetailViewController *playDetail = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoDetailViewController"];
playDetail.view.frame = CGRectMake(0, ScreenHeight/2+NavigationHeight, ScreenWidth*2/3, ScreenHeight/2-NavigationHeight);
[self addChildViewController:playDetail];
[self.view addSubview:playDetail.view];
__block VideoHelperViewController *weakVideWindow = videoWindow;
//全屏
WS(weakSelf);
[videoWindow setZoomButtonClickBlock:^(BOOL boolValue) {
if (boolValue) {
[weakSelf.view.window addSubview:weakVideWindow.view];
[UIView animateWithDuration:0.2 animations:^{
weakVideWindow.view.frame = [UIScreen mainScreen].bounds;
weakVideWindow.playerLayer.frame = [UIScreen mainScreen].bounds;
}];
}else{
[weakSelf.view insertSubview:weakVideWindow.view atIndex:0];
[UIView animateWithDuration:0.2 animations:^{
weakVideWindow.view.frame = CGRectMake(0, NavigationHeight, ScreenWidth*2/3, ScreenHeight/2);
weakVideWindow.playerLayer.frame = CGRectMake(0, 0, ScreenWidth*2/3, ScreenHeight/2);
}completion:nil];
}
}];
}
#pragma mark - 获取学习项详情
- (void)getStudyItemDetailAction
{
WS(weakSelf);
StudyTaskCondition *studyListModel = [[StudyTaskCondition alloc]init];
studyListModel.employeeIdEquals = [Shoppersmanager manager].Shoppers.employee.fid;
studyListModel.typeEquals = self.studyTypeEntity.fid;
DataPage *page = [[DataPage alloc] init];
page.page = ONE;
page.rows = 9999;
studyListModel.page = page;
[XBLoadingView showHUDViewWithDefault];
[[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(STUDYLIST) WithRequestType:ZERO WithParameter:studyListModel WithReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault];
if ([returnValue[@"code"] isEqualToNumber:@0]) {
weakSelf.studyResult = [[StudyTaskResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
[weakSelf transferData:weakSelf.studyResult];
}else {
[XBLoadingView showHUDViewWithText:returnValue[@"message"]];
}
}WithFailureBlock:^(NSError *error) {
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - 选中学习项
- (void)seleStudyItemCellIndex:(NSIndexPath *)indexPath
{
VideoDetailViewController *studyDetailVc = [self.childViewControllers lastObject];
studyDetailVc.indexPath = indexPath;
VideoHelperViewController *videoVc = [self.childViewControllers firstObject];
RsStudyTask *studyEntity = self.studyResult.studyEntity[indexPath.section];
CustomStudyEntity *studyList = studyEntity.studyTasks[indexPath.row];
if ([studyList.attachment.fileUrl rangeOfString:@".mp4"].location != NSNotFound) {
videoVc.learningItem = studyList;
videoVc.videoTitleLabel.text = studyList.title;
}else if ([studyList.attachment.fileUrl rangeOfString:@".ppt"].location != NSNotFound) {
[videoVc resetPlayer];
CustomWKWebViewController *pdfvc = [[CustomWKWebViewController alloc]init];
pdfvc.urlString = studyList.attachment.fileUrl;
[self presentViewController:pdfvc animated:YES completion:nil];
}
}
#pragma mark - 视频播放完成
- (void)videoPlayFinish:(CustomStudyEntity *)studyEntity
{
LearningCompleteViewController *assessmentVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"LearningCompleteViewController"];
assessmentVc.delegate = self;
assessmentVc.studyEntity = studyEntity;
assessmentVc.preferredContentSize = CGSizeMake(520, 450);
self.settingsPopoverController = [[WYPopoverController alloc] initWithContentViewController:assessmentVc];
self.settingsPopoverController.wantsDefaultContentAppearance = NO;
self.settingsPopoverController.theme.fillBottomColor = [UIColor clearColor];
self.settingsPopoverController.theme.fillTopColor = [UIColor clearColor];
self.settingsPopoverController.theme.glossShadowColor = [UIColor clearColor];
[self.settingsPopoverController presentPopoverAsDialogAnimated:YES
options:WYPopoverAnimationOptionFadeWithScale];
}
#pragma mark - 开始考核
- (void)beginAssessment:(CustomStudyEntity *)studyEntity
{
WS(weakSelf);
[self.settingsPopoverController dismissPopoverAnimated:YES completion:^{
AssessmentViewController *assessmentVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"AssessmentViewController"];
assessmentVc.taskId = studyEntity.fid;
[weakSelf.navigationController pushViewController:assessmentVc animated:YES];
}];
}
#pragma mark - 赋值
- (void)transferData:(StudyTaskResponse *)result
{
VideoListViewController *studyListVC = self.childViewControllers[1];
studyListVC.datasArray = result.studyEntity;
VideoDetailViewController *studyDetailsVC = self.childViewControllers[2];
studyDetailsVC.datasArray = result.studyEntity;
studyDetailsVC.indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
}
@end