소스 검색

fix:定位节位置

Tang 3 년 전
부모
커밋
522fb8cb7c
1개의 변경된 파일69개의 추가작업 그리고 54개의 파일을 삭제
  1. 69 54
      src/pages/course-detail/index.vue

+ 69 - 54
src/pages/course-detail/index.vue

@@ -2698,7 +2698,7 @@ export default {
       // if (liveMenu && liveMenu.length) {
       //   earlyTime = liveMenu[0].liveStartTime;
       // }
-  
+
       await this.courseCourseList();
       if (this.sectionItem.recordingUrl) {
         let noteSecond = this.$route.query.noteSecond;
@@ -2792,7 +2792,7 @@ export default {
      * 获取观看记录
      */
     studyRecordQueryLiveLast() {
-      return new Promise((resolve,reject)=>{
+      return new Promise((resolve, reject) => {
         this.$request
           .studyRecordQueryLiveLast({
             orderGoodsId: this.orderGoodsId,
@@ -2821,12 +2821,16 @@ export default {
                 this.sectionItem = res.data;
                 this.playVideo(res.data);
               }
-              resolve(true)
-            }else{
-              resolve(false)
+              if (res.data.sectionId > 0) {
+                resolve(true);
+              } else {
+                resolve(false);
+              }
+            } else {
+              resolve(false);
             }
           });
-      })
+      });
     },
     /**
      * 
@@ -4390,6 +4394,7 @@ export default {
      */
     courseChange() {
       return new Promise((resolve) => {
+        this.needOpen = true
         this.noteParams = {
           pageNum: 1,
           // pageSize: 4,
@@ -4450,7 +4455,7 @@ export default {
         self.detail = res.data;
       });
     },
-    openModule(menuItem,status = false) {
+    openModule(menuItem, status = false) {
       //重修目录点击
       console.log(menuItem.list);
       menuItem.showList = !menuItem.showList;
@@ -4459,7 +4464,12 @@ export default {
         if (menuItem.isRebuild) {
           this.getReChapterList(menuItem.id, menuItem.courseId, menuItem);
         } else {
-          this.getBuyChapterList(menuItem.id, menuItem.courseId, menuItem,status);
+          this.getBuyChapterList(
+            menuItem.id,
+            menuItem.courseId,
+            menuItem,
+            status
+          );
         }
       }
     },
@@ -4484,7 +4494,7 @@ export default {
         });
     },
 
-    getBuyChapterList(moduleId, courseId, menuItem,status) {
+    getBuyChapterList(moduleId, courseId, menuItem, status) {
       this.$request
         .reChapterList({
           moduleId: moduleId,
@@ -4501,24 +4511,23 @@ export default {
             item.parent = menuItem;
           }
           menuItem.list = res.data;
-          if(status){
-            console.log(this.sectionItem,"this.sectionItem")
-            console.log(menuItem.list,"menuItem.list")
-            const FindIndexs = menuItem.list.findIndex(item => {
-              return item.chapterId == this.sectionItem.chapterId
-            })
-            if(FindIndexs != -1){
+          if (status) {
+            console.log(this.sectionItem, "this.sectionItem");
+            console.log(menuItem.list, "menuItem.list");
+            const FindIndexs = menuItem.list.findIndex((item) => {
+              return item.chapterId == this.sectionItem.chapterId;
+            });
+            if (FindIndexs != -1) {
               this.openChapter(menuItem.list[FindIndexs]);
-            }else{
-              this.$message.warning("章列表定位失败")
+            } else {
+              this.$message.warning("章列表定位失败");
+            }
+          } else {
+            if (this.needOpen) {
+              // this.needOpen = false;
+              this.openChapter(menuItem.list[0]);
             }
-          }else{
-if (this.needOpen) {
-            // this.needOpen = false;
-            this.openChapter(menuItem.list[0]);
-          }
           }
-          
         });
     },
     openChapter(chapter) {
@@ -6105,7 +6114,7 @@ if (this.needOpen) {
       let self = this;
       this.$request
         .reMenuList({ courseId: this.courseId, gradeId: this.gradeId })
-        .then(async(res) => {
+        .then(async (res) => {
           for (let i = 0; i < res.rows.length; i++) {
             let item = res.rows[i];
             item.id = item.menuId;
@@ -6116,49 +6125,55 @@ if (this.needOpen) {
             item.parent = this.menuList;
           }
           self.menuList = res.rows;
-          const changeStatus = await this.studyRecordQueryLiveLast()
-          if(changeStatus){
+          const changeStatus = await this.studyRecordQueryLiveLast();
+          if (changeStatus) {
             for (let i = 0; i < res.rows.length; i++) {
-              if (res.rows[i].type == 1 && res.rows[i].menuId == this.sectionItem.moduleId) {
+              if (
+                res.rows[i].type == 1 &&
+                res.rows[i].menuId == this.sectionItem.moduleId
+              ) {
                 this.menuIndex = [i];
-                this.openModule(this.menuList[i],true);
+                this.openModule(this.menuList[i], true);
                 break;
-              } else if (res.rows[i].type == 2 && res.rows[i].menuId == this.sectionItem.chapterId && !this.sectionItem.moduleId) {
+              } else if (
+                res.rows[i].type == 2 &&
+                res.rows[i].menuId == this.sectionItem.chapterId &&
+                !this.sectionItem.moduleId
+              ) {
                 this.menuIndex = [i];
                 // this.needOpen = false;
                 this.openChapter(this.menuList[i]);
                 break;
               }
             }
-          }else{
-//展开第一个
-          if (this.needOpen) {
-            for (let i = 0; i < res.rows.length; i++) {
-              if (res.rows[i].type == 1) {
-                this.menuIndex = [i];
-                this.openModule(this.menuList[i]);
-                break;
-              } else if (res.rows[i].type == 2) {
-                this.menuIndex = [i];
-                // this.needOpen = false;
-                this.openChapter(this.menuList[i]);
-                break;
+          } else {
+            //展开第一个
+            if (this.needOpen) {
+              for (let i = 0; i < res.rows.length; i++) {
+                if (res.rows[i].type == 1) {
+                  this.menuIndex = [i];
+                  this.openModule(this.menuList[i]);
+                  break;
+                } else if (res.rows[i].type == 2) {
+                  this.menuIndex = [i];
+                  // this.needOpen = false;
+                  this.openChapter(this.menuList[i]);
+                  break;
+                }
               }
-            }
 
-            //第一个是节,直接播放
-            if (self.menuList.length) {
-              if (
-                self.menuList[0].type == 3 &&
-                !this.sectionItem.recordingUrl &&
-                self.menuList[0].sectionType != 2
-              ) {
-                // this.getResource(self.menuList[0]);
+              //第一个是节,直接播放
+              if (self.menuList.length) {
+                if (
+                  self.menuList[0].type == 3 &&
+                  !this.sectionItem.recordingUrl &&
+                  self.menuList[0].sectionType != 2
+                ) {
+                  // this.getResource(self.menuList[0]);
+                }
               }
             }
           }
-          }
-          
         });
     },