Tang пре 2 година
родитељ
комит
a861d6e8a4
2 измењених фајлова са 312 додато и 111 уклоњено
  1. 5 82
      src/components/videoCy/index.vue
  2. 307 29
      src/pages/course-detail/components/CourseTree.vue

+ 5 - 82
src/components/videoCy/index.vue

@@ -314,88 +314,6 @@ export default {
               } //PC端播放加密视频所需的授权凭证。
             });
             resolve();
-            return;
-            this.player.HTML5.video.addEventListener(
-              "timeupdate",
-              self.timeEvent
-            );
-            this.player.on("s2j_onPlayStart", () => {
-              //开始播放每5秒提交一次观看时间
-              this.hasStart = true;
-              clearInterval(this.postTimer);
-              this.postTimer = setInterval(() => {
-                this.postStudyRecord(0, this.playSectionId, 5);
-              }, 30000);
-              if (this.recordObj.videoCurrentTime) {
-                this.showRecordStatus = true;
-                setTimeout(() => {
-                  this.showRecordStatus = false;
-                }, 5000);
-              } else {
-                //新视频直接提交一条观看记录
-                // this.postStudyRecord(0);
-                this.showRecordStatus = false;
-              }
-            });
-
-            this.player.on("s2j_onVideoPause", () => {
-              clearInterval(this.postTimer);
-              if (
-                this.sectionItem.learning != 1 &&
-                this.goodsData.erJianErZao
-              ) {
-                console.log(123);
-                this.videoPause = setTimeout(() => {
-                  if (!this.takePhotoModal) {
-                    if (this.isFullScreen()) {
-                      this.exitFullscreen();
-                    }
-                    this.confirmStatus = true;
-                    this.$confirm("检测暂停时间过长,刷新当前页面", "提示", {
-                      confirmButtonText: "确定",
-                      cancelButtonText: "取消",
-                      showCancelButton: false,
-                      closeOnClickModal: false,
-                      closeOnPressEscape: false,
-                      showClose: false,
-                      type: "warning"
-                    })
-                      .then(() => {
-                        this.$router.go(0);
-                        this.confirmStatus = false;
-                      })
-                      .catch(() => {
-                        this.confirmStatus = false;
-                      });
-                  }
-                }, 300000);
-              }
-            });
-
-            this.player.on("s2j_onVideoPlay", () => {
-              if (this.postTimer) {
-                this.postTimer = setInterval(() => {
-                  this.postStudyRecord(0, this.playSectionId, 5);
-                }, 30000);
-              }
-              if (this.sectionItem.learning != 1 && this.videoPause) {
-                clearTimeout(this.videoPause);
-              }
-            });
-
-            this.player.on("s2j_onPlayOver", () => {
-              this.hasStart = false;
-              clearInterval(this.postTimer);
-              this.$message({
-                type: "success",
-                message: "播放完毕"
-              });
-
-              if (this.isFullScreen()) {
-                this.exitFullscreen();
-              }
-              this.postStudyRecord(1);
-            });
           });
       });
     },
@@ -657,6 +575,11 @@ export default {
           });
       });
     }
+  },
+  beforeDestroy() {
+    if (this.player) {
+      this.player.destroy();
+    }
   }
 };
 </script>

+ 307 - 29
src/pages/course-detail/components/CourseTree.vue

@@ -12,6 +12,7 @@
             <el-tag
               size="mini"
               effect="dark"
+              :type="getTypeStyle(item1)"
               v-if="item1.type == 3 || item1.type == -1"
               >{{ changeName(item1) }}</el-tag
             >
@@ -33,14 +34,51 @@
               <div class="during">
                 {{ $tools.secondToDate(item1.durationTime) }}
               </div>
+              <template v-if="backSTATUS(item1)['name']">
+                <el-tag
+                  size="mini"
+                  effect="dark"
+                  :type="backSTATUS(item1)['style']"
+                  >{{ backSTATUS(item1)["name"] }}</el-tag
+                >
+              </template>
               <el-tag
                 size="mini"
                 effect="dark"
                 v-if="item1.examList.length > 0"
-                @click="doExam(item1.examList[0], 2)"
+                @click.stop="doExam(item1.examList[0], 2)"
                 >习题</el-tag
               >
             </template>
