Forráskód Böngészése

Merge branch 'xqy_h5' into dev

谢杰标 2 éve
szülő
commit
950ac8e984

+ 9 - 0
common/httpList/login.js

@@ -153,6 +153,15 @@ export default {
       noToken: true,
     });
   },
+  // 三级等保是否需要验证码
+  getDualAuth(data) {
+    return myRequest({
+      url: "/app/common/dual_auth",
+      method: "get",
+      data: data,
+      noToken: true,
+    });
+  },
   //绑定身份证号信息
   bindId(data) {
     return myRequest({

+ 142 - 0
common/methodTool.js

@@ -500,4 +500,146 @@ export default {
     window.location.href = externalLink;
     // #endif
   },
+  calculateScore(data) {
+    let score = 0; //计算总分
+    let totalScore = 0; //总分
+    let doWrongQuestionIds = []; //做错题id(案例题简答不算在内)
+    let doQuestionIds = []; //做过的题目id
+    let lessQuestionNum = 0; //多选题少选
+    let rightQuestionIds = []; //做对的题目id
+    let totalQuestionNum = 0; //排除主观题的总条数(简单题)
+    data.forEach((item) => {
+      console.log("答案--", item.ans, "选择--", item.ques);
+
+      totalScore += item.score * (item.type == 4 ? item.jsonStr.length : 1);
+
+      if (
+        item.type < 4 ||
+        (item.type == 4 && !item.jsonStr.some((e) => e.type == 5))
+      ) {
+        totalQuestionNum++;
+      }
+
+      if (item.type == 1 || item.type == 3) {
+        //正确
+        if (item.ques == item.ans) {
+          item.scoreResult = item.score;
+          score += item.score;
+          rightQuestionIds.push(item.questionId);
+        } else {
+          //错误
+          item.scoreResult = 0;
+          if (item.ques) {
+            doWrongQuestionIds.push(item.questionId);
+          }
+        }
+        if (item.ques) {
+          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;
+          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 {
+            //部分分
+            lessQuestionNum++;
+            item.scoreResult = checkboxScore;
+            score += checkboxScore;
+          }
+        }
+        if (item.ques && item.ques.length) {
+          doQuestionIds.push(item.questionId);
+        }
+      } else if (item.type == 4) {
+        let len = item.ans.length;
+        let questionScore = 0;
+        if (item.ques && item.ques.length) {
+          item.ques.forEach((ele, idx) => {
+            if (
+              ele == item.ans[idx] ||
+              (item.jsonStr[idx].type == 2 &&
+                ele.toString() == item.ans[idx].toString())
+            ) {
+              len--;
+              questionScore += item.score;
+            }
+          });
+          score += questionScore;
+          item.scoreResult = questionScore;
+          len == 0 && rightQuestionIds.push(item.questionId);
+          doQuestionIds.push(item.questionId);
+        }
+      } else if (item.type == 5) {
+        if (item.ques && (item.ques.imageList.length || item.ques.text)) {
+          doQuestionIds.push(item.questionId);
+        }
+      }
+    });
+    return {
+      reportStatus: score >= (data[0].passScore || totalScore * 0.6) ? 1 : 0,
+      lessQuestionNum,
+      performance: score,
+      totalScore,
+      doQuestionNum: doQuestionIds.length,
+      doQuestionIds: doQuestionIds.join(","),
+      rightQuestionIds: rightQuestionIds.join(","),
+      rightQuestionNum: rightQuestionIds.length,
+      historyExamJson: JSON.stringify(data),
+      questionIds: doWrongQuestionIds,
+      totalQuestionNum,
+    };
+  },
+  checkDomain(str) {
+    let domain =
+      /^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|   (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))$/;
+    return domain.test(str);
+  },
 };

+ 6 - 4
common/request.js

@@ -1,5 +1,6 @@
 import store from "@/store/index.js";
 import config from "@/common/config";
+import method from "@/common/methodTool";
 var num = 1;
 //接口api
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
@@ -8,10 +9,7 @@ export const BASE_URL = config.BASE_URL;
 export let tenantId = config.tenantId; // 祥粤云学堂:867735392558919680,祥粤学堂:667735392758919630, 中建云学堂-567735392758918520
 // #endif
 // #ifdef H5
-export const host =
-  process.env.NODE_ENV === "production"
-    ? window.location.host
-    : "120.79.166.78:19012";
+export const host = setHost();
 export let tenantId = uni.getStorageSync(host) || "";
 // #endif
 export const myRequest = (options) => {
@@ -160,3 +158,7 @@ function getTenantId() {
     });
   });
 }
+function setHost() {
+  let host = window.location.host;
+  return method.checkDomain(host) ? host : "120.79.166.78:19012";
+}

+ 2 - 2
components/course/courseSection.vue

