Ver código fonte

试卷限制学习

谢杰标 2 anos atrás
pai
commit
7fdc61357d

+ 28 - 0
common/methodTool.js

@@ -764,4 +764,32 @@ export default {
         });
     });
   },
+  examClientCanLearn(examLimitClient) {
+    // 限制学习
+    if (!examLimitClient) {
+      return true;
+    }
+    // #ifdef MP-WEIXIN
+    if (examLimitClient == 2) {
+      return true;
+    }
+    // #endif
+    // #ifdef H5
+    if (examLimitClient == 1 && this.isWeixin()) {
+      return true;
+    }
+    // #endif
+    uni.showModal({
+      title: "提示",
+      showCancel: false,
+      content:
+        "请去" + (examLimitClient == 2 ? "微信小程序" : "公众号") + "学习",
+      success: (k) => {
+        if (k.confirm) {
+          uni.navigateBack();
+        }
+      },
+    });
+    return false;
+  },
 };

+ 6 - 3
pages2/bank/questionBank.vue

@@ -1060,13 +1060,17 @@ export default {
      * bank/exam + data
      */
     bankExam() {
-      return new Promise((resolve) => {
+      return new Promise((resolve, reject) => {
         this.$api.bankExam(this.id).then((res) => {
+          const { examLimitClient, doType } = res.data.data;
+          if (!this.$method.examClientCanLearn(examLimitClient)) {
+            reject();
+          }
           if (this.entryType == "daily") {
             // 每日一练类型都是为练习
             this.bankType = 1;
           } else {
-            this.bankType = res.data.data.doType;
+            this.bankType = doType;
           }
           this.examData = res.data.data;
           this.allTimes = this.examData.answerTime * 60;
@@ -1075,7 +1079,6 @@ export default {
           if (this.bankType == 2) {
             this.needBack = true;
           }
-
           resolve();
         });
       });

+ 4 - 1
pages2/bank/question_report.vue

@@ -526,8 +526,11 @@ export default {
     },
     bankExam() {
       // '/bank/exam/'+data
-      return new Promise((resolve) => {
+      return new Promise((resolve, reject) => {
         this.$api.bankExam(this.examId).then((res) => {
+          if (!this.$method.examClientCanLearn(res.data.data.examLimitClient)) {
+            reject();
+          }
           this.examData = res.data.data;
           resolve();
         });

+ 5 - 1
pages2/class/questionBank.vue

@@ -1515,7 +1515,11 @@ export default {
      */
     bankExam() {
       return this.$api.bankExam(this.id).then((res) => {
-        this.bankType = res.data.data.doType;
+        const { examLimitClient, doType } = res.data.data;
+        if (!this.$method.examClientCanLearn(examLimitClient)) {
+          return
+        }
+        this.bankType = doType;
         this.examData = res.data.data;
         this.allTimes = this.examData.answerTime * 60;
         this.lastTime =

+ 6 - 3
pages5/examBank/index.vue

@@ -1005,14 +1005,17 @@ export default {
      * 获取试卷类型2考试,1练习
      */
     bankExam() {
-      return new Promise((resolve) => {
+      return new Promise((resolve, reject) => {
         this.$api.bankExam(this.examId).then((res) => {
-          this.bankType = res.data.data.doType;
+          const { examLimitClient, doType } = res.data.data;
+          if (!this.$method.examClientCanLearn(examLimitClient)) {
+            reject();
+          }
+          this.bankType = doType;
           this.examData = res.data.data;
           if (this.bankType == 2) {
             this.needBack = true;
           }
-
           resolve();
         });
       });

+ 4 - 1
pages5/examReport/index.vue

@@ -577,8 +577,11 @@ export default {
         });
     },
     bankExam() {
-      return new Promise((resolve) => {
+      return new Promise((resolve, reject) => {
         this.$api.bankExam(this.examId).then((res) => {
+          if (!this.$method.examClientCanLearn(res.data.data.examLimitClient)) {
+            reject();
+          }
           this.examData = res.data.data;
           resolve();
         });