Tang %!s(int64=2) %!d(string=hai) anos
pai
achega
777cf3b83a

+ 8 - 7
src/components/videoCy/index.vue

@@ -91,7 +91,8 @@ export default {
     //初始化参数
     initData() {
       this.commitTime = null;
-      (this.commitTimePhoto = null), (this.openPhotoStatus = 0);
+      this.commitTimePhoto = null;
+      this.openPhotoStatus = 0;
       clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
     },
     //获取播放记录
@@ -587,17 +588,15 @@ export default {
                   //停止执行-退出页面
                   this.$router.back(-1);
                 });
-            }
-            if (err.code === 559) {
+            } else if (err.code === 559) {
               console.log("拍照不够触发");
               this.$message.error(err.msg);
               this.openPhotoStatus = 1;
               setTimeout(() => {
                 this.openPhoto();
               }, 1500);
-            }
-            if (err.code === 558) {
-              this.$message.error(err.msg);
+            } else {
+              this.$message.error(err.msg || "未知错误");
             }
           });
       });
@@ -653,8 +652,10 @@ export default {
   beforeDestroy() {
     this.$bus.$off("toPlay");
     clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
-    this.player.HTML5.video.removeEventListener("timeupdate", this.timeEvent); //监听器
     document.removeEventListener("visibilitychange", this.pauseVideo);
+    this.player && this.player.destroy(); //初始化播放器
+    this.player &&
+      this.player.HTML5.video.removeEventListener("timeupdate", this.timeEvent); //监听器
     this.$msgbox.close();
   }
 };

+ 125 - 1
src/mixin/index.js

@@ -141,13 +141,137 @@ export default {
         doQuestionIds: doQuestionIds.join(","),
         rightQuestionIds: rightQuestionIds.join(","),
         rightQuestionNum: rightQuestionIds.length,
-        rightRate:(rightQuestionIds.length / totalQuestionNum).toFixed(2),
+        rightRate: (rightQuestionIds.length / totalQuestionNum).toFixed(2),
         historyExamJson: JSON.stringify(data),
         questionIds: doWrongQuestionIds,
         totalQuestionNum,
       };
     },
