lsc 2 years ago
parent
commit
806febea66
3 changed files with 550 additions and 211 deletions
  1. BIN
      src/assets/lock.png
  2. 235 171
      src/components/index.vue
  3. 315 40
      src/components/studyStudent.vue

BIN
src/assets/lock.png


+ 235 - 171
src/components/index.vue

@@ -17,24 +17,43 @@
             <div class="search" @click="selectAll">
               <img src="../assets/icon/search.png" alt="" />
             </div>
-            <input class="sInput" type="text" placeholder="请输入关键字" v-model="sCourse" />
+            <input
+              class="sInput"
+              type="text"
+              placeholder="请输入关键字"
+              v-model="sCourse"
+            />
           </div>
         </div>
         <div class="choose">
-          <div class="all_choose" v-for="(item, index) in CourseType[0]" :key="index">
+          <div
+            class="all_choose"
+            v-for="(item, index) in CourseType[0]"
+            :key="index"
+          >
             <span>{{ item.name }}:</span>
             <div class="typeCss">
-              <div class="cName" @click="getCourse(item.name, '', item.id, 1)"
-                :class="typeE.indexOf(item.id) != -1 ? 'isCType' : ''">
+              <div
+                class="cName"
+                @click="getCourse(item.name, '', item.id, 1)"
+                :class="typeE.indexOf(item.id) != -1 ? 'isCType' : ''"
+              >
                 全部
               </div>
-              <div v-for="item1 in CourseTypeJson[item.id]" :key="item1.id" :label="item1.id"
-                @click="getCourse(item.name, item.id, item1.id, 2)">
-                <div class="cName" :class="
-                  typea == item1.id || typeb == item1.id || typed == item1.id
-                    ? 'isCType'
-                    : ''
-                ">
+              <div
+                v-for="(item1, index1) in CourseTypeJson[item.id]"
+                :key="index + '-' + index1"
+                :label="item1.id"
+                @click="getCourse(item.name, item.id, item1.id, 2)"
+              >
+                <div
+                  class="cName"
+                  :class="
+                    typea == item1.id || typeb == item1.id || typed == item1.id
+                      ? 'isCType'
+                      : ''
+                  "
+                >
                   {{ item1.name }}
                 </div>
               </div>
@@ -58,32 +77,46 @@
           </div> -->
         <div>
           <div class="main_box">
-            <div class="box_course" v-for="(item, index) in zoneClass" :key="index">
+            <div
+              class="box_course"
+              v-for="(item, index) in zoneClass"
+              :key="index"
+            >
               <div class="wheel">
-                <img :src="
-                  item.cover
-                    ? JSON.parse(item.cover)[0].url
-                    : require('../assets/wheel.png')
-                " alt="" />
+                <img
+                  :src="
+                    item.cover
+                      ? JSON.parse(item.cover)[0].url
+                      : require('../assets/wheel.png')
+                  "
+                  alt=""
+                />
               </div>
               <div class="middle_white">
                 <div class="textOverflow">{{ item.title }}</div>
                 <div class="nameAndLength">
-                  <el-tooltip class="typeN" effect="light" :content="item.typename" placement="top">
+                  <el-tooltip
+                    class="typeN"
+                    effect="light"
+                    :content="item.typename"
+                    placement="top"
+                  >
                     <div>{{ item.typename }}</div>
                   </el-tooltip>
 
-                  <div>
-                    {{ JSON.parse(item.chapters).length }}阶段
-                  </div>
+                  <div>{{ JSON.parse(item.chapters).length }}阶段</div>
                 </div>
                 <div class="school_box">
-                  <el-tooltip effect="light" :content="item.school" placement="top">
+                  <el-tooltip
+                    effect="light"
+                    :content="item.school"
+                    placement="top"
+                  >
                     <div class="school">
                       {{ item.school }}
                     </div>
                   </el-tooltip>
-                  <div style="color: #b4b4b4;">{{item.utime}}</div>
+                  <div style="color: #b4b4b4">{{ item.utime }}</div>
                 </div>
                 <!-- <div class="people">
                   <div class="man">
@@ -96,24 +129,27 @@
                   </div>
                 </div> -->
               </div>