@@ -559,7 +559,7 @@ export default {
           // buyCourse 是否购买课程:1是 0否,type=vod是回放
           let encode = encodeURIComponent(
             this.config.hostLive +
-              "pages/live/index?token=" +
+              "/pages/live/index?token=" +
               uni.getStorageSync("token") +
               "&userInfo=" +
               JSON.stringify(this.userInfo) +
@@ -686,7 +686,7 @@ export default {
         // buyCourse 是否购买课程:1是 0否
         let encode = encodeURIComponent(
           this.config.hostLive +
-            "pages/live/index?token=" +
+            "/pages/live/index?token=" +
             uni.getStorageSync("token") +
             "&userInfo=" +
             JSON.stringify(this.userInfo) +

+ 32 - 448
pages2/bank/questionBank.vue

@@ -1069,6 +1069,8 @@ export default {
             this.bankType = res.data.data.doType;
           }
           this.examData = res.data.data;
+          this.allTimes = this.examData.answerTime * 60;
+          this.lastTime = this.examData.answerTime && this.examData.answerTime * 60;
           if (this.bankType == 2) {
             this.needBack = true;
           }
@@ -1205,191 +1207,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false);
       uni.navigateBack({
         delta: 1,
       });
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      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;
-                }
-              });
-            console.log(checkboxScore);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选只能得部分分数
-                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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      //交卷
-      this.$api
-        .examRecordEdit({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
-          examTime: parseInt(this.allTimes),
-          doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-            this.entryType == "daily" && this.dailyExam();
-          }
-        });
-
-      //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          orderGoodsId: this.orderGoodsId,
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          examId: this.id,
-          goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: this.doMode,
-        })
-        .then((res) => {});
     },
     /**
      * 立即交卷
@@ -1404,113 +1225,25 @@ export default {
      */
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        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 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;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (checkboxScore <= 0) {
-                //0分
-              } else {
-                //部分分
-                // number++;
-                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);
-            }
-          }
-        });
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             orderGoodsId: this.orderGoodsId,
             examId: this.id,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            doQuestionIds: doQuestionIds.join(","),
