12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313 |
- <template>
- <div id="courseTree">
- <el-empty description="暂无课程" v-if="courseList.length === 0"></el-empty>
- <ul v-else class="courseTree">
- <li v-for="(item1, index1) in courseDataList" :key="index1">
- <div
- class="menu_box"
- @click="openMenu(item1)"
- :class="isActive(item1) ? 'active' : ''"
- >
- <div class="left level1">
- <el-tag
- size="mini"
- effect="dark"
- :type="getTypeStyle(item1)"
- v-if="item1.type == 3 || item1.type == -1"
- >{{ changeName(item1) }}</el-tag
- >
- <span v-else>
- {{ changeName(item1) }}
- </span>
- </div>
- <div class="center">
- {{ item1.name }}
- <el-tag v-if="item1.type == 2 && item1.commonSign == 1" size="mini"
- >公共章</el-tag
- >
- <p v-if="liveShowTimeData(item1)" class="live_style">
- <span>{{
- $tools.timestampToTime(item1.liveStartTime, (isDay = false))
- }}</span>
- -
- <span>{{
- $tools.timestampToTime(item1.liveEndTime, (isDay = false))
- }}</span>
- </p>
- </div>
- <div class="right">
- <template v-if="item1.type == 3">
- <img
- v-if="isActive(item1)"
- src="@/assets/learing.gif"
- alt=""
- class="activeImg_style"
- />
- <div class="during" v-if="item1.sectionType !== 2">
- {{ $tools.secondToDate(item1.durationTime) }}
- </div>
- <template v-if="BackSTATUS(item1)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackSTATUS(item1)['style']"
- >{{ BackSTATUS(item1)["name"] }}</el-tag
- >
- </template>
- <el-tag
- size="mini"
- effect="dark"
- v-if="item1.examList.length > 0"
- @click.stop="doExam(item1.examList[0], 2)"
- >习题</el-tag
- >
- </template>
- <template v-else-if="item1.type == -1">
- <template v-if="BackExamStatus(item1)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackExamStatus(item1)['style']"
- >{{ BackExamStatus(item1)["name"] }}</el-tag
- >
- </template>
- </template>
- <el-tag
- v-else
- v-show="allSectionList.length > 0"
- size="mini"
- effect="light"
- :type="getStudyStatus(item1)['style']"
- >{{ getStudyStatus(item1)["name"] }}</el-tag
- >
- </div>
- </div>
- <ul
- v-if="item1.children && item1.children.length > 0 && item1.showStatus"
- >
- <li v-for="(item2, index2) in item1.children" :key="index2">
- <div
- class="menu_box"
- @click="openMenu(item2)"
- :class="isActive(item2) ? 'active' : ''"
- >
- <div class="left level2">
- <el-tag
- size="mini"
- effect="dark"
- :type="getTypeStyle(item2)"
- v-if="item2.type == 3 || item2.type == -1"
- >{{ changeName(item2) }}</el-tag
- >
- <span v-else>
- {{ changeName(item2) }}
- </span>
- </div>
- <div class="center">
- {{ item2.name }}
- <el-tag
- v-if="item2.type == 2 && item2.commonSign == 1"
- size="mini"
- >公共章</el-tag
- >
- <p v-if="liveShowTimeData(item2)" class="live_style">
- <span>{{
- $tools.timestampToTime(item2.liveStartTime, (isDay = false))
- }}</span>
- -
- <span>{{
- $tools.timestampToTime(item2.liveEndTime, (isDay = false))
- }}</span>
- </p>
- </div>
- <div class="right">
- <template v-if="item2.type == 3">
- <img
- v-if="isActive(item2)"
- src="@/assets/learing.gif"
- alt=""
- class="activeImg_style"
- />
- <div class="during" v-if="item2.sectionType !== 2">
- {{ $tools.secondToDate(item2.durationTime) }}
- </div>
- <template v-if="BackSTATUS(item2)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackSTATUS(item2)['style']"
- >{{ BackSTATUS(item2)["name"] }}</el-tag
- >
- </template>
- <el-tag
- size="mini"
- effect="dark"
- v-if="item2.examList.length > 0"
- @click.stop="doExam(item2.examList[0], 2)"
- >习题</el-tag
- >
- </template>
- <template v-else-if="item2.type == -1">
- <template v-if="BackExamStatus(item2)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackExamStatus(item2)['style']"
- >{{ BackExamStatus(item2)["name"] }}</el-tag
- >
- </template>
- </template>
- <el-tag
- v-else
- v-show="allSectionList.length > 0"
- size="mini"
- effect="light"
- :type="getStudyStatus(item2)['style']"
- >{{ getStudyStatus(item2)["name"] }}</el-tag
- >
- </div>
- </div>
- <ul
- v-if="
- item2.children && item2.children.length > 0 && item2.showStatus
- "
- >
- <li v-for="(item3, index3) in item2.children" :key="index3">
- <div
- class="menu_box"
- @click="openMenu(item3)"
- :class="isActive(item3) ? 'active' : ''"
- >
- <div class="left level3">
- <el-tag
- size="mini"
- effect="dark"
- :type="getTypeStyle(item3)"
- v-if="item3.type == 3 || item3.type == -1"
- >{{ changeName(item3) }}</el-tag
- >
- <span v-else>
- {{ changeName(item3) }}
- </span>
- </div>
- <div class="center">
- {{ item3.name }}
- <p v-if="liveShowTimeData(item3)" class="live_style">
- <span>{{
- $tools.timestampToTime(
- item3.liveStartTime,
- (isDay = false)
- )
- }}</span>
- -
- <span>{{
- $tools.timestampToTime(
- item3.liveEndTime,
- (isDay = false)
- )
- }}</span>
- </p>
- </div>
- <div class="right">
- <template v-if="item3.type == 3">
- <img
- v-if="isActive(item3)"
- src="@/assets/learing.gif"
- alt=""
- class="activeImg_style"
- />
- <div class="during" v-if="item3.sectionType !== 2">
- {{ $tools.secondToDate(item3.durationTime) }}
- </div>
- <template v-if="BackSTATUS(item3)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackSTATUS(item3)['style']"
- >{{ BackSTATUS(item3)["name"] }}</el-tag
- >
- </template>
- <el-tag
- size="mini"
- effect="dark"
- v-if="item3.examList.length > 0"
- @click.stop="doExam(item3.examList[0], 2)"
- >习题</el-tag
- >
- </template>
- <template v-else-if="item3.type == -1">
- <template v-if="BackExamStatus(item3)['name']">
- <el-tag
- size="mini"
- effect="light"
- :type="BackExamStatus(item3)['style']"
- >{{ BackExamStatus(item3)["name"] }}</el-tag
- >
- </template>
- </template>
- <el-tag
- v-else
- size="mini"
- effect="dark"
- v-show="allSectionList.length > 0"
- >{{ getStudyStatus(item3)["name"] }}</el-tag
- >
- </div>
- </div>
- </li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- inject: ["getGoodsData", "getBusinessData"],
- props: {
- rebuild: {
- type: Number,
- default: () => {
- return 0;
- }
- },
- activeSection: {
- type: Object,
- default: () => {
- return {};
- } //当前节数据
- }
- },
- data() {
- return {
- courseList: [], //商品的课程列表
- courseDataList: [], //课程内容
- allSectionList: [], //商品下所有节和试卷
- repeatShowTips: true, //是否显示跳转提示
- nowTime: 0 //当前时间
- };
- },
- computed: {
- goodsData() {
- return this.getGoodsData();
- },
- businessData() {
- return this.getBusinessData();
- },
- changeName: function() {
- return function(item) {
- var str = "";
- if (item.type == 3) {
- switch (item.sectionType) {
- case 1:
- str = "视频";
- break;
- case 2:
- str = "直播";
- break;
- case 3:
- str = "回放";
- break;
- default:
- break;
- }
- } else if (item.type == -1) {
- if (item.doType == 1) {
- str = "练习";
- } else {
- str = "考试";
- }
- } else {
- if (item.showStatus) {
- str = "▼";
- } else {
- str = "▶";
- }
- }
- return str;
- };
- },
- getTypeStyle: function() {
- return function(item) {
- if (item.type == 3) {
- if (item.sectionType == 2) {
- return "danger";
- }
- if (item.sectionType == 3) {
- return "warning";
- }
- } else {
- return "";
- }
- };
- },
- BackSTATUS: function() {
- return function(item) {
- if (item.sectionType == 1) {
- if (item.rebuild > 0) {
- return {
- name: "待重修",
- style: "danger"
- };
- } else if (item.learning == 1) {
- return {
- name: "已学完",
- style: "success"
- };
- }
- }
- if (item.sectionType == 2) {
- if (item.liveStartTime > this.nowTime) {
- return {
- name: "待开播",
- style: "warning"
- };
- } else if (
- item.liveStartTime <= this.nowTime &&
- item.liveEndTime > this.nowTime
- ) {
- return {
- name: "直播中",
- style: "success"
- };
- } else if (item.liveEndTime < this.nowTime) {
- return {
- name: "已结束",
- style: "danger"
- };
- }
- }
- return {};
- };
- },
- BackExamStatus: function() {
- return function(item) {
- if (item.rebuild > 0) {
- return {
- name: "待重测",
- style: "danger"
- };
- } else if (item.learning == 1) {
- return {
- name: "合格",
- style: "success"
- };
- } else if (item.learning == 0) {
- return {
- name: "不及格(需重考)",
- style: "danger"
- };
- }
- return {};
- };
- },
- isActive: function() {
- return function(item) {
- return (
- item.courseId == this.activeSection.courseId &&
- item.moduleId == this.activeSection.moduleId &&
- item.chapterId == this.activeSection.chapterId &&
- item.sectionId == this.activeSection.sectionId
- );
- };
- },
- getStudyStatus: function() {
- return function(item) {
- if (item.type == 1) {
- var STATUSARRAY = this.allSectionList.filter(i => {
- return i.moduleId == item.moduleId;
- });
- if (
- STATUSARRAY.findIndex(
- i =>
- i.moduleId == this.activeSection.moduleId &&
- i.chapterId == this.activeSection.chapterId &&
- i.sectionId == this.activeSection.sectionId &&
- i.studyStatus != 1
- ) !== -1
- ) {
- return {
- name: "学习中",
- style: "warning"
- };
- }
- }
- if (item.type == 2) {
- var STATUSARRAY = this.allSectionList.filter(i => {
- return i.moduleId == item.moduleId && i.chapterId == item.chapterId;
- });
- if (
- STATUSARRAY.findIndex(
- i =>
- i.moduleId == this.activeSection.moduleId &&
- i.chapterId == this.activeSection.chapterId &&
- i.sectionId == this.activeSection.sectionId &&
- i.studyStatus != 1
- ) !== -1
- ) {
- return {
- name: "学习中",
- style: "warning"
- };
- }
- }
- if (STATUSARRAY.every(i => i.studyStatus == 1)) {
- return {
- name: "已学完",
- style: "success"
- };
- } else {
- return {
- name: "待学习",
- style: ""
- };
- }
- };
- }
- },
- created() {
- this.init();
- this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
- },
- mounted() {
- this.$bus.$on("BackVideoFunc", () => {
- this.BackVideoFunc(); //已学完,重新定位
- });
- },
- methods: {
- // 新增用户视频学习日志
- studyLog(item, studyItem) {
- this.$axios({
- url: "/user/study/log",
- method: "post",
- data: {
- goodsId: this.goodsData.goodsId,
- orderGoodsId: this.goodsData.orderGoodsId,
- courseId: this.courseList[0].courseId,
- fromPlat: 2, //来源平台 1小程序 2PC网站
- goodsType: this.goodsData.goodsType // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
- }
- }).then(res => {
- });
- },
- //是否显示直播时间范围
- liveShowTimeData(item) {
- if (item.type == 3 && item.sectionType == 2) {
- if (
- item.liveStartTime &&
- item.liveEndTime &&
- item.liveStartTime > this.nowTime
- ) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- async init() {
- await this.getGoodsCourseList(); //获取商品课程列表
- await this.getCourseData(this.courseList[0].courseId); //获取课程内容
- await this.getAllSectionList(); //获取所有节列表
- this.studyLog(); // 新增用户视频学习日志
- /**播放逻辑 */
- if (!(this.rebuild > 0)) {
- this.playBackLogic();
- }
- },
- //获取商品课程列表
- getGoodsCourseList() {
- return new Promise((resolve, reject) => {
- this.$request
- .courseCourseList({
- orderGoodsId: this.goodsData.orderGoodsId,
- goodsId: this.goodsData.goodsId,
- gradeId: this.goodsData.gradeId
- })
- .then(res => {
- if (res.rows && res.rows.length > 0) {
- this.courseList = res.rows;
- resolve();
- } else {
- reject();
- }
- })
- .catch(() => {
- reject();
- });
- });
- },
- //获取课程内容
- getCourseData(id) {
- return new Promise(async (resolve, reject) => {
- const examRes = await this.$request.reSectionExamList({
- chapterId: 0,
- courseId: id,
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId
- }); //获取节关联练习试卷
- this.$request
- .reMenuList({
- courseId: id,
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId,
- rebuild: this.rebuild
- })
- .then(res => {
- this.courseDataList = res.rows.map(i => {
- return {
- level: 1,
- type: i.type,
- name: i.menuName,
- courseId: i.courseId,
- commonSign: i.commonSign || null,
- moduleId: i.type == 1 ? i.menuId : 0,
- chapterId: i.type == 2 ? i.menuId : 0,
- sectionId: i.type == 3 ? i.menuId : 0,
- sectionType: i.type == 3 ? i.sectionType : null,
- durationTime: i.type == 3 ? i.durationTime : null,
- recordingUrl: i.type == 3 ? i.recordingUrl : null,
- liveUrl: i.type == 3 ? i.liveUrl : null,
- liveStartTime: i.sectionType == 2 ? i.liveStartTime : null,
- liveEndTime: i.sectionType == 2 ? i.liveEndTime : null,
- showStatus: false, //展开状态
- children: null, //子列表
- learning: i.type == 3 ? i.learning : null,
- examList:
- i.type == 3
- ? examRes.data.filter(item => item.sectionId == i.menuId)
- : [] //关联试卷
- };
- });
- resolve();
- });
- });
- },
- //展开模块
- openModule(item, status = false, renewal = false) {
- if (item.children && item.children.length > 0) {
- item.showStatus = status ? true : !item.showStatus;
- }
- if (!(item.children && item.children.length > 0) || renewal) {
- return new Promise(resolve => {
- this.$request
- .reChapterList({
- moduleId: item.moduleId,
- gradeId: this.goodsData.gradeId,
- courseId: this.courseList[0].courseId,
- orderGoodsId: this.goodsData.orderGoodsId,
- rebuild: this.rebuild
- })
- .then(res => {
- this.$set(item, "showStatus", true);
- this.$set(
- item,
- "children",
- res.data.map(i => {
- if (i.id) {
- return {
- level: item.level + 1,
- type: 2,
- name: i.name,
- commonSign: i.commonSign || null,
- courseId: i.courseId,
- moduleId: i.moduleId,
- chapterId: i.chapterId,
- sectionId: 0,
- sectionType: null,
- durationTime: null,
- recordingUrl: null,
- showStatus: false, //展开状态
- children: null, //子列表
- examList: [] //关联试卷
- };
- } else {
- return Object.assign(i, {
- type: -1,
- chapterId: 0,
- examType: 3
- }); //examType:1章卷,2节卷,3模块卷
- }
- })
- );
- resolve(item.children);
- });
- });
- }
- },
- //展开章
- /**
- * status = true ? '强制展开'
- * renewal = true ? '重新获取数据'
- */
- openChapter(item, status = false, renewal = false) {
- if (item.children && item.children.length > 0) {
- item.showStatus = item.showStatus = status ? true : !item.showStatus;
- }
- if (!(item.children && item.children.length > 0) || renewal) {
- return new Promise(async resolve => {
- const examRes = await this.$request.reSectionExamList({
- moduleId: item.moduleId,
- chapterId: item.chapterId,
- courseId: item.courseId,
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId
- }); //获取节关联练习试卷
- this.$request
- .reSectionList({
- chapterId: item.chapterId,
- gradeId: this.goodsData.gradeId,
- courseId: item.courseId,
- rebuild: this.rebuild,
- moduleId: item.moduleId,
- orderGoodsId: this.goodsData.orderGoodsId
- })
- .then(res => {
- this.$set(item, "showStatus", true);
- this.$set(
- item,
- "children",
- res.data.map(i => {
- if (i.id) {
- return {
- level: item.level + 1,
- type: 3,
- name: i.name,
- courseId: item.courseId,
- moduleId: i.moduleId,
- chapterId: i.chapterId,
- sectionId: i.sectionId,
- sectionType: i.sectionType,
- durationTime: i.durationTime,
- recordingUrl: i.recordingUrl,
- liveUrl: i.liveUrl,
- liveStartTime:
- i.sectionType == 2 ? i.liveStartTime : null,
- liveEndTime: i.sectionType == 2 ? i.liveEndTime : null,
- learning: i.learning,
- rebuild: i.rebuild,
- showStatus: false, //展开状态
- children: null, //子列表
- examList:
- examRes.data.filter(
- item => item.sectionId == i.sectionId
- ) || [] //关联试卷
- };
- } else {
- return Object.assign(i, { type: -1, examType: 1 }); //examType:1章卷,2节卷,3模块卷
- }
- })
- );
- resolve();
- });
- });
- }
- },
- //获取所有节列表
- getAllSectionList() {
- return new Promise((resolve, reject) => {
- this.$request
- .studyrecordgoodsAllListWithExam({
- gradeId: this.goodsData.gradeId,
- goodsId: this.goodsData.goodsId,
- courseId: this.courseList[0].courseId,
- orderGoodsId: this.goodsData.orderGoodsId,
- rebuild: this.rebuild
- })
- .then(res => {
- let ary = res.data.map(i => {
- if (i.type === 3) {
- return {
- type: 3,
- name: i.sectionName,
- courseId: i.courseId,
- moduleId: i.moduleId,
- chapterId: i.chapterId,
- sectionId: i.sectionId,
- sectionType: i.sectionType,
- recordingUrl: i.recordingUrl,
- studyStatus: i.studyStatus,
- learning: i.studyStatus
- };
- } else {
- return Object.assign(i, {
- type: -1,
- typeId: i.examId,
- chapterId: i.chapterId || 0
- });
- }
- });
- this.allSectionList = ary.filter(i => i.sectionType != 2);
- resolve();
- })
- .catch(err => {
- if (err.code == 601) {
- //资料审核不通过,请前往重新填写
- this.$confirm(err.msg, "提示", {
- confirmButtonText: "确定",
- closeOnClickModal: false,
- closeOnPressEscape: false,
- distinguishCancelAndClose: false,
- showClose: false,
- showCancelButton: false
- })
- .then(_ => {
- //停止执行-退出页面
- this.$router.back(-1);
- })
- .catch(_ => {
- //停止执行-退出页面
- this.$router.back(-1);
- });
- }
- });
- });
- },
- //点击菜单
- async openMenu(item) {
- if (item.type == 1) {
- await this.openModule(item); //展开模块
- } else if (item.type == 2) {
- await this.openChapter(item); //展开章
- } else {
- try {
- await this.waitCheckStatus(item); //检查是否可以继续执行
- if (item.type == 3) {
- if (item.sectionType == 1) {
- this.watchSection(item);
- } else {
- this.watchJumpSection(item);
- }
- }
- if (item.type == -1) {
- this.doExam(item);
- }
- } catch (error) {
- console.error("菜单展开逻辑报错:",error);
- }
- }
- },
- //检查是否可以继续执行
- waitCheckStatus(item) {
- return new Promise(async (resolve, reject) => {
- if (
- item.type == 3 &&
- ((item.sectionType == 1 && !item.recordingUrl) ||
- (item.sectionType == 2 && !item.liveUrl) ||
- (item.sectionType == 3 && !item.recordingUrl))
- ) {
- this.$message({
- type: "warning",
- message: `暂无播放地址数据`
- });
- return reject();
- }
- if (item.type == -1 && item.doType != 1 && item.learning == 1) {
- this.$message.warning("考试已通过,请勿重复考试");
- return reject();
- }
- if (!this.orderTopTobottom(item)) {
- this.$message({
- type: "warning",
- message:
- item.type == -1
- ? "请学完视频课程再进行练习和测试"
- : "请按顺序学习视频课程"
- });
- return reject();
- }
- // 检查学习次数
- if (!(await this.exceedLearnNum(item))) {
- return reject();
- }
- resolve();
- });
- },
- //播放视频节
- watchSection(item) {
- if (this.isActive(item)) return;
- this.$emit("update:activeSection", item);
- setTimeout(() => {
- this.$bus.$emit("toPlay", item);
- }, 100);
- let query = {
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId,
- courseId: item.courseId,
- moduleId: item.moduleId || 0,
- chapterId: item.chapterId || 0,
- sectionId: item.sectionId || 0
- };
- this.$router.replace({ path: this.$route.path, query });
- },
- //回放或直播
- async watchJumpSection(item) {
- if (item.sectionType == 2) {
- let data = await this.studyRecordGetChannelBasicInfo(item.liveUrl);
- if (data.watchStatus == "end" || data.watchStatus == "playback") {
- this.$message({
- type: "warning",
- message: `直播已结束`
- });
- return;
- }
- if (data.watchStatus == "waiting") {
- this.$message({
- type: "warning",
- message: `直播未开始`
- });
- return;
- }
- }
- this.$confirm(
- `确定前往观看${
- item.sectionType == 2 ? " [直播] " : " [回放] "
- }${item.sectionName || item.name}?`,
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }
- )
- .then(() => {
- var query = {
- goodsName: this.goodsData.name,
- goodsId: this.goodsData.goodsId,
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId,
- courseId: item.courseId,
- sectionId: item.sectionId,
- chapterId: item.chapterId,
- moduleId: item.moduleId,
- sectionType: item.sectionType,
- vid: item.recordingUrl // 回放vid
- };
- this.$router.push({
- path: "/living-room/" + item.liveUrl,
- query
- });
- })
- .catch(() => {});
- },
- //判断跳转试卷
- async doExam(item, type) {
- if (this.repeatShowTips) {
- this.$confirm("是否跳转做题页面?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- this.jumpExam(item, type);
- })
- .catch(() => {});
- } else {
- this.repeatShowTips = true;
- this.jumpExam(item, type);
- }
- },
- //跳转试卷页面
- jumpExam(item, type) {
- this.$router.push({
- path: "/course-exam/" + this.goodsData.goodsId,
- query: {
- orderGoodsId: this.goodsData.orderGoodsId,
- gradeId: this.goodsData.gradeId,
- courseId: this.courseList[0].courseId,
- moduleId: item.moduleId || 0,
- chapterId: item.chapterId || 0,
- sectionId: item.sectionId || 0,
- examId: item.typeId,
- learning: item.learning,
- type: type || item.examType,
- nextStatus: "next" //是否继续播放课程
- }
- });
- },
- //查看直播状态
- studyRecordGetChannelBasicInfo(channelId) {
- return new Promise(resolve => {
- this.$request
- .studyRecordGetChannelBasicInfo({
- channelId
- })
- .then(res => {
- resolve(res.data);
- })
- .catch(err => {
- this.$message.error(err.msg);
- });
- });
- },
- //限制播放顺序
- orderTopTobottom(item) {
- if (this.businessData.goodsLearningOrder != 2 || item.sectionType == 2) {
- return true;
- }
- const Findex = this.allSectionList.findIndex(i => {
- if (item.type == 3) {
- return (
- i.type == item.type &&
- i.moduleId == item.moduleId &&
- i.chapterId == item.chapterId &&
- i.sectionId == item.sectionId
- );
- } else {
- return (
- i.type == item.type &&
- i.typeId == item.typeId &&
- i.moduleId == item.moduleId &&
- i.chapterId == item.chapterId
- );
- }
- });
- if (Findex == -1) {
- return true;
- } else {
- const Ary = this.allSectionList.slice(0, Findex);
- if (Ary.length == 0) {
- return true;
- } else {
- return Ary.every(i => i.studyStatus == 1 && !(i.rebuild > 0));
- }
- }
- },
- // 检查学习次数
- async exceedLearnNum(section) {
- let learnNum = await this.goodsTodayStudySectionNum();
- let hasLearn = await this.gradeCheckGoodsStudy(section);
- if (
- this.goodsData.sectionMaxNum > 0 &&
- learnNum >= this.goodsData.sectionMaxNum &&
- !hasLearn
- ) {
- this.$message({
- type: "warning",
- message: `每天最多学习${this.goodsData.sectionMaxNum}节`
- });
- return false;
- }
- return true;
- },
- goodsTodayStudySectionNum() {
- return new Promise(resolve => {
- this.$request
- .goodsTodayStudySectionNum({
- goodsId: this.goodsData.goodsId,
- orderGoodsId: this.goodsData.orderGoodsId,
- gradeId: this.goodsData.gradeId
- })
- .then(res => {
- resolve(res.data);
- });
- });
- },
- gradeCheckGoodsStudy(option) {
- return new Promise(resolve => {
- let data = {
- type: option.type == -1 ? 2 : 1,
- goodsId: this.goodsData.goodsId,
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId,
- moduleId: option.moduleId || 0,
- chapterId: option.chapterId || 0
- };
- if (option.type == -1) {
- data.examId = option.typeId;
- } else {
- data.sectionId = option.sectionId;
- }
- this.$request.gradeCheckGoodsStudy(data).then(res => {
- resolve(res.data);
- });
- });
- },
- bankRecordDoNum(section) {
- return new Promise(resolve => {
- this.$request
- .bankRecordDoNum({
- goodsId: this.goodsData.goodsId,
- orderGoodsId: this.goodsData.orderGoodsId,
- gradeId: this.goodsData.gradeId,
- courseId: this.courseList[0].courseId,
- moduleId: 0,
- chapterId: section.chapterId,
- examId: section.typeId
- })
- .then(res => {
- resolve(res.data);
- });
- });
- },
- //播放逻辑
- async playBackLogic() {
- const { courseId, moduleId, chapterId, sectionId } = this.$route.query;
- if (courseId >= 0 && moduleId >= 0 && chapterId >= 0 && sectionId >= 0) {
- let data = this.allSectionList.find(
- e =>
- e.courseId == courseId &&
- e.moduleId == moduleId &&
- e.chapterId == chapterId &&
- e.sectionId == sectionId
- );
- this.openMenu(data);
- this.unfoldFunc(data); //展开定位列表
- } else {
- this.$request
- .studyRecordQueryLiveLast({
- gradeId: this.goodsData.gradeId,
- orderGoodsId: this.goodsData.orderGoodsId,
- courseId: this.courseList[0].courseId
- })
- .then(res => {
- let data = res.data;
- if (data && data.endTime > parseInt(new Date().getTime() / 1000)) {
- this.$confirm(
- "当前无法学习," +
- this.$tools.timestampToTime(data.endTime, false) +
- "过后可继续学习",
- "提示",
- {
- confirmButtonText: "确定",
- closeOnClickModal: false,
- closeOnPressEscape: false,
- showCancelButton: false,
- distinguishCancelAndClose: false,
- showClose: false
- }
- )
- .then(_ => {
- this.$router.back(-1);
- })
- .catch(_ => {});
- return;
- }
- if (!data.sectionId) {
- data = this.allSectionList[0];
- } else {
- data.type = 3;
- }
- if (
- data.learning == 1 &&
- this.businessData.goodsLearningOrder == 2
- ) {
- let next = this.allSectionList.find(e => e.studyStatus != 1);
- next && (data = next);
- }
- this.openMenu(data);
- this.unfoldFunc(data); //展开定位列表
- });
- }
- },
- //展开定位列表
- unfoldFunc(item, status = false, Renewal = false) {
- return new Promise(async resolve => {
- var scrollTopFunc = () => {
- var scrollTop = document.getElementsByClassName("activeImg_style")[0]
- .offsetTop;
- document.getElementsByClassName(
- "courseTree"
- )[0].scrollTop = scrollTop;
- }; //滚动到当前播放位置
- if (item.moduleId) {
- let moduleChildren = await this.openModule(
- this.courseDataList.find(i => i.moduleId == item.moduleId),
- status,
- Renewal
- );
- if (item.chapterId) {
- await this.openChapter(
- moduleChildren.find(i => i.chapterId == item.chapterId),
- status,
- Renewal
- );
- scrollTopFunc();
- }
- }
- if (!item.moduleId && item.chapterId) {
- await this.openChapter(
- this.courseDataList.find(i => i.chapterId == item.chapterId),
- status,
- Renewal
- );
- scrollTopFunc();
- }
- resolve();
- });
- },
- //已学完,重新定位
- async BackVideoFunc() {
- let hasNoStudyStatus = this.allSectionList.find(i => i.studyStatus == -1); //更新前是否存在未学完的课程
- await this.getAllSectionList(); //获取所有节列表
- await this.unfoldFunc(this.activeSection, true, true);
- if (this.businessData.goodsLearningOrder == 2) {
- var ary = this.allSectionList.find(i => i.studyStatus != 1);
- } else {
- var ary = null;
- let index = this.allSectionList.findIndex(
- i =>
- i.courseId == this.activeSection.courseId &&
- i.moduleId == this.activeSection.moduleId &&
- i.chapterId == this.activeSection.chapterId &&
- i.sectionId == this.activeSection.sectionId
- );
- this.$emit(
- "update:activeSection",
- Object.assign({}, this.allSectionList[index])
- ); //重新赋值当前节数据
- ary = this.allSectionList[index + 1];
- if (ary && ary.studyStatus == 1) {
- ary = null;
- hasNoStudyStatus = null;
- }
- }
- if (ary) {
- if (ary.type != 3) {
- this.$confirm(
- "本章视频已学习完成,继续进行下一个考试?",
- "温馨提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }
- )
- .then(() => {
- this.repeatShowTips = false; //是否显示跳转提示
- this.openMenu(ary);
- this.unfoldFunc(ary, true, true);
- })
- .catch(() => {});
- } else {
- this.$confirm("当前视频已学完,继续学习下一个视频?", "温馨提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- this.openMenu(ary);
- this.unfoldFunc(ary, true, true);
- })
- .catch(() => {});
- }
- } else {
- if (hasNoStudyStatus) {
- this.$alert(
- "恭喜您课程学习全部完成,教务会在1-3个工作日内完成学习初审,请耐心等待。",
- "温馨提示",
- {
- confirmButtonText: "确定",
- showClose: false,
- callback: action => {
- if (action == "confirm") {
- this.jumpPage();
- }
- }
- }
- );
- }
- }
- },
- //回到个人中心
- jumpPage() {
- this.$router.replace({
- path: "/person-center/my-course"
- });
- }
- },
- beforeDestroy() {
- this.$bus.$off("BackVideoFunc");
- }
- };
- </script>
- <style lang="scss" scoped>
- .active {
- background-color: rgb(107, 107, 107) !important;
- }
- .activeImg_style {
- width: 20px;
- height: 30px;
- }
- .courseTree {
- height: 416px;
- overflow: auto;
- user-select: none;
- &::-webkit-scrollbar {
- width: 5px;
- height: 9px;
- }
- /*定义滚动条轨道 内阴影+圆角*/
- &::-webkit-scrollbar-track {
- background-color: inherit;
- border: none;
- border-radius: 10px;
- }
- /*定义滑块 内阴影+圆角*/
- &::-webkit-scrollbar-thumb {
- border-radius: 10px;
- position: relative;
- right: 2px;
- background-color: #c6c6cd;
- width: 6px;
- }
- }
- .level1 {
- padding-left: 0px;
- }
- .level2 {
- padding-left: 10px;
- }
- .level3 {
- padding-left: 20px;
- }
- .menu_box {
- margin-top: 4px;
- padding: 0px 10px;
- display: flex;
- align-items: center;
- min-height: 30px;
- max-height: 60px;
- color: #fff;
- cursor: pointer;
- &:hover {
- background-color: rgb(81, 81, 81);
- }
- & > .left {
- flex-shrink: 0;
- padding-right: 10px;
- }
- & > .center {
- flex: 1;
- word-break: break-all;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- & > .right {
- & > .during {
- margin-right: 4px;
- }
- display: flex;
- align-items: center;
- // width: 80px;
- flex-shrink: 0;
- }
- }
- .live_style {
- & > span {
- font-size: 12px;
- }
- }
- </style>
|