|
@@ -577,10 +577,7 @@ export default {
|
|
|
// 判断已选中的视频的父级
|
|
|
let { moduleId, chapterId, sectionId, sectionType } = this.query;
|
|
|
if (moduleId * 1) {
|
|
|
- list = await this.openModule(
|
|
|
- list.find((e) => e.menuId == moduleId),
|
|
|
- true
|
|
|
- );
|
|
|
+ list = await this.openModule(list.find((e) => e.menuId == moduleId));
|
|
|
}
|
|
|
if (chapterId * 1) {
|
|
|
list = await this.openChapter(
|
|
@@ -596,7 +593,6 @@ export default {
|
|
|
if (sectionType == 1) {
|
|
|
this.$emit("getResource", sectionItem);
|
|
|
}
|
|
|
- this.refreshList();
|
|
|
},
|
|
|
activeFunc(courseId, index) {
|
|
|
let { courseId: nowCourseId, courseList } = this.treeList[index];
|
|
@@ -621,10 +617,12 @@ export default {
|
|
|
this.treeList.splice(index, 1, JSON.parse(JSON.stringify(course)));
|
|
|
this.getMenuList(this.treeList[index]);
|
|
|
},
|
|
|
- getMenuList(course) {
|
|
|
+ getMenuList(course, isFresh = false) {
|
|
|
let { showList, courseId, list } = course;
|
|
|
- course.showList = !showList;
|
|
|
- if (list.length) return;
|
|
|
+ if (!isFresh) {
|
|
|
+ course.showList = !showList;
|
|
|
+ if (list.length) return;
|
|
|
+ }
|
|
|
this.$request
|
|
|
.reSectionExamList({
|
|
|
chapterId: 0,
|
|
@@ -644,17 +642,18 @@ export default {
|
|
|
item.menuType = item.type;
|
|
|
item.showList = false;
|
|
|
item.list = [];
|
|
|
- item.parent = this.menuList;
|
|
|
+ item.parent = course;
|
|
|
}
|
|
|
course.list = res.rows;
|
|
|
return Promise.resolve(res.rows);
|
|
|
});
|
|
|
},
|
|
|
- openModule(module, status = false, isAuto = false) {
|
|
|
- console.log(module);
|
|
|
+ openModule(module, isFresh = false) {
|
|
|
let { list, isRebuild, id, courseId, showList } = module;
|
|
|
- module.showList = !showList;
|
|
|
- if (list.length) return;
|
|
|
+ if (!isFresh) {
|
|
|
+ module.showList = !showList;
|
|
|
+ if (list.length) return;
|
|
|
+ }
|
|
|
return this.$request
|
|
|
.reChapterList({
|
|
|
moduleId: id,
|
|
@@ -686,10 +685,11 @@ export default {
|
|
|
courseId,
|
|
|
showList,
|
|
|
} = chapter;
|
|
|
- chapter.showList = !showList;
|
|
|
- if (list.length && !isFresh) {
|
|
|
- return;
|
|
|
+ if (!isFresh) {
|
|
|
+ chapter.showList = !showList;
|
|
|
+ if (list.length) return;
|
|
|
}
|
|
|
+
|
|
|
this.$request
|
|
|
.reSectionExamList({
|
|
|
chapterId: chapterId || menuId,
|
|
@@ -703,7 +703,7 @@ export default {
|
|
|
.reSectionList({
|
|
|
chapterId: id,
|
|
|
gradeId: this.gradeId,
|
|
|
- courseId: courseId,
|
|
|
+ courseId,
|
|
|
rebuild: isRebuild ? 1 : undefined,
|
|
|
moduleId: moduleId || 0,
|
|
|
})
|
|
@@ -713,19 +713,85 @@ export default {
|
|
|
.every((item) => item.learning == 1);
|
|
|
res.data.forEach((section) => {
|
|
|
section.parent = chapter;
|
|
|
+ section.courseId = courseId;
|
|
|
});
|
|
|
chapter.list = res.data;
|
|
|
- if (this.needOpen) {
|
|
|
- this.needOpen = false;
|
|
|
- }
|
|
|
return Promise.resolve(chapter.list);
|
|
|
});
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 判断是否是当前播放的节
|
|
|
+ */
|
|
|
isActive(section) {
|
|
|
- return section == this.sectionItem;
|
|
|
+ let moduleId = section.moduleId || 0;
|
|
|
+ let chapterId = section.chapterId || 0;
|
|
|
+ let sectionId = section.sectionId || section.menuId;
|
|
|
+ let moduleId1 = this.sectionItem.moduleId || 0;
|
|
|
+ let chapterId1 = this.sectionItem.chapterId || 0;
|
|
|
+ let sectionId1 = this.sectionItem.sectionId || this.sectionItem.menuId;
|
|
|
+ return (
|
|
|
+ moduleId == moduleId1 &&
|
|
|
+ chapterId == chapterId1 &&
|
|
|
+ sectionId == sectionId1
|
|
|
+ );
|
|
|
+ },
|
|
|
+ backList(courseId, projectId) {
|
|
|
+ return projectId
|
|
|
+ ? this.treeList
|
|
|
+ : this.treeList.find((e) => e.courseId == courseId).list;
|
|
|
+ },
|
|
|
+ // 自动播放下一个视频
|
|
|
+ async playNextVideo(sectionItem = this.sectionItem) {
|
|
|
+ let { menuId, parent, courseId, projectId } = sectionItem;
|
|
|
+ let list = (
|
|
|
+ menuId
|
|
|
+ ? this.treeList.find((e) => e.courseId == courseId).list
|
|
|
+ : projectId
|
|
|
+ ? this.treeList
|
|
|
+ : parent.list
|
|
|
+ ).filter((e) => !e.doType);
|
|
|
+ let index = list.findIndex((e) => e.id == sectionItem.id);
|
|
|
+ let nextItem = {};
|
|
|
+ if (list.length - 1 > index) {
|
|
|
+ nextItem = list[index + 1];
|
|
|
+ // 切换课程
|
|
|
+ if (projectId) {
|
|
|
+ list = nextItem.list.length
|
|
|
+ ? nextItem.list
|
|
|
+ : await this.getMenuList(nextItem);
|
|
|
+ nextItem = list[0];
|
|
|
+ }
|
|
|
+ // 模块
|
|
|
+ if (nextItem.menuType == 1) {
|
|
|
+ list = nextItem.list.length
|
|
|
+ ? nextItem.list
|
|
|
+ : await this.openModule(nextItem);
|
|
|
+ nextItem = list[0];
|
|
|
+ }
|
|
|
+ // 章
|
|
|
+ if (nextItem.menuType < 3) {
|
|
|
+ list = nextItem.list.length
|
|
|
+ ? nextItem.list
|
|
|
+ : await this.openChapter(nextItem);
|
|
|
+ nextItem = list.find((e) => e.type == 1);
|
|
|
+ }
|
|
|
+ this.toPlay(nextItem);
|
|
|
+ } else {
|
|
|
+ this.playNextVideo(parent);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async backNextItem(nextItem, type) {
|
|
|
+ console.log(nextItem, type);
|
|
|
+ if (type == undefined) return nextItem;
|
|
|
+ let key = ["getMenuList", "openModule", "openChapter"][type];
|
|
|
+ let list = nextItem.list.length
|
|
|
+ ? nextItem.list
|
|
|
+ : await this[key](nextItem);
|
|
|
+ nextItem = type == 2 ? list.find((e) => e.type == 1) : list[0];
|
|
|
+ return this.backNextItem(nextItem, nextItem.menuType);
|
|
|
},
|
|
|
async getResource(section, type, courseIndex) {
|
|
|
- if (section.type != 2 && section == this.sectionItem) {
|
|
|
+ if (section.type != 2 && this.isActive(section)) {
|
|
|
return;
|
|
|
}
|
|
|
if (!(await this.orderTopTobottom(section, type, courseIndex))) {
|
|
@@ -739,20 +805,47 @@ export default {
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
- if (
|
|
|
- section.sectionType === 2 &&
|
|
|
- section.liveStartTime &&
|
|
|
- section.liveEndTime
|
|
|
- ) {
|
|
|
- if (section.liveStartTime > this.nowTime) {
|
|
|
- this.$message.warning("直播待开播");
|
|
|
- return;
|
|
|
+ //视频 回放
|
|
|
+ if (section.sectionType == 1 || section.sectionType == 3) {
|
|
|
+ if (!section.recordingUrl) {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: `暂无播放地址数据`,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
}
|
|
|
- if (section.liveEndTime < this.nowTime) {
|
|
|
- this.$message.warning("直播已结束");
|
|
|
- return;
|
|
|
+ }
|
|
|
+ // 直播
|
|
|
+ if (section.sectionType == 2) {
|
|
|
+ if (!section.liveUrl) {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: `暂无直播地址数据`,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let data = await this.studyRecordGetChannelBasicInfo(section.liveUrl);
|
|
|
+ if (data.watchStatus == "end" || data.watchStatus == "playback") {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: `直播已结束`,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.watchStatus == "waiting") {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: `直播未开始`,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
+ // 学习次数
|
|
|
+ if (!(await this.exceedLearnNum(section))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
section.type == 2
|
|
|
? this.toCourseExam(section, type, courseIndex)
|
|
|
: this.toPlay(section);
|
|
@@ -760,9 +853,6 @@ export default {
|
|
|
async toCourseExam(section, type, courseIndex) {
|
|
|
//试卷
|
|
|
// 学习次数
|
|
|
- if (!(await this.exceedLearnNum(section))) {
|
|
|
- return false;
|
|
|
- }
|
|
|
let num =
|
|
|
this.goodsLearningOrder != 2 || section.rebuild
|
|
|
? await this.bankRecordDoNum(section.typeId)
|
|
@@ -829,7 +919,9 @@ export default {
|
|
|
},
|
|
|
async exceedLearnNum(section) {
|
|
|
let learnNum = await this.goodsTodayStudySectionNum();
|
|
|
- let hasLearn = await this.gradeCheckGoodsStudy(section.typeId);
|
|
|
+ let hasLearn = await this.gradeCheckGoodsStudy(
|
|
|
+ section.type == 2 ? section.typeId : section
|
|
|
+ );
|
|
|
if (this.sectionMaxNum > 0) {
|
|
|
if (learnNum >= this.sectionMaxNum && !hasLearn) {
|
|
|
this.$message({
|
|
@@ -841,7 +933,7 @@ export default {
|
|
|
}
|
|
|
return true;
|
|
|
},
|
|
|
- goodsTodayStudySectionNum(option) {
|
|
|
+ goodsTodayStudySectionNum() {
|
|
|
return new Promise((resolve) => {
|
|
|
this.$request
|
|
|
.goodsTodayStudySectionNum({
|
|
@@ -885,18 +977,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
toPlay(section) {
|
|
|
- // if (
|
|
|
- // this.sectionItem.sectionType === 1 &&
|
|
|
- // this.playSectionId &&
|
|
|
- // (this.playSectionId == section.sectionId ||
|
|
|
- // this.playSectionId == section.menuId) &&
|
|
|
- // this.moduleId == (section.moduleId || 0) &&
|
|
|
- // this.chapterId == (section.chapterId || 0)
|
|
|
- // ) {
|
|
|
- // //切换为同一频道不作为
|
|
|
- // this.clickLock = false;
|
|
|
- // return;
|
|
|
- // }
|
|
|
this.$emit("getResource", section);
|
|
|
},
|
|
|
//获取商品双师资模板
|
|
@@ -987,16 +1067,24 @@ export default {
|
|
|
},
|
|
|
// 刷新数据
|
|
|
refreshList() {
|
|
|
- setTimeout(() => {
|
|
|
- console.log(this.treeList[0].list, 999);
|
|
|
- let { parent, courseId, menuId } = this.sectionItem;
|
|
|
- if (menuId) {
|
|
|
- let index = this.treeList.findIndex((e) => e.courseId == courseId);
|
|
|
- this.getMenuList(this.treeList[index]);
|
|
|
- } else {
|
|
|
- this.openChapter(parent);
|
|
|
- }
|
|
|
- }, 999);
|
|
|
+ let { parent, menuId } = this.sectionItem;
|
|
|
+ if (menuId) {
|
|
|
+ this.getMenuList(playCourse, true);
|
|
|
+ } else {
|
|
|
+ this.openChapter(parent, true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ studyRecordGetChannelBasicInfo(channelId) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.$request
|
|
|
+ .studyRecordGetChannelBasicInfo({
|
|
|
+ channelId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data);
|
|
|
+ })
|
|
|
+ .catch((err) => {});
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
@@ -1009,6 +1097,12 @@ export default {
|
|
|
goodsId() {
|
|
|
return this.$route.params.goodsId;
|
|
|
},
|
|
|
+ playCourseId() {
|
|
|
+ return this.sectionItem.courseId;
|
|
|
+ },
|
|
|
+ playCourse() {
|
|
|
+ return this.treeList.find((e) => e.courseId == this.playCourseId);
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
courseList: {
|