-            rightQuestionNum: number,
+            doQuestionIds,
+            rightQuestionNum,
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
             status: 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -1592,7 +1325,7 @@ export default {
           this.examData = res.data.data || {};
           this.id = this.examData.examId;
           if (!this.examData.questionList.length) {
-            return this.noListTip()
+            return this.noListTip();
           }
           this.dataAnlyze(this.examData.questionList || []);
         } else {
@@ -1629,7 +1362,7 @@ export default {
         from: 1,
       }).then((res) => {
         if (res.data.code == 500) {
-          return this.noListTip('你已完成所有题目')
+          return this.noListTip("你已完成所有题目");
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1637,10 +1370,8 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          return this.noListTip()
+          return this.noListTip();
         }
-        this.allTimes = data[0].answerTime * 60;
-        this.lastTime = data[0].answerTime && data[0].answerTime * 60;
         //考试时间到了自动交卷
         if (this.lastTime) {
           this.timer = setInterval(() => {
@@ -2107,179 +1838,34 @@ export default {
     /**
      * 交卷
      */
-    submit() {
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       //交卷
       this.$api
         .examRecordEdit({
-          // courseId: this.courseId,
           examId: this.id,
           goodsId: this.goodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
           orderGoodsId: this.orderGoodsId,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
+          status: 1, // 1是交卷 2是中途离开
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
-          // type: ''
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
             this.entryType == "daily" && this.dailyExam();
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 1000,
               icon: "none",
             });
-
             setTimeout(() => {
               uni.redirectTo({
                 url:
@@ -2308,17 +1894,15 @@ export default {
         });
 
       //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: this.doMode,
-        })
-        .then((res) => {});
+      this.$api.examWrongRecord({
+        examId: this.id,
+        goodsId: this.goodsId,
+        orderGoodsId: this.orderGoodsId,
+        questionIds: form.questionIds,
+        recordId: this.recordId,
+        type: 1, // 题库试卷传1
+        doMode: this.doMode,
+      });
     },
     // 每日一练试卷打卡
     dailyExam() {

+ 57 - 396
pages2/bank/questionBankContinue.vue

@@ -6,11 +6,7 @@
       :statusBar="true"
       :title="examData.examName"
     ></uni-nav-bar>
-    <swiper
-      class="swiper"
-      :current="current"
-      @change="swiperChange"
-    >
+    <swiper class="swiper" :current="current" @change="swiperChange">
       <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
         <view class="pageContent">
           <view class="pad_8 titBox">
@@ -217,12 +213,15 @@
                   :key="index"
                   class="lisSty"
                 >
-                <!-- right: index == bank.ques || index == bank.ans,
+                  <!-- right: index == bank.ques || index == bank.ans,
                       wrong: index == bank.ques && bank.ques != bank.ans, -->
                   <text
                     :class="{
-                      right: index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
-                      wrong: index == (bank.ques == 1 ? 0 : 1) && bank.ques != bank.ans,
+                      right:
+                        index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
+                      wrong:
+                        index == (bank.ques == 1 ? 0 : 1) &&
+                        bank.ques != bank.ans,
                     }"
                     class="activeTI"
                     >{{ ast[index] }}</text
@@ -564,7 +563,7 @@
                       :key="childindex"
                       class="lisSty"
                     >
-                    <!-- right:
+                      <!-- right:
                             childindex == bank.ques[ansIndex] ||
                             childindex == bank.ans[ansIndex],
                           wrong:
@@ -573,11 +572,13 @@
                       <text
                         :class="{
                           right:
-                            bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
-                            childindex != bank.ans[ansIndex]),
+                            bankType == 1 &&
+                            (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
+                              childindex != bank.ans[ansIndex]),
                           wrong:
-                            bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
-                            bank.ques[ansIndex] != bank.ans[ansIndex]),
+                            bankType == 1 &&
+                            childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
+                            bank.ques[ansIndex] != bank.ans[ansIndex],
                         }"
                         class="activeTI"
                         >{{ ast[childindex] }}</text
@@ -597,8 +598,16 @@
                 </view>
                 <view v-if="bank.ques[ansIndex]">
                   <view class="pad_8 answer">
-                    <view>题目答案:{{ ast[bank.ans[ansIndex] == 1 ? 0 : 1] }}</view>
-                    <view>我的答案:{{ ast[bank.ques[ansIndex] == 1 ? 0 : 1] || "" }}</view>
+                    <view
+                      >题目答案:{{
+                        ast[bank.ans[ansIndex] == 1 ? 0 : 1]
+                      }}</view
+                    >
+                    <view
+                      >我的答案:{{
+                        ast[bank.ques[ansIndex] == 1 ? 0 : 1] || ""
+                      }}</view
+                    >
                   </view>
                   <view class="pad_8 answerInfos">
                     <view class="answerTitle">答案解析</view>
@@ -1032,7 +1041,7 @@ export default {
         let json = JSON.parse(res.data.data.historyExamJson);
         this.examData = res.data.data;
         this.questionList = json;
-        this.getCollectInfo(this.current)
+        this.getCollectInfo(this.current);
       });
     },
 
@@ -1060,78 +1069,32 @@ export default {
      * @param {Object} e单选点击
      */
     radioSelect(optionsId, bindex) {
-      console.log('单选');
+      console.log("单选");
       if (this.questionList[bindex].ques) return;
       this.$set(this.questionList[bindex], "ques", optionsId);
       this.isDoOver();
     },
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        this.questionList.length &&
-          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.ques &&
-                item.ques.every((quesItem, quesIndex) => {
-                  return item.ques[quesIndex] == item.ans[quesIndex];
-                });
-
-              if (isRight) {
-                score += item.score;
-                number++;
-              }
-              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);
-              }
-            }
-          });
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
             examId: this.id,
-            doQuestionIds: doQuestionIds.join(""),
+            doQuestionIds,
             goodsId: this.goodsId,
             orderGoodsId: this.orderGoodsId,
             recordId: this.recordId,
