xuqiaoying 3 年之前
父節點
當前提交
19f729d8ca
共有 1 個文件被更改,包括 39 次插入30 次删除
  1. 39 30
      src/pages/person-center/my-course/index.vue

+ 39 - 30
src/pages/person-center/my-course/index.vue

@@ -50,7 +50,7 @@
           >{{ item.name }}</el-button
         >
       </div>
-      <div v-for="(courseItem, index) in goodsTeacher" :key="index + 'one'">
+      <div v-for="(courseItem, teacherIndex) in goodsTeacher" :key="teacherIndex">
       <div v-for="(item, index) in courseItem.courseList" :key="index + 'two'" v-show="item.subjectId === newActiveSubjectId || !newActiveSubjectId">
         <div v-if="item.show == 1">
         <div class="firstTop hoverStyle" >
@@ -80,7 +80,7 @@
             <div v-if="items.type === 1" :key="indexs">
               <p
                 class="moduleStyle hoverStyle"
-                @click="changeModuleStatus(items, index, indexs)"
+                @click="changeModuleStatus(items, index, indexs, teacherIndex)"
               >
                 {{ items.menuName }}
                 <span class="showHide"
@@ -102,7 +102,7 @@
                 >
                   <div
                     class="chapterStyle hoverStyle"
-                    @click="changeChapterStatus(2, i, index, indexs, k)"
+                    @click="changeChapterStatus(teacherIndex, 2, i, index, indexs, k)"
                   >
                     <!-- <span class="iconStyle">章</span> -->
                     {{ i.name }}
@@ -264,7 +264,7 @@
             <div v-if="items.type === 2" :key="indexs">
               <div
                 class="chapterStyle hoverStyle"
-                @click="changeChapterStatus(1, items, index, indexs)"
+                @click="changeChapterStatus(teacherIndex, 1, items, index, indexs)"
               >
                 <!-- <span class="iconStyle">章</span> -->
                 {{ items.menuName }}