-              <div class="now_study" @click="
-                goTo(
-                  '/courseDetail?courseId=' +
-                    item.courseId +
-                    '&userid=' +
-                    userid +
-                    '&oid=' +
-                    oid +
-                    '&org=' +
-                    org +
-                    '&cid=' +
-                    classId +
-                    '&tType=' +
-                    tType +
-                    '&screenType=' +
-                    screenType
-                )
-              ">
+              <div
+                class="now_study"
+                @click="
+                  goTo(
+                    '/courseDetail?courseId=' +
+                      item.courseId +
+                      '&userid=' +
+                      userid +
+                      '&oid=' +
+                      oid +
+                      '&org=' +
+                      org +
+                      '&cid=' +
+                      classId +
+                      '&tType=' +
+                      tType +
+                      '&screenType=' +
+                      screenType
+                  )
+                "
+              >
                 立即学习
               </div>
             </div>
@@ -122,12 +158,28 @@
             </div>
           </div>
         </div>
-        <div class="student_page" style="margin: 15px 0 0" v-if="zoneClass.length > 0">
-          <el-pagination background layout="prev, pager, next" :page-size="10" :total="total"
-            v-if="page && zoneListId != 0" @current-change="handleCurrentChange">
+        <div
+          class="student_page"
+          style="margin: 15px 0 0"
+          v-if="zoneClass.length > 0"
+        >
+          <el-pagination
+            background
+            layout="prev, pager, next"
+            :page-size="10"
+            :total="total"
+            v-if="page && zoneListId != 0"
+            @current-change="handleCurrentChange"
+          >
           </el-pagination>
-          <el-pagination background layout="prev, pager, next" :page-size="10" :total="total"
-            v-if="page && zoneListId == 0" @current-change="handleCurrentChange1">
+          <el-pagination
+            background
+            layout="prev, pager, next"
+            :page-size="10"
+            :total="total"
+            v-if="page && zoneListId == 0"
+            @current-change="handleCurrentChange1"
+          >
           </el-pagination>
         </div>
       </div>