-            rightQuestionNum: number,
+            rightQuestionNum,
             status: 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1172,162 +1135,30 @@ export default {
     /**
      * 提交数据
      */
-    submit() {
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let allScore = 0;
-      let passScore = 0;
-      let doQuestionNum = 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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            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++;
-            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;
-                }
-              });
-            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分
-              item.scoreResult = 0;
-              doWrongQuestionIds.push(item.questionId);
-            } else {
-              //部分分
-              // number++;
-              // doWrongQuestionIds.push(item.questionId)
-              lessQuestionNum++;
-              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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       this.$api
         .examRecordEdit({
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          totalScore: allScore,
           recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 2000,
               icon: "none",
             });
-
             setTimeout(() => {
               uni.redirectTo({
                 url:
@@ -1347,7 +1178,7 @@ export default {
         .examWrongRecord({
           examId: this.id,
           goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
           type: 1, // 题库试卷传1
@@ -1416,14 +1247,22 @@ export default {
 
     judgeSelect(index, bindex) {
       if (this.questionList[bindex].ques) return;
-      this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
-      console.log('this.questionList[bindex]', this.questionList[bindex].ques, this.questionList[bindex])
+      this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
+      console.log(
+        "this.questionList[bindex]",
+        this.questionList[bindex].ques,
+        this.questionList[bindex]
+      );
       this.isDoOver();
     },
 
     judgeSelectChild(ansindex, childindex, bindex) {
       if (this.questionList[bindex].ques[ansindex]) return;
-      this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
+      this.$set(
+        this.questionList[bindex].ques,
+        ansindex,
+        childindex == 0 ? "1" : "0"
+      );
       this.isDoOver();
     },
 
@@ -1433,188 +1272,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false)
       uni.navigateBack({
         delta: 1,
       });
-      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;
-                }
-              });
-            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分
-              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) {
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          if (item.ques && (item.ques.imageList || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      //交卷
-      this.$api
-        .examRecordEdit({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
-          status: 1,
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
-          examTime: parseInt(this.allTimes),
-          doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-          }
-        });
-
-      //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: 1, // 做题模式 1章卷 2随机练习
-        })
-        .then((res) => {});
     },
 
     openFooterTab() {
@@ -1629,7 +1290,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
-      this.getCollectInfo(this.current)
+      this.getCollectInfo(this.current);
     },
 
     deleteImg(imgIndex, bankIndex) {
@@ -1753,7 +1414,7 @@ export default {
             },
             success: (result) => {
               // if (result.statusCode === 200) {
-                resolve(ossToken.dir);
+              resolve(ossToken.dir);
               // } else {
               //   uni.showToast({
               //     title: "上传失败",

+ 42 - 188
pages2/bank/questionBankExplainDetail.vue

@@ -10,11 +10,7 @@
         active-color="#007AFF"
       ></u-tabs>
     </view>
-    <swiper
-      class="swiper"
-      :current="current"
-      @change="swiperChange"
-    >
+    <swiper class="swiper" :current="current" @change="swiperChange">
       <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
         <view class="pageContent">
           <view class="pad_8 titBox">
@@ -222,8 +218,11 @@
                 >
                   <text
                     :class="{
-                      right: index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
-                      wrong: index == (bank.ques == 1 ? 0 : 1) && bank.ques != bank.ans,
+                      right:
+                        index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
+                      wrong:
+                        index == (bank.ques == 1 ? 0 : 1) &&
+                        bank.ques != bank.ans,
                     }"
                     class="activeTI"
                     >{{ ast[index] }}</text
@@ -244,7 +243,9 @@
             <view v-if="bank.ques">
               <view class="pad_8 answer">
                 <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
-                <view v-if="!explain">我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
+                <view v-if="!explain"
+                  >我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view
+                >
               </view>
               <view class="pad_8 answerInfos">
                 <view class="answerTitle">答案解析</view>
@@ -565,7 +566,7 @@
                       <text
                         :class="{
                           right:
-                           childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
+                            childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
                             childindex != bank.ans[ansIndex],
                           wrong:
                             childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
@@ -590,9 +591,15 @@
                 </view>
                 <view v-if="bank.ques[ansIndex]">
                   <view class="pad_8 answer">
-                    <view>题目答案:{{ ast[bank.ans[ansIndex] == 1 ? 0 : 1] }}</view>
+                    <view
+                      >题目答案:{{
+                        ast[bank.ans[ansIndex] == 1 ? 0 : 1]
+                      }}</view
+                    >
                     <view v-if="!explain"
-                      >我的答案:{{ ast[bank.ques[ansIndex] == 1 ? 0 : 1] }}</view
+                      >我的答案:{{
+                        ast[bank.ques[ansIndex] == 1 ? 0 : 1]
+                      }}</view
                     >
                   </view>
                   <view class="pad_8 answerInfos">
@@ -1192,63 +1199,24 @@ export default {
     },
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        this.questionList.length &&
-          this.questionList.forEach((item, index) => {
-            if (item.type == 1) {
-              if (item.ques == item.ans) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 2) {
-              let isRight =
-                item.ques &&
-                item.ques.every((quesItem, quesIndex) => {
-                  return item.ques[quesIndex] == item.ans[quesIndex];
-                });
-
-              if (isRight) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques && item.ques.length) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 3) {
-              if (item.ques == item.ans) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            } else if (item == 4) {
-              if (item.ques.length) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 5) {
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            }
-          });
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             examId: this.id,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            rightQuestionNum: number,
+            rightQuestionNum,
+            doQuestionIds,
             status: 0,
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1288,142 +1256,24 @@ export default {
     /**
      * 提交数据
      */
-    submit() {
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let allScore = 0;
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            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++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let checkboxScore = item.score; //获取单题总分数
-            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) {
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
-                    checkboxScore = item.partScore;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (checkboxScore <= 0) {
-              //0分
-              item.scoreResult = 0;
-              doWrongQuestionIds.push(item.questionId);
-            } else {
-              //部分分
-              number++;
-              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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            doWrongQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-          }
-        } else if (item.type == 5) {
-          if (item.ques) {
-            doQuestionNum++;
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       this.$api
         .examRecordEdit({
           examId: this.id,
           goodsId: this.goodsId,
-          reportStatus: reportStatus,
-          totalScore: allScore,
           recordId: this.recordId,
-          rightQuestionNum: number,
           status: 1,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 2000,
@@ -1477,12 +1327,16 @@ export default {
 
     judgeSelect(index, bindex) {
       if (this.questionList[bindex].ques) return;
-      this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
+      this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
     },
 
     judgeSelectChild(ansindex, childindex, bindex) {
       if (this.questionList[bindex].ques[ansindex]) return;
-      this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
+      this.$set(
+        this.questionList[bindex].ques,
+        ansindex,
+        childindex == 0 ? "1" : "0"
+      );
     },
 
     openFooterTab() {
@@ -1497,7 +1351,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
-      this.getCollectInfo(this.current)
+      this.getCollectInfo(this.current);
     },
 
     deleteImg(imgIndex, bankIndex) {
@@ -1620,7 +1474,7 @@ export default {
             },
             success: (result) => {
               // if (result.statusCode === 200) {
-                resolve(ossToken.dir);
+              resolve(ossToken.dir);
               // } else {
               //   uni.showToast({
               //     title: "上传失败",

+ 1 - 4
pages2/bank/question_record.vue

@@ -41,10 +41,7 @@
           </view>
           <view>
             <image src="/static/icon/wk_icon2.png"></image>
-            <text
-              >总共 {{ record.totalQuestionNum }} 题 做对
-              {{ record.rightQuestionNum }} 题</text
-            >
+            <text>总共 {{ record.totalQuestionNum }} 题 做对 {{ record.rightQuestionNum }} 题</text>
           </view>
         </view>
         <view class="btns">

+ 4 - 4
pages2/bank/question_report.vue

@@ -62,7 +62,7 @@
             <!-- {{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}% -->
           </view>
           <view>正确率</view>
-          <view>不含简答/案例题</view>
+          <view>不含主观题</view>
         </view>
         <view class="right">
           <view class="flex up">
@@ -140,7 +140,7 @@
         >
         <view
           class="btnACs"
-          v-if="doMode != 3 && (entryType != 'random' || nextExamId)"
+          v-if="doMode != 3 && (entryType == 'daily' || nextExamId)"
           @click="backBank"
           >继续做题</view
         >
@@ -246,7 +246,7 @@ export default {
       bankNum: 5, // 随机练习的题目数量
       examName: "", // 试卷名称
       doMode: "",
-      courseType:''
+      courseType: "",
     };
   },
   onUnload() {},
@@ -268,7 +268,7 @@ export default {
     this.chapterId = option.chapterId || 0;
     this.goodsId = option.goodsId || "";
     this.doMode = option.doMode;
-    this.courseType = option.courseType
+    this.courseType = option.courseType;
     this.examWrongRecordWrongNum();
     this.bankExamNextExam();
     // await this.bankExam();

+ 14 - 402
pages2/class/questionBank.vue

@@ -1532,6 +1532,9 @@ export default {
       return this.$api.bankExam(this.id).then((res) => {
         this.bankType = res.data.data.doType;
         this.examData = res.data.data;
+        this.allTimes = this.examData.answerTime * 60;
+        this.lastTime =
+          this.examData.answerTime && this.examData.answerTime * 60;
         if (this.bankType == 2) {
           this.needBack = true;
         }
@@ -1686,135 +1689,6 @@ export default {
         return;
       }
       this.submit("leaveNow");
-      return;
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let doQuestionIds = []; //做过的题目id
-      let doQuestionNum = 0; //做过的题目数量
-      let passScore = 0;
-      let allScore = 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++;
-          } else {
-            item.scoreResult = 0;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else if (item.type == 2) {
-          let isRight =
-            item.ques &&
-            item.ques.every((quesItem, quesIndex) => {
-              return item.ques[quesIndex] == item.ans[quesIndex];
-            });
-
-          if (isRight) {
-            //全对
-            item.scoreResult = item.score;
-            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;
-                }
-              });
-
-            //没选错
-            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) {
-              item.scoreResult = 0;
-            } else {
-              item.scoreResult = checkboxScore;
-            }
-
-            score += checkboxScore;
-          }
-
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-          } else {
-            item.scoreResult = 0;
-          }
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else {
-          allScore += item.score;
-        }
-      });
-
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      this.$api
-        .bankRecordEdit({
-          moduleId: this.moduleId || 0,
-          chapterId: this.chapterId || 0,
-          sectionId: this.sectionId || 0,
-          gradeId: this.gradeId,
-          courseId: this.courseId,
-          orderGoodsId: this.orderGoodsId,
-          goodsId: this.goodsId,
-          examId: this.id,
-          recordId: this.recordId,
-          reportStatus: reportStatus,
-          rightQuestionNum: number,
-          doQuestionNum: doQuestionNum,
-          status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          performance: score,
-          totalScore: allScore,
-          type: this.examType,
-          // examTime: parseInt(this.allTimes),
-          // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          // historyExamJson: JSON.stringify(this.questionList)
-        })
-        .then((res) => {});
     },
     /**
      * 立即交卷
@@ -1830,118 +1704,6 @@ export default {
     examRecordEdit() {
       if (!this.isSubmit) {
         this.submit("leave");
-        return;
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let reportStatus = 0;
-        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++;
-            }
-          } else if (item.type == 2) {
-            let isRight =
-              item.ques &&
-              item.ques.every((quesItem, quesIndex) => {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              });
-
-            if (isRight) {
-              score += item.score;
-              number++;
-            } else {
-              let hasPart = false;
-              let checkboxScore = 1; //获取单题总分数
-              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) => {
-                  //漏选扣一部分
-                  if (item.ques) {
-                    if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
-                      checkboxScore += item.partScore;
-                      hasPart = true;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (!hasPart) {
-                item.scoreResult = 0;
-              } else {
-                lessQuestionNum++;
-                item.scoreResult = checkboxScore;
-                score += checkboxScore;
-                // number++;
-              }
-            }
-
-            if (item.ques && item.ques.length) {
-              doQuestionNum++;
-            }
-          } else if (item.type == 3) {
-            if (item.ques == item.ans) {
-              score += item.score;
-              number++;
-            }
-
-            if (item.ques) {
-              doQuestionNum++;
-            }
-          } else if (item == 4) {
-            if (item.ques.length) {
-              doQuestionNum++;
-            }
-          } else if (item.type == 5) {
-            if (item.ques) {
-              doQuestionNum++;
-            }
-          }
-        });
-
-        if (score >= 60) {
-          reportStatus = 1;
-        }
-
-        this.$api
-          .bankRecordEdit({
-            moduleId: this.moduleId || 0,
-            chapterId: this.chapterId || 0,
-            sectionId: this.sectionId || 0,
-            gradeId: this.gradeId,
-            courseId: this.courseId,
-            orderGoodsId: this.orderGoodsId,
-            goodsId: this.goodsId,
-            examId: this.id,
-            recordId: this.recordId,
-            lessQuestionNum: lessQuestionNum,
-            performance: score,
-            reportStatus: reportStatus,
-            status: 1,
-            type: this.examType,
-            // historyExamJson: JSON.stringify(this.questionList)
-          })
-          .then((res) => {});
       }
     },
 
@@ -1989,7 +1751,7 @@ export default {
         from: 2,
       }).then(async (res) => {
         if (res.data.code == 500) {
-          return this.noListTip('你已完成所有题目')
+          return this.noListTip("你已完成所有题目");
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1997,11 +1759,8 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          return this.noListTip()
+          return this.noListTip();
         }
-        this.allTimes = data[0].answerTime * 60;
-        this.lastTime = data[0].answerTime && data[0].answerTime * 60;
-
         data.forEach((item, index) => {
           if (typeof item.jsonStr == "string") {
             item.jsonStr = JSON.parse(item.jsonStr);
@@ -2487,146 +2246,7 @@ export default {
      * 交卷
      */
     submit(typesubmit) {
-      console.log("交卷", typesubmit);
-      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;
-                }
-              });
-            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分
-              item.scoreResult = 0;
-              if (item.ques) {
-                doWrongQuestionIds.push(item.questionId);
-              }
-            } else {
-              //部分分
-              // number++;
-              // doWrongQuestionIds.push(item.questionId);
-              lessQuestionNum++;
-              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;
-      }
-
+      let form = this.$method.calculateScore(this.questionList);
       clearInterval(this.timer);
       //交卷
       this.$api
@@ -2638,21 +2258,13 @@ export default {
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
           courseId: this.courseId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           type: this.examType,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
@@ -2669,17 +2281,17 @@ export default {
                 uni.redirectTo({
                   url:
                     "/pages2/class/question_report?rightQuestionNum=" +
-                    number +
+                    form.rightQuestionNum +
                     "&doWrongQuestionNum=" +
-                    doWrongQuestionIds.length +
+                    form.questionIds.length +
                     "&score=" +
-                    score +
+                    form.performance +
                     "&totalScore=" +
-                    allScore +
+                    form.totalScore +
                     "&reportStatus=" +
-                    reportStatus +
+                    form.reportStatus +
                     "&lessQuestionNum=" +
-                    lessQuestionNum +
+                    form.lessQuestionNum +
                     "&examId=" +
                     this.id +
                     "&recordId=" +
@@ -2705,7 +2317,7 @@ export default {
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           type: 2, // 视频课程的传2
           doMode: this.doMode,

+ 9 - 17
pages3/polyv/detail.vue

@@ -954,14 +954,7 @@ export default {
       }
     },
   },
-  async onLoad(option) {
-    if (option.skipPort) {
-      await this.$method.skipLogin(option.skipPort);
-    }
-    if (this.$method.isGoLogin()) {
-      // 从公众号消息进来的没登录需要跳到登录页,登录后返回
-      return;
-    }
+  onLoad(option) {
     if (option.isOther) {
       this.showMark = true;
       return;
@@ -974,16 +967,15 @@ export default {
     this.option = option;
     // 公众号模板消息的数据埋点
     option.informId && this.clickOfficial(option.informId);
-    this.courseCourseList();
   },
   async onShow() {
-    // if (this.option.skipPort) {
-    //   await this.$method.skipLogin(this.option.skipPort);
-    // }
-    // if (this.$method.isGoLogin()) {
-    //   return;
-    // }
-    // this.courseCourseList();
+    if (this.option.skipPort) {
+      await this.$method.skipLogin(this.option.skipPort);
+    }
+    if (this.$method.isGoLogin()) {
+      return;
+    }
+    this.courseCourseList();
   },
   onUnload() {
     console.log("onUnloadonUnloadonUnloadonUnload");
@@ -1846,7 +1838,7 @@ export default {
       // buyCourse 是否购买课程:1是 0否
       let encode = encodeURIComponent(
         this.config.hostLive +
-          "pages/live/index?token=" +
+          "/pages/live/index?token=" +
           uni.getStorageSync("token") +
           "&userInfo=" +
           JSON.stringify(this.userInfo) +

+ 59 - 18
pages4/login/login.vue

@@ -27,13 +27,21 @@
       </view>
       <view class="login_box">
         <u-form :model="form" ref="uForm1" v-show="current == 0">
-          <u-form-item prop="account"
+          <u-form-item prop="account" v-if="!isDualAuth"
             ><u-input
               type="idcard"
               v-model="form.account"
               placeholder-style="color:#999999"
               placeholder="手机号/学员身份证"
           /></u-form-item>
+          <u-form-item prop="account" ref="account" v-else
+            ><u-input
+              type="number"
+              maxlength="11"
+              placeholder-style="color:#999999"
+              v-model="form.account"
+              placeholder="手机号"
+          /></u-form-item>
           <u-form-item prop="pwd"
             ><u-input
               class="password"
@@ -42,6 +50,17 @@
               type="password"
               placeholder="登录密码"
           /></u-form-item>
+          <u-form-item prop="code" v-if="isDualAuth">
+            <u-input
+              v-model="form.code"
+              type="number"
+              placeholder-style="color:#999999"
+              placeholder="验证码"
+            />
+            <u-button slot="right" size="mini" @click="getCode('account')">{{
+              codeTips
+            }}</u-button>
+          </u-form-item>
         </u-form>
         <u-form :model="form" ref="uForm2" v-show="current == 1">
           <u-form-item prop="tel" ref="tel"
@@ -59,7 +78,7 @@
               placeholder-style="color:#999999"
               placeholder="验证码"
             />
-            <u-button slot="right" size="mini" @click="getCode">{{
+            <u-button slot="right" size="mini" @click="getCode('tel')">{{
               codeTips
             }}</u-button>
           </u-form-item>
@@ -182,7 +201,6 @@ export default {
           {
             required: true,
             message: "请输入手机号/学员身份证",
-            // 可以单个或者同时写两个触发验证方式
             trigger: ["change"],
           },
         ],
@@ -210,29 +228,20 @@ export default {
       newUser_sc: "", // 用户扫码进来详情页获取的sc
       shareActivityCode: "", // 用户扫码进来详情页获取的
       isBack: false,
+      isDualAuth: false,
     };
   },
   onLoad(option) {
     if (option.isBack) {
       this.isBack = option.isBack;
     }
-    console.log("登录后的this.isBack:", option.isBack, typeof this.isBack);
-    // else if (option.scanCode) {
-    // 	this.scanCode = option.scanCode
-    // }
-    // this.from = option.from;
     if (uni.getStorageSync("newUser_sc")) {
       this.newUser_sc = uni.getStorageSync("newUser_sc");
     }
     if (uni.getStorageSync("shareActivityCode")) {
       this.shareActivityCode = uni.getStorageSync("shareActivityCode");
     }
-    console.log(
-      "---this.newUser_sc:",
-      this.newUser_sc,
-      "this.shareActivityCode:",
-      this.shareActivityCode
-    );
+    this.getDualAuth();
   },
   onShow() {
     // 获取code
@@ -265,6 +274,29 @@ export default {
         });
       }
     },
+    getDualAuth() {
+      this.$api.getDualAuth().then((res) => {
+        if (res.data.code == 200) {
+          this.isDualAuth = res.data.data * 1;
+          if (this.isDualAuth === 1) {
+            this.rules.account = [
+              {
+                required: true,
+                message: "请输入手机号",
+                trigger: ["change"],
+              },
+              {
+                validator: (rule, value, callback) => {
+                  return this.$u.test.mobile(value);
+                },
+                message: "手机号码格式不正确",
+                trigger: ["change"],
+              },
+            ];
+          }
+        }
+      });
+    },
     wxLogin(e) {
       this.$api
         .wxLogin({
@@ -366,6 +398,15 @@ export default {
         this.$u.toast("请输入密码");
         return;
       }
+
+      if (this.isDualAuth) {
+        if (!this.form.code) {
+          this.$u.toast("请输入验证码");
+          return;
+        }
+        this.form.tel = this.form.account;
+      }
+
       //虚拟登录
       /* that.fakeLogin()
 			return */
@@ -392,11 +433,11 @@ export default {
       this.codeTips = text;
     },
     // 获取验证码
-    getCode() {
+    getCode(key) {
       let that = this;
       if (that.$refs.uCode.canGetCode) {
-        if (that.$refs.tel.validateState == "success") {
-          let datas = { tel: this.form.tel };
+        if (that.$refs[key].validateState == "success") {
+          let datas = { tel: this.form[key] };
           that.$api.loginSms(datas).then(
             (res) => {
               if (res.data.code == 200) {
@@ -412,7 +453,7 @@ export default {
             }
           );
         } else {
-          this.$refs.tel.onFieldChange();
+          this.$refs[key].onFieldChange();
         }
       }
     },

+ 18 - 432
pages5/examBank/index.vue

@@ -1199,191 +1199,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false);
       uni.navigateBack({
         delta: 1,
       });
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        // passScore = item.passScore
-        if (item.type == 1) {
-          //正确
-
-          console.log(item.ques, item.ans);
-          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;
-                }
-              });
-            console.log(checkboxScore);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选只能得部分分数
-                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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      if (this.subscribeId) {
-        this.mockSubscribeEdit();
-      }
-
-      //交卷
-      this.$api
-        .mockRecordEdit({
-          examId: this.examId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          eachExamId: this.eachExamId,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
-          examTime: parseInt(this.allTimes),
-          doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-          }
-        });
-
-      //错题集id提交(客观题)
-      if (doWrongQuestionIds.length) {
-        this.$api
-          .mockWrongRecord({
-            eachExamId: this.eachExamId,
-            examId: this.examId,
-            questionIds: doWrongQuestionIds,
-            recordId: this.recordId,
-            doMode: this.doMode,
-          })
-          .then((res) => {});
-      }
     },
     /**
      * 立即交卷
@@ -1399,115 +1218,26 @@ export default {
      */
     mockRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        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 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;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (checkboxScore <= 0) {
-                //0分
-              } else {
-                //部分分
-                // number++;
-                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);
-            }
-          }
-        });
-
         if (this.subscribeId) {
           this.mockSubscribeEdit();
         }
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .mockRecordEdit({
             examId: this.examId,
             eachExamId: this.eachExamId,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            doQuestionIds: doQuestionIds.join(","),
-            rightQuestionNum: number,
+            doQuestionIds,
+            rightQuestionNum,
             status: 1,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1978,147 +1708,8 @@ export default {
     /**
      * 交卷
      */
-    submit() {
-      console.log("itme--", 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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            console.log("sfsofhusdho");
-            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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       if (this.subscribeId) {
         this.mockSubscribeEdit();
       }
@@ -2128,23 +1719,18 @@ export default {
         .mockRecordEdit({
           examId: this.examId,
           eachExamId: this.eachExamId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
           status: 1,
-          lessQuestionNum: lessQuestionNum,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 1000,
@@ -2175,7 +1761,7 @@ export default {
           .mockWrongRecord({
             eachExamId: this.eachExamId,
             examId: this.examId,
-            questionIds: doWrongQuestionIds,
+            questionIds: form.questionIds,
             recordId: this.recordId,
             doMode: this.doMode,
           })

+ 1 - 1
pages5/examList/index.vue

@@ -445,7 +445,7 @@ export default {
       // buyCourse 是否购买课程:1是 0否
       let encode = encodeURIComponent(
         this.config.hostLive +
-          "pages/live/index?token=" +
+          "/pages/live/index?token=" +
           uni.getStorageSync("token") +
           "&userInfo=" +
           JSON.stringify(this.userInfo) +

+ 1 - 1
pages5/examReport/index.vue

@@ -540,7 +540,7 @@ export default {
       // buyCourse 是否购买课程:1是 0否
       let encode = encodeURIComponent(
         this.config.hostLive +
-          "pages/live/index?token=" +
+          "/pages/live/index?token=" +
           uni.getStorageSync("token") +
           "&userInfo=" +
           JSON.stringify(this.userInfo) +