+            <template v-else-if="item1.type == -1">
+              <el-tag
+                v-if="item1.learning == 1"
+                size="mini"
+                effect="light"
+                type="success"
+                >合格</el-tag
+              >
+              <el-tag
+                v-else-if="item1.learning == 0"
+                size="mini"
+                effect="light"
+                type="danger"
+                >不及格(需重考)</el-tag
+              ><el-tag
+                v-if="item1.rebuild > 0"
+                size="mini"
+                effect="light"
+                type="warning"
+                >待重测</el-tag
+              >
+            </template>
+            <el-tag
+              v-else
+              size="mini"
+              effect="light"
+              :type="getStudyStatus(item1)['style']"
+              >{{ getStudyStatus(item1)["name"] }}</el-tag
+            >
           </div>
         </div>
         <ul
@@ -56,6 +94,7 @@
                 <el-tag
                   size="mini"
                   effect="dark"
+                  :type="getTypeStyle(item2)"
                   v-if="item2.type == 3 || item2.type == -1"
                   >{{ changeName(item2) }}</el-tag
                 >
@@ -67,12 +106,60 @@
                 {{ item2.name }}
               </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">
+                    {{ $tools.secondToDate(item2.durationTime) }}
+                  </div>
+                  <template v-if="backSTATUS(item2)['name']">
+                    <el-tag
+                      size="mini"
+                      effect="dark"
+                      :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">
+                  <el-tag
+                    v-if="item2.learning == 1"
+                    size="mini"
+                    effect="light"
+                    type="success"
+                    >合格</el-tag
+                  >
+                  <el-tag
+                    v-else-if="item2.learning == 0"
+                    size="mini"
+                    effect="light"
+                    type="danger"
+                    >不及格(需重考)</el-tag
+                  ><el-tag
+                    v-if="item2.rebuild > 0"
+                    size="mini"
+                    effect="light"
+                    type="warning"
+                    >待重测</el-tag
+                  >
+                </template>
                 <el-tag
+                  v-else
                   size="mini"
-                  effect="dark"
-                  v-if="item2.type == 3 && item2.examList.length > 0"
-                  >习题</el-tag
+                  effect="light"
+                  :type="getStudyStatus(item2)['style']"
+                  >{{ getStudyStatus(item2)["name"] }}</el-tag
                 >
               </div>
             </div>
@@ -91,6 +178,7 @@
                     <el-tag
                       size="mini"
                       effect="dark"
+                      :type="getTypeStyle(item3)"
                       v-if="item3.type == 3 || item3.type == -1"
                       >{{ changeName(item3) }}</el-tag
                     >
@@ -102,13 +190,57 @@
                     {{ item3.name }}
                   </div>
                   <div class="right">
-                    20:30
-                    <el-tag
-                      size="mini"
-                      effect="dark"
-                      v-if="item3.type == 3 && item3.examList.length > 0"
-                      >习题</el-tag
-                    >
+                    <template v-if="item3.type == 3">
+                      <img
+                        v-if="isActive(item3)"
+                        src="@/assets/learing.gif"
+                        alt=""
+                        class="activeImg_style"
+                      />
+                      <div class="during">
+                        {{ $tools.secondToDate(item3.durationTime) }}
+                      </div>
+                      <template v-if="backSTATUS(item3)['name']">
+                        <el-tag
+                          size="mini"
+                          effect="dark"
+                          :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">
+                      <el-tag
+                        v-if="item3.learning == 1"
+                        size="mini"
+                        effect="light"
+                        type="success"
+                        >合格</el-tag
+                      >
+                      <el-tag
+                        v-else-if="item3.learning == 0"
+                        size="mini"
+                        effect="light"
+                        type="danger"
+                        >不及格(需重考)</el-tag
+                      ><el-tag
+                        v-if="item3.rebuild > 0"
+                        size="mini"
+                        effect="light"
+                        type="warning"
+                        >待重测</el-tag
+                      >
+                    </template>
+                    <el-tag v-else size="mini" effect="dark">{{
+                      getStudyStatus(item3)
+                    }}</el-tag>
                   </div>
                 </div>
               </li>