@@ -865,35 +865,38 @@ export default {
         if (res.data && res.data.sectionId) {
           await this.getGoodsData(res);
           var stop = false;
-          for (let i = 0; i < this.courseList.length; i++) {
+          for(let y = 0; y < this.goodsTeacher.length; y++){
+          for (let i = 0; i <  this.goodsTeacher[y].courseList.length; i++) {
             if (stop) {
               break;
             }
-            if (this.courseList[i].courseId == res.data.courseId) {
-              await this.changeStatus(this.courseList[i]);
-              for (let k = 0; k < this.courseList[i].children.length; k++) {
+            if (this.goodsTeacher[y].courseList[i].courseId == res.data.courseId) {
+              await this.changeStatus(this.goodsTeacher[y].courseList[i]);
+              for (let k = 0; k < this.goodsTeacher[y].courseList[i].children.length; k++) {
                 if (res.data.moduleId) {
                   console.log(1);
                   if (
-                    this.courseList[i].children[k].menuId == res.data.moduleId
+                    this.goodsTeacher[y].courseList[i].children[k].menuId == res.data.moduleId
                   ) {
                     await this.changeModuleStatus(
-                      this.courseList[i].children[k],
+                      this.goodsTeacher[y].courseList[i].children[k],
                       i,
-                      k
+                      k,
+                      y
                     );
                     for (
                       let j = 0;
-                      j < this.courseList[i].children[k].children.length;
+                      j < this.goodsTeacher[y].courseList[i].children[k].children.length;
                       j++
                     ) {
                       if (
-                        this.courseList[i].children[k].children[j].chapterId ==
+                        this.goodsTeacher[y].courseList[i].children[k].children[j].chapterId ==
                         res.data.chapterId
                       ) {
                         await this.changeChapterStatus(
+                          y,
                           2,
-                          this.courseList[i].children[k].children[j],
+                          this.goodsTeacher[y].courseList[i].children[k].children[j],
                           i,
                           k,
                           j
@@ -902,17 +905,17 @@ export default {
                         for (
                           let m = 0;
                           m <
-                          this.courseList[i].children[k].children[j].children
+                          this.goodsTeacher[y].courseList[i].children[k].children[j].children
                             .length;
                           m++
                         ) {
                           if (
-                            this.courseList[i].children[k].children[j].children[
+                            this.goodsTeacher[y].courseList[i].children[k].children[j].children[
                               m
                             ].sectionId == res.data.sectionId
                           ) {
                             this.$set(
-                              this.courseList[i].children[k].children[j]
+                              this.goodsTeacher[y].courseList[i].children[k].children[j]
                                 .children[m],
                               "recordStatus",
                               true
@@ -927,25 +930,26 @@ export default {
                 } else if (res.data.chapterId) {
                   console.log(2);
                   if (
-                    this.courseList[i].children[k].menuId == res.data.chapterId
+                    this.goodsTeacher[y].courseList[i].children[k].menuId == res.data.chapterId
                   ) {
                     await this.changeChapterStatus(
+                      y,
                       1,
-                      this.courseList[i].children[k],
+                      this.goodsTeacher[y].courseList[i].children[k],
                       i,
                       k
                     );
                     for (
                       let j = 0;
-                      j < this.courseList[i].children[k].children.length;
+                      j < this.goodsTeacher[y].courseList[i].children[k].children.length;
                       j++
                     ) {
                       if (
-                        this.courseList[i].children[k].children[j].sectionId ==
+                        this.goodsTeacher[y].courseList[i].children[k].children[j].sectionId ==
                         res.data.sectionId
                       ) {
                         this.$set(
-                          this.courseList[i].children[k].children[j],
+                          this.goodsTeacher[y].courseList[i].children[k].children[j],
                           "recordStatus",
                           true
                         );
@@ -957,10 +961,10 @@ export default {
                 } else {
                   console.log(3);
                   if (
-                    this.courseList[i].children[k].menuId == res.data.sectionId
+                    this.goodsTeacher[y].courseList[i].children[k].menuId == res.data.sectionId
                   ) {
                     this.$set(
-                      this.courseList[i].children[k],
+                      this.goodsTeacher[y].courseList[i].children[k],
                       "recordStatus",
                       true
                     );
@@ -971,6 +975,7 @@ export default {
               }
             }
           }
+          }
         } else {
           this.resultCourseGoodsList();
         }
@@ -1024,8 +1029,9 @@ export default {
     /**
      * 模块详情列表
      */
-    changeModuleStatus(item, index, indexs) {
+    changeModuleStatus(item, index, indexs,teacherIndex) {
       return new Promise((resolve, reject) => {
+        console.log(item,'item');
         if (item.children && item.children.length > 0) {
           item.showStatus = !item.showStatus;
           return;
@@ -1041,8 +1047,9 @@ export default {
               items.children = [];
               items.showStatus = false;
             });
+            console.log(teacherIndex,'teacherIndex');
             this.$set(
-              this.courseList[index].children[indexs],
+              this.goodsTeacher[teacherIndex].courseList[index].children[indexs],
               "children",
               res.data
             );
@@ -1054,10 +1061,10 @@ export default {
     /**
      * 章详情列表 type = 1 父级章 type = 2 父级模块
      */
-    changeChapterStatus(type, item, courseIndex, index, indexs) {
+    changeChapterStatus(teacherIndex,type, item, courseIndex, index, indexs) {
       return new Promise((resolve, reject) => {
         console.log(item, "定位");
-        console.log(type, item, courseIndex, index, indexs)
+        console.log(type, item, courseIndex, index, indexs,teacherIndex)
         if (item.children && item.children.length > 0) {
           item.showStatus = !item.showStatus;
           return;
@@ -1084,16 +1091,18 @@ export default {
             res.data.forEach((section) => {
               section.canLearn = canLearn;
             });
+            console.log(teacherIndex,'teacherIndex');
+            console.log(courseIndex,'courseIndex');
             if (type === 1) {
               this.$set(
-                this.courseList[courseIndex].children[index],
+                this.goodsTeacher[teacherIndex].courseList[courseIndex].children[index],
                 "children",
                 res.data
               );
             }
             if (type === 2) {
               this.$set(
-                this.courseList[courseIndex].children[index].children[indexs],
+                this.goodsTeacher[teacherIndex].courseList[courseIndex].children[index].children[indexs],
                 "children",
                 res.data
               );