谢杰标 2 жил өмнө
parent
commit
b7fd10c9a8

+ 16 - 35
pages2/bank/questionBank.vue

@@ -1592,18 +1592,7 @@ export default {
           this.examData = res.data.data || {};
           this.id = this.examData.examId;
           if (!this.examData.questionList.length) {
-            this.hideDialog();
-            uni.showModal({
-              showCancel: false,
-              content: "该试卷暂无题目",
-              success: (k) => {
-                if (k.confirm) {
-                  this.isSubmit = true;
-                  uni.navigateBack();
-                }
-              },
-            });
-            return;
+            return this.noListTip()
           }
           this.dataAnlyze(this.examData.questionList || []);
         } else {
@@ -1614,6 +1603,19 @@ export default {
         }
       });
     },
+    noListTip(content = "该试卷暂无题目") {
+      this.hideDialog();
+      uni.showModal({
+        showCancel: false,
+        content,
+        success: (k) => {
+          if (k.confirm) {
+            this.isSubmit = true;
+            uni.navigateBack();
+          }
+        },
+      });
+    },
     /**
      * 请求题目列表 app/common/bank/question/list
      */
@@ -1627,17 +1629,7 @@ export default {
         from: 1,
       }).then((res) => {
         if (res.data.code == 500) {
-          uni.showModal({
-            showCancel: false,
-            content: "你已完成所有题目",
-            success: (k) => {
-              if (k.confirm) {
-                this.isSubmit = true;
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip('你已完成所有题目')
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1645,18 +1637,7 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          this.hideDialog();
-          uni.showModal({
-            showCancel: false,
-            content: "该试卷暂无题目",
-            success: (k) => {
-              if (k.confirm) {
-                this.isSubmit = true;
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip()
         }
         this.allTimes = data[0].answerTime * 60;
         this.lastTime = data[0].answerTime && data[0].answerTime * 60;

+ 17 - 24
pages2/class/questionBank.vue

@@ -1963,6 +1963,19 @@ export default {
         return "";
       }
     },
+    noListTip(content = "该试卷暂无题目") {
+      this.hideDialog();
+      uni.showModal({
+        showCancel: false,
+        content,
+        success: (k) => {
+          if (k.confirm) {
+            this.isSubmit = true;
+            uni.navigateBack();
+          }
+        },
+      });
+    },
     /**
      * 请求题目列表
      */
@@ -1976,17 +1989,7 @@ export default {
         from: 2,
       }).then(async (res) => {
         if (res.data.code == 500) {
-          uni.showModal({
-            showCancel: false,
-            content: "你已完成所有题目",
-            success: (k) => {
-              if (k.confirm) {
-                this.isSubmit = true;
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip('你已完成所有题目')
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1994,17 +1997,7 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          this.hideDialog();
-          uni.showModal({
-            showCancel: false,
-            content: "该试卷暂无题目",
-            success: function (k) {
-              if (k.confirm) {
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip()
         }
         this.allTimes = data[0].answerTime * 60;
         this.lastTime = data[0].answerTime && data[0].answerTime * 60;
@@ -2859,7 +2852,7 @@ export default {
         imageList: this.questionList[bankindex].ansText.imageList,
         text: this.questionList[bankindex].ansText.text,
       });
-	  this.$u.toast("已确认答案");
+      this.$u.toast("已确认答案");
       this.isDoOver();
     },
 
@@ -2886,7 +2879,7 @@ export default {
           this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
         text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
       });
-	  this.$u.toast("已确认答案");
+      this.$u.toast("已确认答案");
       this.isDoOver();
     },
     isCheck(item, index) {

+ 15 - 23
pages5/examBank/index.vue

@@ -1564,6 +1564,19 @@ export default {
     hideDialog() {
       this.showDialog = false;
     },
+    noListTip(content = "该试卷暂无题目") {
+      this.hideDialog();
+      uni.showModal({
+        showCancel: false,
+        content,
+        success: (k) => {
+          if (k.confirm) {
+            this.isSubmit = true;
+            uni.navigateBack();
+          }
+        },
+      });
+    },
     /**
      * 请求题目列表
      */
@@ -1578,17 +1591,7 @@ export default {
         from: 3,
       }).then((res) => {
         if (res.data.code == 500) {
-          uni.showModal({
-            showCancel: false,
-            content: "你已完成所有题目",
-            success: (k) => {
-              if (k.confirm) {
-                this.isSubmit = true;
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip("你已完成所有题目");
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1596,18 +1599,7 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          this.hideDialog();
-          uni.showModal({
-            showCancel: false,
-            content: "该试卷暂无题目",
-            success: (k) => {
-              if (k.confirm) {
-                this.isSubmit = true;
-                uni.navigateBack();
-              }
-            },
-          });
-          return;
+          return this.noListTip();
         }
 
         if (this.subscribeId) {