@@ -343,7 +395,7 @@ export default {
         typec: "",
         typed: this.typed != undefined ? this.typed : "",
         // typeE: this.typeE.join(","),
-        typeE: '',
+        typeE: "",
         cu: "",
         cn: this.sCourse,
         classid: this.classId,
@@ -358,6 +410,13 @@ export default {
           this.isListAjax = false;
           this.zoneClass = res.data[0];
           this.total = res.data[0].length ? res.data[0][0].num : 0;
+
+          this.selectType({
+            data: [res.data[1], res.data[2], res.data[3], res.data[4]],
+          });
+          this.getBanner({
+            data: [res.data[6], res.data[5], res.data[7]],
+          });
         })
         .catch((err) => {
           console.error(err);
@@ -377,143 +436,148 @@ export default {
       this.selectAll();
     },
     //获取banner
-    getBanner() {
+    getBanner(res) {
       // var a = false;
       // if (this.org == "eb2af5e9-ac3d-46b6-9fe3-3c1c364f018d") {
       //   a = true;
       // }
-      let params = {
-        oid: this.org,
-      };
-      this.ajax
-        .get(this.$store.state.api + "selectBannerByOid", params)
-        .then((res) => {
-          if (res.data[0].length > 0) {
-            this.bannerList = res.data[0];
-          } else {
-            this.getBannerByOid();
-          }
-        })
-        .catch((err) => {
-          console.error(err);
+      // let params = {
+      //   oid: this.org,
+      // };
+      // this.ajax
+      //   .get(this.$store.state.api + "selectBannerByOid", params)
+      //   .then((res) => {
+      if (res.data[0].length > 0) {
+        this.bannerList = res.data[0];
+      } else {
+        this.getBannerByOid({
+          data: [res.data[1], res.data[2]],
         });
+      }
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
-    getBannerByOid() {
-      let params = {
-        oid: this.oid,
-      };
-      this.ajax
-        .get(this.$store.state.api + "selectBannerByOid", params)
-        .then((res) => {
-          if (res.data[0].length > 0) {
-            this.bannerList = res.data[0];
-          } else {
-            this.getOldBanner();
-          }
-        })
-        .catch((err) => {
-          console.error(err);
+    getBannerByOid(res) {
+      // let params = {
+      //   oid: this.oid,
+      // };
+      // this.ajax
+      //   .get(this.$store.state.api + "selectBannerByOid", params)
+      //   .then((res) => {
+      if (res.data[0].length > 0) {
+        this.bannerList = res.data[0];
+      } else {
+        this.getOldBanner({
+          data: [res.data[1]],
         });
+      }
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
-    getOldBanner() {
-      this.ajax
-        .get(this.$store.state.api + "getBanner", "")
-        .then((res) => {
-          this.bannerList = res.data[0];
-        })
-        .catch((err) => {
-          console.error(err);
-        });
+    getOldBanner(res) {
+      // this.ajax
+      //   .get(this.$store.state.api + "getBanner", "")
+      //   .then((res) => {
+      this.bannerList = res.data[0];
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
-    selectType() {
-      this.ajax
-        .get(this.$store.state.api + "selectType")
-        .then((res) => {
-          this.CourseType = res.data;
-          for (var i = 0; i < res.data[0].length; i++) {
-            if (!this.cid) {
-              this.courseTypeId[res.data[0][i].id] = "";
-            }
-            if (this.oid == "69893dca-1d47-11ed-8c78-005056b86db5") {
-              if (res.data[0][i].name == "栏目") {
-                this.CourseType[0][i].name = "主题";
-              }
-            }
-            for (var j = 0; j < res.data[1].length; j++) {
-              if (res.data[0][i].id == res.data[1][j].pid) {
-                if (!this.CourseTypeJson[res.data[0][i].id]) {
-                  this.CourseTypeJson[res.data[0][i].id] = [];
-                }
-                this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
-              }
+    selectType(res) {
+      // this.ajax
+      //   .get(this.$store.state.api + "selectType")
+      //   .then((res) => {
+      this.CourseTypeJson = {};
+      this.CourseType = res.data;
+      for (var i = 0; i < res.data[0].length; i++) {
+        if (!this.cid) {
+          this.courseTypeId[res.data[0][i].id] = "";
+        }
+        if (this.oid == "69893dca-1d47-11ed-8c78-005056b86db5") {
+          if (res.data[0][i].name == "栏目") {
+            this.CourseType[0][i].name = "主题";
+          }
+        }
+        for (var j = 0; j < res.data[1].length; j++) {
+          if (res.data[0][i].id == res.data[1][j].pid) {
+            if (!this.CourseTypeJson[res.data[0][i].id]) {
+              this.CourseTypeJson[res.data[0][i].id] = [];
             }
+            this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
           }
-          this.selectTypeByOid();
-          this.selectTypeByOrg();
-        })
-        .catch((err) => {
-          console.error(err);
-        });
+        }
+      }
+      this.selectTypeByOid({ data: [res.data[0], res.data[2]] });
+      this.selectTypeByOrg({ data: [res.data[0], res.data[3]] });
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
-    selectTypeByOid() {
-      let params = {
-        oid: this.oid,
-      };
-      this.ajax
-        .get(this.$store.state.api + "selectTypeByOid", params)
-        .then((res) => {
-          for (var i = 0; i < res.data[0].length; i++) {
-            for (var j = 0; j < res.data[1].length; j++) {
-              if (res.data[0][i].id == res.data[1][j].pid) {
-                if (!this.CourseTypeJson[res.data[0][i].id]) {
-                  this.CourseTypeJson[res.data[0][i].id] = [];
-                }
-                this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
-              }
+    selectTypeByOid(res) {
+      // let params = {
+      //   oid: this.oid,
+      // };
+      // this.ajax
+      //   .get(this.$store.state.api + "selectTypeByOid", params)
+      //   .then((res) => {
+      for (var i = 0; i < res.data[0].length; i++) {
+        for (var j = 0; j < res.data[1].length; j++) {
+          if (res.data[0][i].id == res.data[1][j].pid) {
+            if (!this.CourseTypeJson[res.data[0][i].id]) {
+              this.CourseTypeJson[res.data[0][i].id] = [];
             }
+            this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
           }
-          this.$forceUpdate();
-        })
-        .catch((err) => {
-          console.error(err);
-        });
+        }
+      }
+      this.$forceUpdate();
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
-    selectTypeByOrg() {
-      let params = {
-        oid: this.org,
-      };
-      this.ajax
-        .get(this.$store.state.api + "selectTypeByOrg", params)
-        .then((res) => {
-          for (var i = 0; i < res.data[0].length; i++) {
-            for (var j = 0; j < res.data[1].length; j++) {
-              if (res.data[0][i].id == res.data[1][j].pid) {
-                if (!this.CourseTypeJson[res.data[0][i].id]) {
-                  this.CourseTypeJson[res.data[0][i].id] = [];
-                }
-                this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
-              }
+    selectTypeByOrg(res) {
+      // let params = {
+      //   oid: this.org,
+      // };
+      // this.ajax
+      //   .get(this.$store.state.api + "selectTypeByOrg", params)
+      //   .then((res) => {
+      for (var i = 0; i < res.data[0].length; i++) {
+        for (var j = 0; j < res.data[1].length; j++) {
+          if (res.data[0][i].id == res.data[1][j].pid) {
+            if (!this.CourseTypeJson[res.data[0][i].id]) {
+              this.CourseTypeJson[res.data[0][i].id] = [];
             }
+            this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
           }
-          this.$forceUpdate();
-        })
-        .catch((err) => {
-          console.error(err);
-        });
+        }
+      }
+      this.$forceUpdate();
+      // })
+      // .catch((err) => {
+      //   console.error(err);
+      // });
     },
   },
   beforeDestroy() {
-    clearInterval(this.timer)
-    this.timer = null
+    clearInterval(this.timer);
+    this.timer = null;
   },
   created() {
     this.loading = this.openLoading(document.querySelector(".main_box"));
-    this.selectType();
+    // this.selectType();
     this.selectAll();
-    this.getBanner();
+    // this.getBanner();
     this.timer = setInterval(() => {
       this.selectAll();
-      this.getBanner();
+      // this.getBanner();
     }, 5000);
     document.scrollingElement.scrollTop = 0;
   },
@@ -577,8 +641,8 @@ export default {
   height: 16px;
 }
 
-.wheel>img,
-.man>img {
+.wheel > img,
+.man > img {
   width: 100%;
   height: 100%;
   object-fit: cover;
@@ -609,7 +673,7 @@ export default {
   align-items: center;
 }
 
-.people>div:nth-child(2) {
+.people > div:nth-child(2) {
   margin-left: 10px;
 }
 
@@ -643,7 +707,7 @@ export default {
   margin: auto 0;
 }
 
-.right_bottom_flex>img {
+.right_bottom_flex > img {
   width: 100%;
   height: 100%;
 }
@@ -699,17 +763,17 @@ export default {
   width: 100%;
 }
 
-.all_choose>span {
+.all_choose > span {
   min-width: 80px;
   display: block;
   letter-spacing: 14px;
 }
 
-.all_choose>span:nth-child(1) {
+.all_choose > span:nth-child(1) {
   font-weight: bold;
 }
 
-.all_choose>>>.el-checkbox-group {
+.all_choose >>> .el-checkbox-group {
   display: flex;
   flex-direction: row;
   width: 820px;
@@ -720,14 +784,14 @@ export default {
   margin-top: 3px;
 }
 
-.all_choose>.el-checkbox-group>>>.el-checkbox {
+.all_choose > .el-checkbox-group >>> .el-checkbox {
   margin-bottom: 10px;
   display: flex;
   flex-direction: row;
   align-items: center;
 }
 
-.all_choose>.el-checkbox-group>.el-checkbox>>>.el-checkbox__label {
+.all_choose > .el-checkbox-group > .el-checkbox >>> .el-checkbox__label {
   min-width: 80px;
   overflow: hidden;
   width: 80px;
@@ -735,7 +799,7 @@ export default {
   white-space: nowrap;
 }
 
-.all_choose>.el-checkbox-group>.el-checkbox>>>.el-checkbox__label:hover {
+.all_choose > .el-checkbox-group > .el-checkbox >>> .el-checkbox__label:hover {
   width: auto;
 }
 
@@ -772,7 +836,7 @@ export default {
   justify-content: space-between;
 }
 
-.reTop>div:nth-child(1) {
+.reTop > div:nth-child(1) {
   font-weight: bold;
   width: 40px;
   border-bottom: 1px solid #205cc6;
@@ -781,7 +845,7 @@ export default {
   font-size: 20px;
 }
 
-.reTop>div:nth-child(2) {
+.reTop > div:nth-child(2) {
   display: flex;
   flex-direction: row;
   align-items: center;
@@ -797,7 +861,7 @@ export default {
   padding: 0 5px;
 }
 
-.search>img {
+.search > img {
   width: 100%;
   height: 100%;
 }

+ 315 - 40
src/components/studyStudent.vue

@@ -55,8 +55,22 @@
                     :content="nav.taskName"
                     placement="top"
                   >
-                    <div>{{ nav.taskName }}</div>
+                    <div
+                      :style="{
+                        width:
+                          IsLookOpen && !nav.isLook
+                            ? 'calc(100% - 75px)'
+                            : 'auto',
+                      }"
+                    >
+                      {{ nav.taskName }}
+                    </div>
                   </el-tooltip>
+                  <img
+                    src="../assets/lock.png"
+                    v-if="IsLookOpen && !nav.isLook"
+                    alt=""
+                  />
                 </div>
               </div>
             </div>
@@ -1610,9 +1624,7 @@
                       <div>
                         <span>{{ index + 1 + "、" + item.askstitle }}</span>
                       </div>
-                      <div
-                        class="right_box_xuan"
-                      >
+                      <div class="right_box_xuan">
                         <span>正确率</span>
                         <span>{{
                           (checkJson[toolIndex][index].right
@@ -3570,15 +3582,25 @@
       class="dialog_diy"
     >
       <div>
-        <div>
-          <div>
+        <div class="open_box">
+          <div class="switch_box">
+            <span>学生是否能查看所有作业</span>
             <el-switch
               v-model="sIsOpen"
-              active-text="学生是否能查看所有作业"
+              active-text=""
               class="switchCss"
               @change="updateSLook"
             ></el-switch>
           </div>
+          <div class="switch_box" v-if="courseDetail.userid == userid">
+            <span>是否锁定阶段</span>
+            <el-switch
+              v-model="IsLookOpen"
+              active-text=""
+              class="switchCss"
+              @change="updateLookOpen"
+            ></el-switch>
+          </div>
         </div>
       </div>
       <div slot="footer">
@@ -4202,6 +4224,7 @@ export default {
       commentText: "",
       full: false,
       sIsOpen: false,
+      IsLookOpen: false,
       pzDialog: false,
       type: 1,
       vedio: [],
@@ -5047,7 +5070,9 @@ export default {
                       }
                     }
                     if (
-                      (JSON.parse(data.content)[0].askJson.askJson[z].answer || JSON.parse(data.content)[0].askJson.askJson[z].answer == 0)  &&
+                      (JSON.parse(data.content)[0].askJson.askJson[z].answer ||
+                        JSON.parse(data.content)[0].askJson.askJson[z].answer ==
+                          0) &&
                       JSON.parse(data.content)[0].askJson.askJson[z].answer ==
                         checkL[z]
                     ) {
@@ -5656,12 +5681,23 @@ export default {
       window.parent.postMessage({ allScreen: this.screenType }, "*");
     },
     nextOrpreSteps(t) {
-      document.scrollingElement.scrollTop = 0;
-      this.showType = 0;
       var b = this.chapInfoList.length - 1;
       if (t == 0) {
         if (this.courseType == 0) {
           if (this.taskCount == 0) {
+            // console.log(this.navList[b].task[this.navList[b].task.length - 1].isLook);
+            if (this.IsLookOpen) {
+              if (
+                !this.navList[b].task[this.navList[b].task.length - 1].isLook
+              ) {
+                if (this.courseDetail.userid != this.userid) {
+                  this.$message.error("任务未解锁");
+                } else {
+                  this.$message.error("上一任务未解锁");
+                }
+                return;
+              }
+            }
             this.navList[this.courseType].isOpen = false;
             this.courseType = b;
             this.taskCount =
@@ -5684,7 +5720,6 @@ export default {
           }
         }
       } else {
-        var b = this.chapInfoList.length - 1;
         if (this.courseType == b) {
           if (
             this.taskCount ==
@@ -5696,7 +5731,22 @@ export default {
             this.taskCount = 0;
             this.navList[this.courseType].isOpen = true;
           } else {
+            var bbb = this.taskCount + 1;
+            if (
+              !this.chapInfoList[this.courseType].chapterInfo[0].taskJson[bbb]
+                .isLook &&
+              this.courseDetail.userid != this.userid
+            ) {
+              this.$message.error("任务未解锁");
+              return;
+            }
             this.taskCount++;
+            if (this.IsLookOpen) {
+              this.chapInfoList[this.courseType].chapterInfo[0].taskJson[
+                this.taskCount
+              ].isLook = true;
+              this.addCourseState(3);
+            }
           }
         } else {
           if (
@@ -5704,14 +5754,38 @@ export default {
             this.chapInfoList[this.courseType].chapterInfo[0].taskJson.length -
               1
           ) {
+            var bbb = this.courseType + 1;
+            if (
+              !this.chapInfoList[bbb].chapterInfo[0].taskJson[0].isLook &&
+              this.courseDetail.userid != this.userid
+            ) {
+              this.$message.error("任务未解锁");
+              return;
+            }
             this.navList[this.courseType].isOpen = false;
             this.courseType++;
             this.taskCount = 0;
             this.navList[this.courseType].isOpen = true;
           } else {
+            var bbb = this.taskCount + 1;
+            if (
+              !this.chapInfoList[this.courseType].chapterInfo[0].taskJson[bbb]
+                .isLook &&
+              this.courseDetail.userid != this.userid
+            ) {
+              this.$message.error("任务未解锁");
+              return;
+            }
             this.taskCount++;
           }
+          if (this.IsLookOpen) {
+            this.chapInfoList[this.courseType].chapterInfo[0].taskJson[
+              this.taskCount
+            ].isLook = true;
+            this.addCourseState(3);
+          }
         }
+
         // if (
         //   this.taskCount ==
         //   this.chapInfo.chapterInfo[0].taskJson.length - 1
@@ -5721,6 +5795,8 @@ export default {
         //   this.taskCount++;
         // }
       }
+      document.scrollingElement.scrollTop = 0;
+      this.showType = 0;
       this.navId = this.navList[this.courseType].task[this.taskCount].id;
       // if (this.vedio[this.taskCount].length > 0) {
       //   var a =
@@ -5749,10 +5825,49 @@ export default {
       this.$forceUpdate();
     },
     openTask(s, n, i) {
-      document.scrollingElement.scrollTop = 0;
+      if (this.IsLookOpen) {
+        if (
+          !this.chapInfoList[s].chapterInfo[0].taskJson[n].isLook &&
+          this.courseDetail.userid != this.userid
+        ) {
+          this.$message.error("任务未解锁");
+          return;
+        }
+        if (this.courseType == s && this.taskCount != n && n > this.taskCount) {
+          if (
+            !this.chapInfoList[this.courseType].chapterInfo[0].taskJson[n - 1]
+              .isLook
+          ) {
+            this.$message.error("上一任务未解锁");
+            return;
+          }
+        } else if (s > this.courseType) {
+          if (n > 0) {
+            if (!this.chapInfoList[s].chapterInfo[0].taskJson[n - 1].isLook) {
+              this.$message.error("上一任务未解锁");
+              return;
+            }
+          } else {
+            if (
+              !this.chapInfoList[s - 1].chapterInfo[0].taskJson[
+                this.chapInfoList[s - 1].chapterInfo[0].taskJson.length - 1
+              ].isLook
+            ) {
+              this.$message.error("上一任务未解锁");
+              return;
+            }
+          }
+        }
+      }
       this.courseType = s;
       this.navId = i;
       this.taskCount = n;
+      if (this.IsLookOpen) {
+        this.chapInfoList[this.courseType].chapterInfo[0].taskJson[
+          this.taskCount
+        ].isLook = true;
+        this.addCourseState(3);
+      }
       this.showType = 0;
       this.isNoHomeWork = false;
       (this.studyJuri = [
@@ -5764,6 +5879,8 @@ export default {
         },
       ]),
         (this.radio = []);
+      document.scrollingElement.scrollTop = 0;
+
       // setTimeout(() => {
       //   let a = document.getElementById(i);
       //   if (a.offsetTop - 110 == 0) {
@@ -5900,27 +6017,27 @@ export default {
             this.courseType
           ];
           this.chapInfoList = JSON.parse(this.courseDetail.chapters);
-          if (this.navList.length == 0) {
-            this.navList = [];
-            for (var l = 0; l < this.chapInfoList.length; l++) {
-              var q = this.chapInfoList[l].dyName;
-              var w = this.chapInfoList[l].chapterInfo[0].taskJson;
-              var e;
-              this.navList.push({
-                dyName: q,
-                isOpen: l === 0 ? true : false,
-                task: [],
-              });
-              for (var r = 0; r < w.length; r++) {
-                e = w[r].task;
-                this.navList[l].task.push({ taskName: e, id: l + "-" + r });
-                this.navId = this.navId ? this.navId : l + "-" + r;
-              }
-            }
-          }
-          this.navList[0].isOpen = false;
-          this.navList[this.courseType].isOpen = true;
-          this.navId = this.navList[this.courseType].task[this.taskCount].id;
+          // if (this.navList.length == 0) {
+          //   this.navList = [];
+          //   for (var l = 0; l < this.chapInfoList.length; l++) {
+          //     var q = this.chapInfoList[l].dyName;
+          //     var w = this.chapInfoList[l].chapterInfo[0].taskJson;
+          //     var e;
+          //     this.navList.push({
+          //       dyName: q,
+          //       isOpen: l === 0 ? true : false,
+          //       task: [],
+          //     });
+          //     for (var r = 0; r < w.length; r++) {
+          //       e = w[r].task;
+          //       this.navList[l].task.push({ taskName: e, id: l + "-" + r });
+          //       this.navId = this.navId ? this.navId : l + "-" + r;
+          //     }
+          //   }
+          // }
+          // this.navList[0].isOpen = false;
+          // this.navList[this.courseType].isOpen = true;
+          // this.navId = this.navList[this.courseType].task[this.taskCount].id;
           for (var l = 0; l < this.chapInfoList.length; l++) {
             var w = this.chapInfoList[l].chapterInfo[0].taskJson;
             for (var m = 0; m < w.length; m++) {
@@ -6066,6 +6183,7 @@ export default {
           }, 500);
           this.selectStudent();
           this.selectSWorks();
+          this.selectSLook();
           let _this = this;
           if (_this.timer) {
             clearInterval(_this.timer);
@@ -6201,6 +6319,36 @@ export default {
           console.error(err);
         });
     },
+    updateLookOpen() {
+      let params = [
+        {
+          sopen: this.IsLookOpen == false ? 1 : 2,
+          cid: this.id,
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.api + "updateCourseLookOpen", params)
+        .then((res) => {
+          if (this.IsLookOpen == true) {
+            if (this.courseType != 0 && this.taskCount != 0) {
+              this.openTask(0, 0, "0-0");
+            }
+            this.$message({
+              message: "权限开放成功",
+              type: "success",
+            });
+          } else {
+            this.$message({
+              message: "权限关闭成功",
+              type: "success",
+            });
+          }
+          this.getCourseState(2);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     selectSLook() {
       let params = {
         cid: this.id,
@@ -6209,6 +6357,116 @@ export default {
         .get(this.$store.state.api + "selectCourseSLook", params)
         .then((res) => {
           this.sIsOpen = res.data[0][0].sopen == 1 ? false : true;
+          this.IsLookOpen = res.data[0][0].look == 1 ? false : true;
+          if (!this.IsLookOpen) {
+            this.setNavList();
+          } else {
+            this.getCourseState(1);
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
+    setNavList() {
+      if (this.navList.length == 0) {
+        this.navList = [];
+        for (var l = 0; l < this.chapInfoList.length; l++) {
+          var q = this.chapInfoList[l].dyName;
+          var w = this.chapInfoList[l].chapterInfo[0].taskJson;
+          var e;
+          this.navList.push({
+            dyName: q,
+            isOpen: l === 0 ? true : false,
+            task: [],
+          });
+          for (var r = 0; r < w.length; r++) {
+            e = w[r].task;
+            this.navList[l].task.push({
+              taskName: e,
+              id: l + "-" + r,
+              isLook: w[r].isLook,
+            });
+            // this.navId = this.navId ? this.navId : l + "-" + r;
+            // this.navId = l + "-" + r;
+          }
+        }
+        this.navList[0].isOpen = false;
+        this.navList[this.courseType].isOpen = true;
+        this.navId = this.navList[this.courseType].task[this.taskCount].id;
+      } else {
+        this.setNavList2();
+      }
+    },
+    setNavList2() {
+      for (var l = 0; l < this.chapInfoList.length; l++) {
+        var w = this.chapInfoList[l].chapterInfo[0].taskJson;
+        for (var r = 0; r < w.length; r++) {
+          this.navList[l].task[r].isLook = w[r].isLook;
+        }
+      }
+      if (
+        this.IsLookOpen &&
+        !this.navList[this.courseType].task[this.taskCount].isLook
+      ) {
+        this.openTask(0, 0, "0-0");
+      }
+      this.$forceUpdate();
+    },
+    getCourseState(type) {
+      let params = {
+        cid: this.id,
+      };
+      this.ajax
+        .get(this.$store.state.api + "getCourseState", params)
+        .then((res) => {
+          if (res.data[0].length > 0 && this.IsLookOpen && type == 1) {
+            this.chapInfoList = JSON.parse(res.data[0][0].state);
+            this.setNavList();
+            this.$forceUpdate();
+          } else if (res.data[0].length > 0 && this.IsLookOpen && type == 2) {
+            this.addCourseState(2);
+          } else {
+            this.addCourseState(1);
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
+    addCourseState(type) {
+      let _state = this.chapInfoList;
+      if (type == 1 || type == 2) {
+        for (var i = 0; i < _state.length; i++) {
+          let el = _state[i].chapterInfo[0].taskJson;
+          for (var j = 0; j < el.length; j++) {
+            if (i == 0 && j == 0) {
+              el[j].isLook = true;
+            } else {
+              el[j].isLook = false;
+            }
+          }
+        }
+      }
+      let params = [
+        {
+          cid: this.id,
+          state: JSON.stringify(_state).replaceAll(/%/g, "%25"),
+        },
+      ];
+      this.ajax
+        .post(
+          this.$store.state.api +
+            (type == 1 ? "addCourseState" : "updateCourseSate"),
+          params
+        )
+        .then((res) => {
+          if (this.IsLookOpen) {
+            this.setNavList();
+          }
+          if (type == 3 && type == 2) {
+            this.getCourseState(1);
+          }
         })
         .catch((err) => {
           console.error(err);
@@ -6386,7 +6644,7 @@ export default {
           stage: this.courseType,
           task: this.taskCount,
           tool: this.toolindex,
-          content: JSON.stringify(this.askList).replace(/%/g, "%25"),
+          content: JSON.stringify(this.askList).replaceAll(/%/g, "%25"),
           type: 2,
         },
       ];
@@ -6423,7 +6681,7 @@ export default {
           stage: this.courseType,
           task: this.taskCount,
           tool: this.toolindex,
-          content: JSON.stringify(this.askList).replace(/%/g, "%25"),
+          content: JSON.stringify(this.askList).replaceAll(/%/g, "%25"),
           type: 8,
         },
       ];
@@ -7082,7 +7340,6 @@ export default {
     this.getCourseDetail();
     this.selectCount();
     this.getHomeWork();
-    this.selectSLook();
     if (this.tType == 4) {
       this.pzDialog = true;
       this.selectPz();
@@ -7724,7 +7981,7 @@ export default {
   display: flex;
   flex-direction: row;
   align-items: center;
-  width: calc(100% - 350px);
+  width: calc(100% - 420px);
 }
 
 .courseIndex > div:nth-child(1) {
@@ -8209,8 +8466,15 @@ export default {
   width: 100%;
   cursor: pointer;
   margin-bottom: 10px;
+  position: relative;
+}
+.navChild img {
+  position: absolute;
+  right: 11px;
+  width: 15px;
+  top: 50%;
+  transform: translateY(-50%);
 }
-
 .navActive {
   height: auto;
 }
@@ -8883,12 +9147,12 @@ export default {
 }
 
 .switchCss {
-  width: 100%;
+  /* width: 100%; */
   display: flex;
   flex-direction: row;
   flex-wrap: nowrap;
   align-items: center;
-  justify-content: center;
+  /* justify-content: center; */
 }
 
 .isClickNav {
@@ -9655,4 +9919,15 @@ ol {
   color: #fff;
   cursor: pointer;
 }
+
+.open_box .switch_box {
+  width: 100%;
+  margin: 0 auto;
+  display: flex;
+  justify-content: space-between;
+}
+
+.open_box .switch_box + .switch_box {
+  margin-top: 10px;
+}
 </style>