+    //优化题目结构
+    questionOptimizeFormat(data) {
+      let objs = JSON.parse(JSON.stringify(data))
+      objs.forEach((item, index) => {
+        if (typeof item.jsonStr == "string") {
+          item.jsonStr = JSON.parse(item.jsonStr);
 
+          if (item.type == 2) {
+            //多选
+            item.jsonStr.forEach(str => {
+              str.optionsId = "" + str.optionsId;
+            });
+            let arr = item.answerQuestion.split(",");
+            arr.forEach((a, i) => {
+              arr[i] = "" + a;
+            });
+            item.ans = arr;
+            item.quesSelect = [];
+            item.analysisContent &&
+              (item.analysisContent = item.analysisContent.replace(
+                /<img/gi,
+                '<img style="max-width:100%;"'
+              ));
+            item.content &&
+              (item.content = item.content.replace(
+                /<img/gi,
+                '<img style="max-width:100%;"'
+              ));
+            return;
+          } else if (item.type == 5) {
+            //简答题
+            item.ansText = {
+              text: "",
+              imageList: []
+            };
+            item.ques = {
+              text: "",
+              imageList: []
+            };
+            item.analysisContent &&
+              (item.analysisContent = item.analysisContent.replace(
+                /<img/gi,
+                '<img style="max-width:100%;"'
+              ));
+            item.content &&
+              (item.content = item.content.replace(
+                /<img/gi,
+                '<img style="max-width:100%;"'
+              ));
+
+            return;
+          } else if (item.type == 4) {
+            //案例题
+            item.ques = [];
+            item.tabIndex = "0";
+            let ansArr = [];
+            item.jsonStr.forEach((json, index) => {
+              if (json.type == 1) {
+                ansArr[index] = json.answerQuestion;
+                json.content &&
+                  (json.content = json.content.replace(
+                    /<img/gi,
+                    '<img style="max-width:100%;"'
+                  ));
+              } else if (json.type == 2) {
+                json.optionsList.forEach(str => {
+                  str.optionsId = "" + str.optionsId;
+                });
+                let arr = json.answerQuestion.split(",");
+                arr.forEach((a, i) => {
+                  arr[i] = "" + a;
+                });
+                ansArr[index] = arr;
+                json.content &&
+                  (json.content = json.content.replace(
+                    /<img/gi,
+                    '<img style="max-width:100%;"'
+                  ));
+              } else if (json.type == 3) {
+                ansArr[index] = json.answerQuestion;
+                json.content &&
+                  (json.content = json.content.replace(
+                    /<img/gi,
+                    '<img style="max-width:100%;"'
+                  ));
+              } else if (json.type == 5) {
+                ansArr[index] = {
+                  text: "",
+                  imageList: []
+                };
+                json.ansText = {
+                  text: "",
+                  imageList: []
+                };
+                json.ques = {
+                  text: "",
+                  imageList: []
+                };
+                json.content &&
+                  (json.content = json.content.replace(
+                    /<img/gi,
+                    '<img style="max-width:100%;"'
+                  ));
+              }
+            });
+
+            item.ans = ansArr;
+            return;
+          }
+          item.analysisContent &&
+            (item.analysisContent = item.analysisContent.replace(
+              /<img/gi,
+              '<img style="max-width:100%;"'
+            ));
+          item.content &&
+            (item.content = item.content.replace(
+              /<img/gi,
+              '<img style="max-width:100%;"'
+            ));
+          item.ques = "";
+          item.ans = item.answerQuestion;
+        }
+      });
+      return objs
+    },
 
     go(path) {
       this.$router.push({

+ 50 - 35
src/pages/course-detail/components/CourseTree.vue

@@ -271,6 +271,7 @@ export default {
       courseList: [], //商品的课程列表
       courseDataList: [], //课程内容
       allSectionList: [], //商品下所有节和试卷
+      repeatShowTips: true, //是否显示跳转提示
       nowTime: 0 //当前时间
     };
   },
@@ -372,17 +373,18 @@ export default {
     },
     BackExamStatus: function() {
       return function(item) {
+        console.log(item, "item");
         if (item.rebuild > 0) {
           return {
             name: "待重测",
             style: "danger"
           };
-        } else if (item.learing == 1) {
+        } else if (item.learning == 1) {
           return {
             name: "合格",
             style: "success"
           };
-        } else if (item.learing == 0) {
+        } else if (item.learning == 0) {
           return {
             name: "不及格(需重考)",
             style: "danger"
@@ -464,6 +466,22 @@ export default {
     });
   },
   methods: {
+    // 新增用户视频学习日志
+    studyLog(item, studyItem) {
+      this.$axios({
+        url: "/user/study/log",
+        method: "post",
+        data: {
+          goodsId: this.goodsData.goodsId,
+          orderGoodsId: this.goodsData.orderGoodsId,
+          courseId: this.courseList[0].courseId,
+          fromPlat: 2, //来源平台 1小程序 2PC网站
+          goodsType: this.goodsData.goodsType // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
+        }
+      }).then(res => {
+        console.log("直播的用户学习日志:", res);
+      });
+    },
     //是否显示直播时间范围
     liveShowTimeData(item) {
       if (item.type == 3 && item.sectionType == 2) {
@@ -484,6 +502,7 @@ export default {
       await this.getGoodsCourseList(); //获取商品课程列表
       await this.getCourseData(this.courseList[0].courseId); //获取课程内容
       await this.getAllSectionList(); //获取所有节列表
+      this.studyLog(); // 新增用户视频学习日志
       /**播放逻辑 */
       if (!(this.rebuild > 0)) {
         this.playBackLogic();
@@ -697,7 +716,8 @@ export default {
                   sectionId: i.sectionId,
                   sectionType: i.sectionType,
                   recordingUrl: i.recordingUrl,
-                  studyStatus: i.studyStatus
+                  studyStatus: i.studyStatus,
+                  learning: i.studyStatus
                 };
               } else {
                 return Object.assign(i, {
@@ -838,48 +858,41 @@ export default {
         })
         .catch(() => {});
     },
-    //跳转试卷
-    async doExam(section, type) {
-      // 试卷学习次数
-      let num =
-        this.businessData.goodsLearningOrder != 2 || section.rebuild
-          ? await this.bankRecordDoNum(section)
-          : section.doNum;
-      if (
-        (section.answerNum - num > 0 && section.answerNum > 0) ||
-        section.answerNum == 0
-      ) {
+    //判断跳转试卷
+    async doExam(item, type) {
+      if (this.repeatShowTips) {
         this.$confirm("是否跳转做题页面?", "提示", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           type: "warning"
         })
           .then(() => {
-            this.$router.push({
-              path: "/course-exam/" + this.goodsData.goodsId,
-              query: {
-                gradeId: this.goodsData.gradeId,
-                courseId: this.courseList[0].courseId,
-                moduleId: section.moduleId || 0,
-                chapterId: section.chapterId || 0,
-                sectionId: section.sectionId || 0,
-                examId: section.typeId,
-                learning: section.learning,
-                type: type || section.examType,
-                nextStatus: "next", //是否继续播放课程
-                orderGoodsId: this.goodsData.orderGoodsId
-              }
-            });
+            this.jumpExam(item, type);
           })
           .catch(() => {});
       } else {
-        this.$message({
-          type: "warning",
-          message: "该试卷只能答题" + section.answerNum + "次"
-        });
-        return;
+        this.repeatShowTips = true;
+        this.jumpExam(item, type);
       }
     },
+    //跳转试卷页面
+    jumpExam(item, type) {
+      this.$router.push({
+        path: "/course-exam/" + this.goodsData.goodsId,
+        query: {
+          orderGoodsId: this.goodsData.orderGoodsId,
+          gradeId: this.goodsData.gradeId,
+          courseId: this.courseList[0].courseId,
+          moduleId: item.moduleId || 0,
+          chapterId: item.chapterId || 0,
+          sectionId: item.sectionId || 0,
+          examId: item.typeId,
+          learning: item.learning,
+          type: type || item.examType,
+          nextStatus: "next" //是否继续播放课程
+        }
+      });
+    },
     //查看直播状态
     studyRecordGetChannelBasicInfo(channelId) {
       return new Promise(resolve => {
@@ -1058,7 +1071,8 @@ export default {
       }
     },
     //已学完,重新定位
-    BackVideoFunc() {
+    async BackVideoFunc() {
+      await this.getAllSectionList(); //获取所有节列表
       this.unfoldFunc(this.activeSection, true, true);
       if (this.businessData.goodsLearningOrder == 2) {
         var ary = this.allSectionList.find(i => i.studyStatus != 1);
@@ -1085,6 +1099,7 @@ export default {
             }
           )
             .then(() => {
+              this.repeatShowTips = false; //是否显示跳转提示
               this.openMenu(ary);
               this.unfoldFunc(ary, true);
             })

+ 0 - 267
src/pages/course-detail/components/HandOut copy.vue

@@ -1,267 +0,0 @@
-<template>
-  <div class="lecture-notesjy">
-    <div class="header">
-      <div class="header__name">{{ showId != null ? activeItem.urlName : courseHandoutsData.handoutsName }}</div>
-      <el-button
-        class="header__btn"
-        size="mini"
-        v-if="showId"
-        @click="showId = null"
-        >收起当前PDF</el-button
-      >
-    </div>
-    <ul
-      class="center"
-      v-if="
-        courseHandoutsData.fileList &&
-        courseHandoutsData.fileList.length > 0 &&
-        showId == null
-      "
-    >
-      <li
-        class="centerLi"
-        v-for="(item, index) in courseHandoutsData.fileList"
-        :key="index"
-      >
-        <div class="centerLibox">
-          <div class="centerLiboxName">{{ item.urlName }}</div>
-          <div class="centerLiboxBtnBox">
-            <el-button
-              v-if="showId !== item.fileId"
-              type="text"
-              @click="loadSeePdf(item)"
-              >预览</el-button
-            >
-            <el-button
-              type="text"
-              v-if="courseHandoutsData.canDownload == 1 ? true : false"
-              @click="printView($tools.splitImgHost(item.url))"
-              >打印</el-button
-            >
-            <el-button
-              type="text"
-              v-if="courseHandoutsData.canDownload == 1 ? true : false"
-              @click="download($tools.splitImgHost(item.url), item.urlName)"
-              >下载</el-button
-            >
-          </div>
-        </div>
-      </li>
-    </ul>
-    <div
-      class="pdf_box"
-      v-else-if="showId != null"
-      v-infinite-scroll="loadscroll"
-      :infinite-scroll-delay="200"
-      :infinite-scroll-distance="50"
-    >
-      <pdf
-        class="iframe"
-        :src="$tools.splitImgHost(activeItem.url)"
-        v-for="i in pdfCounts"
-        :key="i"
-        :page="i"
-        ref="pdf"
-      ></pdf>
-      <iframe
-        id="printIframe"
-        :src="$tools.splitImgHost(activeItem.url)"
-        frameborder="0"
-        style="display: none"
-      ></iframe>
-    </div>
-    <p class="no_center" v-else>暂无讲义列表</p>
-  </div>
-</template>
-
-<script>
-import pdf from "vue-pdf";
-import Print from "print-js";
-export default {
-  components: { pdf },
-  props: {
-    goodsData: {
-      type: Object,
-      default: () => {
-        return {};
-      },
-    },
-  },
-  data() {
-    return {
-      courseHandoutsData: {},
-      showId: null, //当前显示pdfID号
-      activeItem: {},
-      pdfCounts: 0,
-    };
-  },
-  watch: {
-    goodsData: {
-      handler(newVal, oldVal) {
-        if (newVal.handoutsId != oldVal.handoutsId) {
-          this.courseHandouts();
-        }
-      },
-      deep: true,
-    },
-  },
-  methods: {
-    /**
-     * 打印
-     */
-    printView(url) {
-      console.log("触发打印", url);
-      Print({
-        printable: url,
-        type: "pdf",
-        header: null,
-        targetStyles: ["*"],
-        style: "@page {margin:0 10mm}",
-      });
-    },
-    //下载
-    download(url, fileName) {
-      let xhr = new XMLHttpRequest();
-      xhr.open("get", url, true);
-      xhr.setRequestHeader("Content-Type", `application/pdf`);
-      xhr.responseType = "blob";
-      let that = this;
-      xhr.onload = function () {
-        if (this.status == 200) {
-          //接受二进制文件流
-          var blob = this.response;
-          that.downloadExportFile(blob, fileName);
-        }
-      };
-      xhr.send();
-    },
-
-    downloadExportFile(blob, tagFileName) {
-      let downloadElement = document.createElement("a");
-      let href = "";
-      if (typeof blob == "string") {
-        downloadElement.target = "_blank";
-      } else {
-        href = window.URL.createObjectURL(blob); //创建下载的链接
-      }
-      downloadElement.href = href;
-      downloadElement.download = tagFileName;
-      //下载后文件名
-      document.body.appendChild(downloadElement);
-      downloadElement.click(); //点击下载
-      document.body.removeChild(downloadElement); //下载完成移除元素
-      if (typeof blob != "string") {
-        window.URL.revokeObjectURL(href); //释放掉blob对象
-      }
-    },
-    /**
-     * 获取讲义权限
-     */
-    courseHandouts() {
-      if (this.goodsData.handoutsId) {
-        this.$request
-          .courseHandoutsdetail({handoutsId:this.goodsData.handoutsId})
-          .then((res) => {
-            this.courseHandoutsData = res.data || {};
-            if (res.data.fileList && res.data.fileList.length > 0) {
-              this.loadSeePdf(res.data.fileList[0]);
-            }
-          })
-          .catch((err) => {});
-      }
-    },
-
-    loadscroll() {
-      if (!this.pdfCounts && this.activeItem.pdf) {
-        if (this.activeItem.pdf >= 4) {
-          this.pdfCounts = 4;
-        } else {
-          this.pdfCounts = this.activeItem.pdf;
-        }
-      }
-      if (this.pdfCounts < this.activeItem.pdf) {
-        this.pdfCounts++;
-      } else {
-        return;
-      }
-    },
-    //点击预览加载
-    loadSeePdf(item) {
-      if (item.pdf) {
-        this.showId = item.fileId;
-        this.activeItem = item;
-        if (item.pdf >= 4) {
-          this.pdfCounts = 4;
-        } else {
-          this.pdfCounts = item.pdf;
-        }
-        this.$emit("backSwitchPdfData", item);
-        return;
-      }
-      const loadingTask = pdf.createLoadingTask(
-        this.$tools.splitImgHost(item.url)
-      );
-      loadingTask.promise
-        .then((pdf) => {
-          item.pdf = pdf.numPages;
-          this.showId = item.fileId;
-          this.activeItem = item;
-          if (item.pdf >= 4) {
-            this.pdfCounts = 4;
-          } else {
-            this.pdfCounts = item.pdf;
-          }
-          this.$emit("backSwitchPdfData", item);
-        })
-        .catch((err) => {});
-    },
-  },
-};
-</script>
-
-<style lang="scss" scoped>
-.lecture-notesjy {
-  max-height: 416px;
-  .header {
-    display: flex;
-    align-items: center;
-    border-bottom: 1px solid #fff;
-    &__name {
-      flex: 1;
-      color: #fff;
-      padding: 10px;
-    }
-    &__btn {
-      flex-shrink: 0;
-      margin: 0px 10px;
-    }
-  }
-  .no_center {
-    text-align: center;
-    color: #fff;
-    padding: 10px;
-  }
-  .center {
-    flex: 1;
-    overflow: auto;
-    .centerLi {
-      padding: 4px 10px;
-      & > .centerLibox {
-        display: flex;
-        align-items: center;
-        color: #fff;
-        & > .centerLiboxName {
-          flex: 1;
-        }
-        & > .centerLiboxBtnBox {
-          flex-shrink: 0;
-        }
-      }
-    }
-  }
-  .pdf_box {
-    flex: 1;
-    overflow: auto;
-  }
-}
-</style>

+ 1 - 1
src/pages/course-detail/index.vue

@@ -66,7 +66,6 @@ export default {
       await this.getGoodsData(); //获取商品详情
       await this.courseBusiness(); //获取培训项目详情
     },
-
     //获取培训项目详情
     courseBusiness() {
       return new Promise(resolve => {
@@ -82,6 +81,7 @@ export default {
         this.$request.goodsDetail(this.routerData.goodsId).then(res => {
           res.data.orderGoodsId = this.routerData.orderGoodsId;
           this.goodsData = res.data;
+          this.goodsData.gradeId = this.routerData.gradeId;
           //播放设置
           if (this.goodsData.goodsPlayConfig) {
             var goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);

+ 87 - 446
src/pages/course-exam/index.vue

@@ -5,13 +5,13 @@
       <div class="container">
         <div class="section__header">
           <!-- <el-breadcrumb separator="/">
-            <el-breadcrumb-item
-              v-for="(item, index) in $route.matched"
-              :key="index"
-              :to="{ path: item.path }"
-              >{{ item.name }}</el-breadcrumb-item
-            >
-          </el-breadcrumb> -->
+              <el-breadcrumb-item
+                v-for="(item, index) in $route.matched"
+                :key="index"
+                :to="{ path: item.path }"
+                >{{ item.name }}</el-breadcrumb-item
+              >
+            </el-breadcrumb> -->
         </div>
         <div class="section__body">
           <div class="explain-record">
@@ -1265,6 +1265,9 @@ export default {
               self.needPhoto = true;
             }
           }
+          if (res.data.erJianErZao) {
+            self.needPhoto = true;
+          }
 
           resolve();
         });
@@ -1317,129 +1320,7 @@ export default {
           this.allTimes = this.examData.answerTime * 60;
           this.lastTime =
             this.examData.answerTime && this.examData.answerTime * 60;
-
-          data.forEach((item, index) => {
-            if (typeof item.jsonStr == "string") {
-              item.jsonStr = JSON.parse(item.jsonStr);
-
-              if (item.type == 2) {
-                //多选
-                item.jsonStr.forEach(str => {
-                  str.optionsId = "" + str.optionsId;
-                });
-                let arr = item.answerQuestion.split(",");
-                arr.forEach((a, i) => {
-                  arr[i] = "" + a;
-                });
-                item.ans = arr;
-                item.quesSelect = [];
-                item.analysisContent &&
-                  (item.analysisContent = item.analysisContent.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                item.content &&
-                  (item.content = item.content.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                return;
-              } else if (item.type == 5) {
-                //简答题
-                item.ansText = {
-                  text: "",
-                  imageList: []
-                };
-                item.ques = {
-                  text: "",
-                  imageList: []
-                };
-                item.analysisContent &&
-                  (item.analysisContent = item.analysisContent.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                item.content &&
-                  (item.content = item.content.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-
-                return;
-              } else if (item.type == 4) {
-                //案例题
-                item.ques = [];
-                item.tabIndex = "0";
-                let ansArr = [];
-                item.jsonStr.forEach((json, index) => {
-                  if (json.type == 1) {
-                    ansArr[index] = json.answerQuestion;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 2) {
-                    json.optionsList.forEach(str => {
-                      str.optionsId = "" + str.optionsId;
-                    });
-                    let arr = json.answerQuestion.split(",");
-                    arr.forEach((a, i) => {
-                      arr[i] = "" + a;
-                    });
-                    ansArr[index] = arr;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 3) {
-                    ansArr[index] = json.answerQuestion;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 5) {
-                    ansArr[index] = {
-                      text: "",
-                      imageList: []
-                    };
-                    json.ansText = {
-                      text: "",
-                      imageList: []
-                    };
-                    json.ques = {
-                      text: "",
-                      imageList: []
-                    };
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  }
-                });
-
-                item.ans = ansArr;
-                return;
-              }
-              item.analysisContent &&
-                (item.analysisContent = item.analysisContent.replace(
-                  /<img/gi,
-                  '<img style="max-width:100%;"'
-                ));
-              item.content &&
-                (item.content = item.content.replace(
-                  /<img/gi,
-                  '<img style="max-width:100%;"'
-                ));
-              item.ques = "";
-              item.ans = item.answerQuestion;
-            }
-          });
-
-          this.questionList = data;
+          this.questionList = this.questionOptimizeFormat(data);
           this.lastCount = this.questionList.length;
           this.getCollectInfo(this.current);
           await this.examRecord();
@@ -1721,6 +1602,7 @@ export default {
           showClose: false
         }
       ).then(() => {
+        this.mustBack = true;
         this.$router.go(-1);
       });
     },
@@ -1746,6 +1628,7 @@ export default {
           distinguishCancelAndClose: false,
           showClose: false
         }).then(() => {
+          this.mustBack = true;
           this.$router.go(-1);
         });
       }
@@ -1786,7 +1669,7 @@ export default {
           })
           .then(res => {
             this.recordId = res.data;
-            console.error(self.needPhoto , this.type , this.learning)
+            console.error(self.needPhoto, this.type, this.learning);
             //  节不需要拍照
             if (self.needPhoto && this.type != 2 && !this.learning) {
               this.openPhoto();
@@ -2377,144 +2260,6 @@ export default {
         return;
       }
       let form = this.calculateScore(this.questionList);
-      // let score = 0; //计算总分
-      // let reportStatus = 0;
-      // let number = 0; //做对的题目数量
-      // let doQuestionNum = 0; //做过的题目数量
-      // let allScore = 0; //总分
-      // let passScore = 0;
-      // let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      // let doQuestionIds = []; //做过的题目id
-      // let rightQuestionIds = []; //做对的题目id
-      // let lessQuestionNum = 0;
-      // this.questionList.forEach((item, index) => {
-      //   passScore = item.passScore;
-      //   if (item.type == 1) {
-      //     //正确
-      //     if (item.ques == item.ans) {
-      //       item.scoreResult = item.score;
-      //       score += item.score;
-      //       number++;
-      //       rightQuestionIds.push(item.questionId);
-      //     } else {
-      //       //错误
-      //       item.scoreResult = 0;
-      //       if (item.ques) {
-      //         doWrongQuestionIds.push(item.questionId);
-      //       }
-      //     }
-      //     allScore += item.score;
-      //     if (item.ques) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 2) {
-      //     let isRight =
-      //       item.ans &&
-      //       item.ans.every((quesItem, quesIndex) => {
-      //         if (item.ques) {
-      //           return item.ques[quesIndex] == item.ans[quesIndex];
-      //         } else {
-      //           return false;
-      //         }
-      //       });
-
-      //     if (isRight) {
-      //       score += item.score;
-      //       number++;
-      //       item.scoreResult = item.score;
-      //       rightQuestionIds.push(item.questionId);
-      //     } else {
-      //       let hasPart = false;
-      //       let checkboxScore = 1; //获取单题总分数
-      //       item.ques &&
-      //         item.ques.forEach((ques, quesIndex) => {
-      //           //选错一个全扣
-      //           if (item.ques) {
-      //             if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-      //               checkboxScore = 0;
-      //             }
-      //           } else {
-      //             checkboxScore = 0;
-      //           }
-      //         });
-
-      //       //没选错
-      //       if (checkboxScore) {
-      //         checkboxScore = 0;
-      //         item.ans.forEach((ans, quesIndex) => {
-      //           //漏选扣一部分,对n题给n X partScore 分
-      //           if (item.ques) {
-      //             if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-      //               checkboxScore += item.partScore;
-      //               hasPart = true;
-      //             }
-      //           } else {
-      //             checkboxScore = 0;
-      //           }
-      //         });
-      //       }
-
-      //       if (!hasPart) {
-      //         //0分
-      //         item.scoreResult = 0;
-      //         if (item.ques) {
-      //           doWrongQuestionIds.push(item.questionId);
-      //         }
-      //       } else {
-      //         //部分分
-      //         // number++;
-      //         lessQuestionNum++;
-      //         // doWrongQuestionIds.push(item.questionId);
-      //         item.scoreResult = checkboxScore;
-      //         score += checkboxScore;
-      //         // rightQuestionIds.push(item.questionId)
-      //       }
-      //     }
-      //     allScore += item.score;
-      //     if (item.ques && item.ques.length) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 3) {
-      //     if (item.ques == item.ans) {
-      //       item.scoreResult = item.score;
-      //       score += item.score;
-      //       number++;
-      //       rightQuestionIds.push(item.questionId);
-      //     } else {
-      //       item.scoreResult = 0;
-      //       if (item.ques) {
-      //         doWrongQuestionIds.push(item.questionId);
-      //       }
-      //     }
-      //     allScore += item.score;
-      //     if (item.ques) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 4) {
-      //     allScore += item.score;
-      //     if (item.ques && item.ques.length) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 5) {
-      //     allScore += item.score;
-      //     if (item.ques && (item.ques.imageList || item.ques.text)) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   }
-      // });
-
-      // //大于分及格
-      // if (score >= passScore) {
-      //   reportStatus = 1;
-      // } else {
-      //   reportStatus = 0;
-      // }
-
       clearInterval(this.timer);
       //交卷 /bank/record/edit
       this.$request
@@ -2607,7 +2352,7 @@ export default {
           moduleId: this.moduleId,
           type: this.type,
           examId: this.examId,
-          orderGoodsId: this.orderGoodsId,
+          orderGoodsId: this.orderGoodsId
         })
         .then(res => {
           this.learning = res.data;
@@ -2624,104 +2369,6 @@ export default {
       clearInterval(this.postTimer);
       clearInterval(this.timer);
       let form = this.calculateScore(this.questionList);
-      // let number = 0;
-      // let score = 0;
-      // let doQuestionNum = 0;
-      // let doQuestionIds = []; //做过的题目id
-      // let lessQuestionNum = 0;
-      // this.questionList.forEach((item, index) => {
-      //   if (item.type == 1) {
-      //     if (item.ques == item.ans) {
-      //       score += item.score;
-      //       number++;
-      //     }
-
-      //     if (item.ques) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 2) {
-      //     let isRight =
-      //       item.ans &&
-      //       item.ans.every((quesItem, quesIndex) => {
-      //         if (item.ques) {
-      //           return item.ques[quesIndex] == item.ans[quesIndex];
-      //         } else {
-      //           return false;
-      //         }
-      //       });
-
-      //     if (isRight) {
-      //       score += item.score;
-      //       number++;
-      //     } else {
-      //       let hasPart = false;
-      //       let checkboxScore = 1; //获取单题总分数
-      //       item.ques &&
-      //         item.ques.forEach((ques, quesIndex) => {
-      //           //选错一个全扣
-      //           if (item.ques) {
-      //             if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-      //               checkboxScore = 0;
-      //             }
-      //           } else {
-      //             checkboxScore = 0;
-      //           }
-      //         });
-      //       console.log(checkboxScore);
-
-      //       //没选错
-      //       if (checkboxScore) {
-      //         checkboxScore = 0;
-      //         item.ans.forEach((ans, quesIndex) => {
-      //           //漏选扣一部分,对n题给n X partScore 分
-      //           if (item.ques) {
-      //             if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-      //               checkboxScore += item.partScore;
-      //               hasPart = true;
-      //             }
-      //           } else {
-      //             checkboxScore = 0;
-      //           }
-      //         });
-      //       }
-
-      //       if (!hasPart) {
-      //         //0分
-      //       } else {
-      //         //部分分
-      //         // number++;
-      //         lessQuestionNum++;
-      //         score += checkboxScore;
-      //       }
-      //     }
-      //     if (item.ques && item.ques.length) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 3) {
-      //     if (item.ques == item.ans) {
-      //       score += item.score;
-      //       number++;
-      //     }
-
-      //     if (item.ques) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item == 4) {
-      //     if (item.ques.length) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   } else if (item.type == 5) {
-      //     if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-      //       doQuestionNum++;
-      //       doQuestionIds.push(item.questionId);
-      //     }
-      //   }
-      // });
-
       this.$request
         .bankRecordEdit({
           examId: this.examId,
@@ -2752,91 +2399,85 @@ export default {
     }
   },
   beforeRouteLeave(to, from, next) {
-    if (this.mustBack) {
+    if (this.mustBack || this.isSubmit) {
       next();
     } else {
-      if (this.isSubmit) {
-        //交卷
-        next();
-      } else {
-        next(false)
-        //离开
-        let ansCount = this.questionOverNum(true); //已答题数
-        this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
-        if (this.bankType == 1) {
-          //所有题目答完
-          if (this.lastCount == 0) {
-            // this.testOver = true;
-            this.$nextTick(() => {
-              this.$confirm("您还未交卷,确定结束做题吗?", "温馨提示", {
-                confirmButtonText: "结束做题",
+      next(false);
+      //离开
+      let ansCount = this.questionOverNum(true); //已答题数
+      this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
+      if (this.bankType == 1) {
+        //所有题目答完
+        if (this.lastCount == 0) {
+          // this.testOver = true;
+          this.$nextTick(() => {
+            this.$confirm("您还未交卷,确定结束做题吗?", "温馨提示", {
+              confirmButtonText: "结束做题",
+              cancelButtonText: "下次继续",
+              type: "warning"
+            })
+              .then(() => {
+                this.examSubmit();
+              })
+              .catch(() => {
+                this.examRecordEdit();
+                next();
+              });
+          });
+          //未答完
+        } else {
+          this.$nextTick(() => {
+            this.$confirm(
+              `您还有${this.lastCount}道题未作答, 现在继续作答,还是下次继续?`,
+              "温馨提示",
+              {
+                confirmButtonText: "继续作答",
                 cancelButtonText: "下次继续",
                 type: "warning"
+              }
+            )
+              .then(() => {
+                // confirmButton回调
               })
-                .then(() => {
-                  this.examSubmit();
-                })
-                .catch(() => {
-                  this.examRecordEdit();
-                  next();
-                });
-            });
-            //未答完
-          } else {
-            this.$nextTick(() => {
-              this.$confirm(
-                `您还有${this.lastCount}道题未作答, 现在继续作答,还是下次继续?`,
-                "温馨提示",
-                {
-                  confirmButtonText: "继续作答",
-                  cancelButtonText: "下次继续",
-                  type: "warning"
-                }
-              )
-                .then(() => {
-                  // confirmButton回调
-                })
-                .catch(() => {
-                  this.examRecordEdit();
-                  next();
-                });
-            });
-            // this.isLastCount = true;
-          }
-        } else if (this.bankType == 2) {
-          //所有题目答完
-          if (this.lastCount == 0) {
-            this.$nextTick(() => {
-              this.$confirm(`您已完成所有题目,快去交卷吧!`, "温馨提示", {
-                confirmButtonText: "立即交卷",
-                cancelButtonText: "暂不交卷",
+              .catch(() => {
+                this.examRecordEdit();
+                next();
+              });
+          });
+          // this.isLastCount = true;
+        }
+      } else if (this.bankType == 2) {
+        //所有题目答完
+        if (this.lastCount == 0) {
+          this.$nextTick(() => {
+            this.$confirm(`您已完成所有题目,快去交卷吧!`, "温馨提示", {
+              confirmButtonText: "立即交卷",
+              cancelButtonText: "暂不交卷",
+              type: "warning"
+            })
+              .then(() => {
+                // confirmButton回调
+                this.examSubmit();
+              })
+              .catch(() => {});
+          });
+          //未答完
+        } else {
+          this.$nextTick(() => {
+            this.$confirm(
+              `您当前正在测试,还剩${this.lastCount}道题未完成,离开视为交卷`,
+              "温馨提示",
+              {
+                confirmButtonText: "继续离开",
+                cancelButtonText: "暂不离开",
                 type: "warning"
+              }
+            )
+              .then(() => {
+                this.examSubmit();
               })
-                .then(() => {
-                  // confirmButton回调
-                  this.examSubmit();
-                  next();
-                })
-                .catch(() => {});
-            });
-            //未答完
-          } else {
-            this.$nextTick(() => {
-              this.$confirm(
-                `您当前正在测试,还剩${this.lastCount}道题未完成,离开视为交卷`,
-                "温馨提示",
-                {
-                  confirmButtonText: "继续离开",
-                  cancelButtonText: "暂不离开",
-                  type: "warning"
-                }
-              )
-                .then(() => {
-                  this.examSubmit();
-                })
-                .catch(() => {});
-            });
-          }
+              .catch(() => {});
+          });
         }
       }
     }

+ 0 - 130
src/pages/course-report/index.vue

@@ -22,10 +22,6 @@
             <span class="icon">X</span>
             测试未通过
           </div>
-          <!-- <div class="desc">
-            答题时长:12分钟
-            <span class="note">(限时60分钟)</span>
-          </div> -->
         </div>
         <div
           class="section__header section__header--success"
@@ -35,32 +31,10 @@
             <span class="icon">✔</span>
             测试通过
           </div>
-          <!-- <div class="desc">
-            答题时长:12分钟
-            <span class="note">(限时60分钟)</span>
-          </div> -->
         </div>
 
         <div class="section__body">
           <div class="section__body__content">
-            <!-- <div class="left-box">
-              <div class="left-box__in">
-                <div class="title">
-                  试卷得分
-                  <span class="note">(客观题)</span>
-                </div>
-                <div class="desc">78</div>
-                <div class="other">满分100</div>
-              </div>
-              <div class="left-box__in left-box__in--bottom">
-                <div class="title">
-                  试卷得分
-                  <span class="note">(客观题+主观题)</span>
-                </div>
-                <div class="desc">86</div>
-                <div class="other">满分120</div>
-              </div>
-            </div> -->
             <div class="right-box">
               <div class="right-box__in">
                 <div class="title">
@@ -98,7 +72,6 @@
           <el-button type="primary" class="btn" @click="backList()"
             >返回列表</el-button
           >
-          <!-- <el-button type="primary" class="btn">练习下一节</el-button> -->
           <el-button
             type="primary"
             class="btn"
@@ -210,12 +183,6 @@ export default {
     this.getcourList();
     this.bankReport();
   },
-  mounted() {
-    console.log("examResult:", this.examResult);
-    // if (JSON.stringify(this.examResult) == "{}") {
-    //   this.$router.back(-1);
-    // }
-  },
   methods: {
     studyRecordMenuAllList(item) {
       return new Promise(resolve => {
@@ -268,22 +235,6 @@ export default {
         console.log("直播的用户学习日志:", res);
       });
     },
-    bankRecordDoNum(item, studyItem) {
-      return new Promise(resolve => {
-        this.$request
-          .bankRecordDoNum({
-            goodsId: item.goodsId,
-            gradeId: item.gradeId,
-            chapterId: studyItem.chapterId,
-            courseId: studyItem.courseId,
-            moduleId: studyItem.moduleId,
-            examId: studyItem.examId
-          })
-          .then(res => {
-            resolve(res.data);
-          });
-      });
-    },
     async nextJump() {
       var item = this.reportdata;
       var studyItem = this.studyItem;
@@ -305,18 +256,8 @@ export default {
             liveEndTime: studyItem.liveEndTime
           }
         });
-        this.studyLog(item, studyItem);
       }
       if (studyItem.examId) {
-        //有次数限制
-        let num = await this.bankRecordDoNum(item, studyItem);
-        let examItem = await this.$request.getExamDetail(studyItem.examId);
-        // section.doNum
-        // record.status == 0 && record.historyExamJson 继续做题
-        if (
-          (examItem.data.answerNum - num > 0 && examItem.data.answerNum > 0) ||
-          examItem.data.answerNum == 0
-        ) {
           this.$router.replace({
             path: "/course-exam/" + item.goodsId,
             query: {
@@ -332,13 +273,6 @@ export default {
               nextStatus: "next" //是否继续播放课程
             }
           });
-        } else {
-          this.$message({
-            type: "warning",
-            message: "该试卷只能答题" + examItem.data.answerNum + "次"
-          });
-          return;
-        }
       }
       this.nextDialogStatus = false;
     },
@@ -392,21 +326,7 @@ export default {
      * 去做题
      */
     async doRepeat(reportdata) {
-      // /bank/record/doNum
-      let count = await this.bankRecordDoNum();
-      console.log("已做的次数", count);
-      let answerNum = await this.getExamDetail(this.reportdata.examId);
-      console.log("全部的次数", answerNum);
-      //超过答题次数
-      if (answerNum > 0 && count >= answerNum) {
-        this.$message({
-          type: "warning",
-          message: "该试卷只能答题" + answerNum + "次!"
-        });
-        return;
-      }
       // answerNum==0没有答题次数限制
-      if (answerNum == 0 || (answerNum - count > 0 && answerNum > 0)) {
         this.$router.replace({
           path: "/course-exam/" + this.reportdata.goodsId,
           query: {
@@ -420,56 +340,6 @@ export default {
             orderGoodsId: this.reportdata.orderGoodsId
           }
         });
-      }
-
-      // this.studyLog()
-    },
-    /**
-     * 获取试卷已做的次数
-     */
-    bankRecordDoNum() {
-      return new Promise(resolve => {
-        this.$request
-          .bankRecordDoNum({
-            goodsId: this.reportdata.goodsId,
-            gradeId: this.reportdata.gradeId,
-            chapterId: this.reportdata.chapterId || 0,
-            courseId: this.reportdata.courseId,
-            moduleId: this.reportdata.moduleId || 0,
-            examId: this.reportdata.examId
-          })
-          .then(res => {
-            resolve(res.data);
-          });
-      });
-    },
-    /**
-     * @param {Object} exam_id
-     * 获取试卷可以做的次数
-     */
-    getExamDetail(exam_id) {
-      return new Promise(resolve => {
-        this.$request.getExamDetail(exam_id).then(res => {
-          resolve(res.data.answerNum);
-        });
-      });
-    },
-    // 新增用户视频学习日志
-    studyLog() {
-      this.$axios({
-        url: "/user/study/log",
-        method: "post",
-        data: {
-          goodsId: this.reportdata.goodsId,
-          courseId: this.reportdata.courseId,
-          moduleId: this.reportdata.moduleId || 0,
-          chapterId: this.reportdata.chapterId || 0,
-          sectionId: this.reportdata.sectionId || 0,
-          fromPlat: 2, //来源平台 1小程序 2PC网站
-          goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
-          orderGoodsId: this.reportdata.orderGoodsId
-        }
-      }).then(res => {});
     },
     wrongExplain(reportdata) {
       this.$router.push({

+ 6 - 159
src/pages/person-center/my-course/index.vue

@@ -970,102 +970,6 @@ export default {
       return index === -1;
     },
 
-    studyRecordMenuAllList(item, courseItem) {
-      return new Promise(resolve => {
-        this.$request
-          .studyRecordMenuAllListWithExam({
-            courseId: courseItem.courseId,
-            gradeId: item.gradeId,
-            goodsId: item.goodsId,
-            orderGoodsId: item.orderGoodsId
-          })
-          .then(res => {
-            // res.data = res.data.filter(
-            //   e => e.sectionType != 2 && e.doType != 1
-            // );
-            resolve(res.data);
-          });
-      });
-    },
-    checkListDontStudy(list) {
-      if (list.length === 0) {
-        this.$message.warning("该课程无学习内容");
-        return false;
-      }
-      const index = list.findIndex(
-        i => i.studyStatus == -1 || i.studyStatus == 0
-      );
-      if (index != -1) {
-        return list[index];
-      } else {
-        return list[0];
-      }
-    },
-    async goToStudy(item, courseItem) {
-      this.$message.success("进入学习页");
-      console.log("进入学习页");
-      //获取当前课程所有节和试卷
-      let list = await this.studyRecordMenuAllList(item, courseItem);
-      //返回第一个没学习的节或试卷
-      let studyItem = this.checkListDontStudy(list);
-      if (studyItem.sectionId) {
-        Loading.service({
-          text: "资源加载中,请耐心等待",
-          background: "rgba(0, 0, 0, 0.7)"
-        });
-        //返回节
-        this.$router.push({
-          path: `/my-course-detail/${item.goodsId}`,
-          query: {
-            gradeId: item.gradeId,
-            orderGoodsId: item.orderGoodsId,
-            courseId: studyItem.courseId,
-            chapterId: studyItem.chapterId,
-            moduleId: studyItem.moduleId,
-            sectionId: studyItem.sectionId,
-            recordingUrl: studyItem.recordingUrl,
-            liveUrl: studyItem.liveUrl,
-            sectionType: studyItem.sectionType,
-            liveStartTime: studyItem.liveStartTime,
-            liveEndTime: studyItem.liveEndTime
-          }
-        });
-        this.studyLog(item, studyItem);
-      }
-      if (studyItem.examId) {
-        //有次数限制
-        let num = await this.bankRecordDoNum(item, studyItem);
-        let examItem = await this.$request.getExamDetail(studyItem.examId);
-        // section.doNum
-        // record.status == 0 && record.historyExamJson 继续做题
-        if (
-          (examItem.data.answerNum - num > 0 && examItem.data.answerNum > 0) ||
-          examItem.data.answerNum == 0
-        ) {
-          this.$router.push({
-            path: "/course-exam/" + item.goodsId,
-            query: {
-              courseId: studyItem.courseId,
-              gradeId: item.gradeId,
-              moduleId: studyItem.moduleId || 0,
-              sectionId: studyItem.sectionId || 0,
-              examId: studyItem.examId,
-              learning: studyItem.studyStatus,
-              type: studyItem.examType, //题卷类型 1章卷 2节卷 3模块卷,
-              chapterId: studyItem.chapterId || 0,
-              orderGoodsId: item.orderGoodsId,
-              nextStatus: "next" //是否继续播放课程
-            }
-          });
-        } else {
-          this.$message({
-            type: "warning",
-            message: "该试卷只能答题" + examItem.data.answerNum + "次"
-          });
-          return;
-        }
-      }
-    },
     // 新增用户视频学习日志
     studyLog(item, studyItem) {
       this.$axios({
@@ -1125,31 +1029,6 @@ export default {
         }
       });
     },
-    goodsTodayStudySectionNum(option) {
-      return new Promise(resolve => {
-        this.$request
-          .goodsTodayStudySectionNum({
-            goodsId: option.goodsId,
-            gradeId: option.gradeId
-          })
-          .then(res => {
-            resolve(res.data);
-          });
-      });
-    },
-    //检查用户是否学习过节
-    gradeCheckGoodsStudy(item) {
-      return new Promise(resolve => {
-        this.$request
-          .gradeCheckGoodsStudy({
-            goodsId: item.goodsId,
-            gradeId: item.gradeId
-          })
-          .then(res => {
-            resolve(res.data);
-          });
-      });
-    },
     async goCourseDetail(item) {
       //-----------------七大员是否允许学习
       try {
@@ -1211,44 +1090,12 @@ export default {
         })
         .catch(err => {
           this.$router.push({
-          path: `/my-course-detail/${item.goodsId}`,
-          query: {
-            gradeId: item.gradeId,
-            orderGoodsId: item.orderGoodsId,
-          }
-        });
-        return
-          //可以学习
-          this.$request
-            .courseCourseList({
-              goodsId: item.goodsId,
-              gradeId: item.gradeId
-            })
-            .then(async res => {
-              //学习次数是否上限---start
-              let learnNum = await this.goodsTodayStudySectionNum(item);
-              //检查用户是否学习过节
-              let hasLearn = await this.gradeCheckGoodsStudy(item);
-              if (item.sectionMaxNum > 0) {
-                if (learnNum >= item.sectionMaxNum && !hasLearn) {
-                  this.$message({
-                    type: "warning",
-                    message: `每天最多学习${item.sectionMaxNum}节`
-                  });
-                  return;
-                }
-              }
-              //学习次数是否上限---end
-              if (res.rows.length) {
-                console.log("可以学习");
-                this.goToStudy(item, res.rows[0]);
-              } else {
-                this.$message({
-                  type: "warning",
-                  message: "课程内暂无可以学习的科目"
-                });
-              }
-            });
+            path: `/my-course-detail/${item.goodsId}`,
+            query: {
+              gradeId: item.gradeId,
+              orderGoodsId: item.orderGoodsId
+            }
+          });
         });
     },