xiejiebiao %!s(int64=2) %!d(string=hai) anos
pai
achega
c8f3852fde
Modificáronse 2 ficheiros con 74 adicións e 31 borrados
  1. 72 16
      src/components/courseTree/CourseTree.vue
  2. 2 15
      src/pages/course-detail/index.vue

+ 72 - 16
src/components/courseTree/CourseTree.vue

@@ -150,7 +150,8 @@
                                                     <div class="exercises" @click.stop="
                                                         handelPracticeOrRxam(
                                                             section,
-                                                            2
+                                                            2,
+                                                            courseItem.courseId
                                                         )
                                                     ">
                                                         习题
@@ -339,7 +340,8 @@
                                                     <div class="exercises" @click.stop="
                                                         handelPracticeOrRxam(
                                                             section,
-                                                            2
+                                                            2,
+                                                            courseItem.courseId
                                                         )
                                                     ">
                                                         习题
@@ -467,7 +469,8 @@
                                             'sectionExamList'
                                         )
                                     ">
-                                        <div class="exercises" @click.stop="handelPracticeOrRxam(menu, 3)">
+                                        <div class="exercises"
+                                            @click.stop="handelPracticeOrRxam(menu, 3, courseItem.courseId)">
                                             习题
                                             <i class="el-icon-arrow-right icons"></i>
                                         </div>
@@ -496,6 +499,12 @@ export default {
         },
         sectionMaxNum: {
             type: Number
+        },
+        sectionItem: {
+            type: Object,
+            default: () => {
+                return {}
+            }
         }
     },
     data() {
@@ -504,7 +513,6 @@ export default {
             nowTime: 0,
             treeList: [],
             query: this.$route.query,
-            sectionItem: {},
             sectionExam: [],
             sectionExamList: []
         }
@@ -521,17 +529,16 @@ export default {
             this.treeList = await this.getDoubleTeacherList()
             let index = this.treeList.findIndex(e => e.courseId == this.activeCourseId)
             let list = await this.getMenuList(this.treeList[index])
-
             // 判断已选中的视频的父级 
-            let { moduleId, chapterId, sectionId } = this.query
-            if (moduleId) {
+            let { moduleId, chapterId, sectionId, sectionType } = this.query
+            if (moduleId * 1) {
                 list = await this.openModule(list.find(e => e.menuId == moduleId), true);
             }
-            if (chapterId) {
-                list = await this.openChapter(list.find(e => e.chapterId == chapterId))
+            if (chapterId * 1) {
+                list = await this.openChapter(list.find(e => e[moduleId * 1 ? 'chapterId' : 'menuId'] == chapterId))
             }
-            this.sectionItem = list.find(e => e.id == sectionId)
-            console.log(this.sectionItem, 'this.sectionItem', list, sectionId)
+            let sectionItem = list.find(e => e[(moduleId * 1 || chapterId * 1) ? 'sectionId' : 'id'] == sectionId)
+            this.$emit('getResource', sectionItem)
         },
         activeFunc(courseId, index) {
             let { courseId: nowCourseId, courseList } = this.treeList[index]
@@ -674,9 +681,9 @@ export default {
                     return;
                 }
             }
-            section.type == 2 ? this.toCourseExam(section) : this.toPlay()
+            section.type == 2 ? this.toCourseExam(section, type, courseIndex) : this.toPlay(section)
         },
-        async toCourseExam(section, type) {
+        async toCourseExam(section, type, courseIndex) {
             //试卷
             // 学习次数
             if (!(await this.exceedLearnNum(section))) {
@@ -690,7 +697,7 @@ export default {
                 this.$router.push({
                     path: "/course-exam/" + this.goodsId,
                     query: {
-                        courseId: this.courseId,
+                        courseId: this.treeList[courseIndex].courseId,
                         gradeId: this.gradeId,
                         moduleId: section.moduleId || 0,
                         sectionId: section.sectionId || 0,
@@ -709,6 +716,40 @@ export default {
                 return;
             }
         },
+        handelPracticeOrRxam(section, type, courseId) {
+            if (type == 3) {
+                //节卷
+                let data = this.sectionExamList.filter(
+                    (x) => x.sectionId == section.menuId
+                );
+                if (data && data.length > 0) {
+                    section = data[0];
+                }
+            } else if (type == 2) {
+                //节卷
+                let data = this.sectionExam.filter(
+                    (x) => x.sectionId == section.sectionId
+                );
+
+                if (data && data.length > 0) {
+                    section = data[0];
+                }
+            }
+            this.$router.push({
+                path: "/course-exam/" + this.goodsId,
+                query: {
+                    courseId,
+                    gradeId: this.gradeId,
+                    moduleId: section.moduleId || 0,
+                    sectionId: section.sectionId || 0,
+                    examId: section.typeId,
+                    learning: section.learning,
+                    type: type,
+                    chapterId: section.chapterId || 0,
+                    orderGoodsId: this.orderGoodsId,
+                },
+            });
+        },
         async exceedLearnNum(section) {
             let learnNum = await this.goodsTodayStudySectionNum();
             let hasLearn = await this.gradeCheckGoodsStudy(section.typeId);
@@ -766,8 +807,23 @@ export default {
                     });
             });
         },
-        toPlay() {
-            // this.$emit('getResource', section, type)
+        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;
+            // }
+            if (section == this.sectionItem) {
+                return
+            }
+            this.$emit('getResource', section)
         },
         //获取商品双师资模板
         getDoubleTeacherList() {

+ 2 - 15
src/pages/course-detail/index.vue

@@ -48,8 +48,8 @@
                           <!-- 章节目录 -->
                           <template v-if="tab.name == '1'">
                             <Course-tree :courseList="courseList" :goodsLearningOrder="businessData.goodsLearningOrder"
-                              :sectionMaxNum="goodsData.sectionMaxNum" @getMenuList="getMenuList"
-                              @getResource="getResource">
+                              :sectionItem.sync="sectionItem" :sectionMaxNum="goodsData.sectionMaxNum"
+                              @getMenuList="getMenuList" @getResource="getResource">
                             </Course-tree>
                             <!-- <div class="right-box__body">
                               <div v-for="(courseItem, courseIndex) in courseList" :key="courseIndex">
@@ -4681,20 +4681,7 @@ export default {
         return;
       }
       this.clickLock = true;
-      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.initVideo(section);
-
     },
     bankRecordDoNum(section) {
       return new Promise((resolve) => {