@@ -128,7 +260,8 @@ export default {
       courseList: [], //商品的课程列表
       courseDataList: [], //课程内容
       allSectionList: [], //商品下所有节和试卷
-      activeSection: {} //当前节数据
+      activeSection: {}, //当前节数据
+      nowTime: 0 //当前时间
     };
   },
   computed: {
@@ -172,6 +305,59 @@ export default {
         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.learning == 1) {
+            return {
+              name: "已学完",
+              style: "success"
+            };
+          } else if (item.rebuild > 0) {
+            return {
+              name: "待重修",
+              style: "warning"
+            };
+          }
+        }
+        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 {};
+      };
+    },
     isActive: function() {
       return function(item) {
         return (
@@ -181,10 +367,95 @@ export default {
           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
+            ) !== -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
+            ) !== -1
+          ) {
+            return {
+              name: "学习中",
+              style: "warning"
+            };
+          }
+        }
+
+        if (STATUSARRAY.every(i => i.studyStatus == 1)) {
+          if (STATUSARRAY.findIndex(i => i.rebuild == 1) !== -1) {
+            return {
+              name: "待重修",
+              style: "danger"
+            };
+          } else {
+            return {
+              name: "已学完",
+              style: "success"
+            };
+          }
+        } else if (STATUSARRAY.every(i => i.studyStatus == -1)) {
+          return {
+            name: "待学习",
+            style: ""
+          };
+        }
+
+        // const Array1 = this.allSectionList.filter(
+        //   i =>
+        //     (i.chapterId == item.chapterId || i.chapterId == item.menuId) &&
+        //     (i.moduleId == item.moduleId || i.moduleId == 0)
+        // );
+        // var str = "";
+        // console.log("chapter", this.sectionItem, item);
+        // if (Array1.every(i => i.studyStatus == 1)) {
+        //   item.studyStatus = 1;
+        //   str = style_type ? 1 : "已学完";
+        // } else {
+        //   item.studyStatus = -1;
+        //   str = style_type ? -1 : "待学习";
+        // }
+        // if (
+        //   (item.menuId == this.sectionItem.chapterId &&
+        //     0 == this.sectionItem.moduleId) ||
+        //   (item.chapterId == this.sectionItem.chapterId &&
+        //     item.moduleId == this.sectionItem.moduleId)
+        // ) {
+        //   item.studyStatus = 0;
+        //   str = style_type ? 0 : "学习中";
+        // }
+        // return str;
+      };
     }
   },
   created() {
     this.init();
+    this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
   },
   methods: {
     async init() {
@@ -245,6 +516,7 @@ export default {
                 recordingUrl: i.type == 3 ? i.recordingUrl : null,
                 showStatus: false, //展开状态
                 children: null, //子列表
+                learning: i.type == 3 ? i.learning : null,
                 examList:
                   i.type == 3
                     ? examRes.data.filter(item => item.sectionId == i.menuId)
@@ -333,7 +605,6 @@ export default {
                 item,
                 "children",
                 res.data.map(i => {
-                  console.log(i);
                   if (i.id) {
                     return {
                       level: item.level + 1,
@@ -346,6 +617,8 @@ export default {
                       sectionType: i.sectionType,
                       durationTime: i.durationTime,
                       recordingUrl: i.recordingUrl,
+                      learning: i.learning,
+                      rebuild: i.rebuild,
                       showStatus: false, //展开状态
                       children: null, //子列表
                       examList:
@@ -407,16 +680,20 @@ export default {
       } else if (item.type == 2) {
         await this.openChapter(item); //展开章
       } else {
-        await this.waitCheckStatus(item); //检查是否可以继续执行
-        if (item.type == 3) {
-          if (item.sectionType == 1) {
-            this.watchSection(item);
-          } else {
-            this.watchJumpSection(item);
+        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);
+          if (item.type == -1) {
+            this.doExam(item);
+          }
+        } catch (error) {
+          console.log(error, "error");
         }
       }
     },
@@ -433,11 +710,11 @@ export default {
             type: "warning",
             message: `暂无播放地址数据`
           });
-          reject();
+          return reject();
         }
         if (item.type == -1 && item.doType != 1 && item.learning == 1) {
           this.$message.warning("考试已通过,请勿重复考试");
-          reject();
+          return reject();
         }
         if (!this.orderTopTobottom(item)) {
           this.$message({
@@ -447,11 +724,11 @@ export default {
                 ? "请学完视频课程再进行练习和测试"
                 : "请按顺序学习视频课程"
           });
-          reject();
+          return reject();
         }
         // 检查学习次数
         if (!(await this.exceedLearnNum(item))) {
-          reject();
+          return reject();
         }
         resolve();
       });
@@ -462,7 +739,6 @@ export default {
       this.$bus.$emit("toPlay", item);
       this.activeSection = item;
     },
-    toPlay(item) {},
     //回放或直播
     async watchJumpSection(item) {
       if (item.sectionType == 2) {
@@ -483,8 +759,9 @@ export default {
           return;
         }
       }
-      this.toPlay(item);
+      this.toPlaySection(item);
     },
+    toPlaySection(item) {},
     //跳转试卷
     async doExam(section, type) {
       // 试卷学习次数
@@ -764,6 +1041,7 @@ export default {
   }
   & > .right {
     & > .during {
+      margin-right: 4px;
     }
     display: flex;
     align-items: center;