yangg 11 小時之前
父節點
當前提交
68cbac61d6

+ 49 - 15
pages/camera/camera.vue

@@ -602,8 +602,10 @@
 					return;
 				}
 
-				// 如果已经显示结果,不允许再次选择
-				if (this.showResult) return;
+				// 如果已经显示结果,重置结果状态
+				if (this.showResult) {
+					this.showResult = false;
+				}
 				
 				console.log('selectOption', index);
 				// 判断当前题目类型
@@ -627,12 +629,23 @@
 						
 						this.submitCurrentAnswer().then(() => {
 							setTimeout(() => {
-								this.goToNextQuestion();
+								// 如果是在回答上一题,完成后要回到当前题目
+								if (this.currentQuestionIndex < this.answers.length - 1) {
+									this.currentQuestionIndex++;
+									this.currentScrollId = 'question-' + this.currentQuestionIndex;
+								} else {
+									this.goToNextQuestion();
+								}
 							}, 800);
 						}).catch(error => {
 							console.error('提交答案失败:', error);
 							setTimeout(() => {
-								this.goToNextQuestion();
+								if (this.currentQuestionIndex < this.answers.length - 1) {
+									this.currentQuestionIndex++;
+									this.currentScrollId = 'question-' + this.currentQuestionIndex;
+								} else {
+									this.goToNextQuestion();
+								}
 							}, 1000);
 						});
 					}, 500);
@@ -660,12 +673,23 @@
 						
 						this.submitCurrentAnswer().then(() => {
 							setTimeout(() => {
-								this.goToNextQuestion();
+								// 如果是在回答上一题,完成后要回到当前题目
+								if (this.currentQuestionIndex < this.answers.length - 1) {
+									this.currentQuestionIndex++;
+									this.currentScrollId = 'question-' + this.currentQuestionIndex;
+								} else {
+									this.goToNextQuestion();
+								}
 							}, 800);
 						}).catch(error => {
 							console.error('提交答案失败:', error);
 							setTimeout(() => {
-								this.goToNextQuestion();
+								if (this.currentQuestionIndex < this.answers.length - 1) {
+									this.currentQuestionIndex++;
+									this.currentScrollId = 'question-' + this.currentQuestionIndex;
+								} else {
+									this.goToNextQuestion();
+								}
 							}, 1000);
 						});
 					}, 500);
@@ -963,13 +987,13 @@
 
 			// 修改 handleOptionClick 方法
 			handleOptionClick(qIndex, index) {
-				// 如果点击的是已完成的题目
-				if (qIndex < this.currentQuestionIndex) {
-					uni.showToast({
-						title: '该题目已完成,无法修改',
+				// 如果点击的是已完成的题目,但不是上一题
+				if (qIndex < this.currentQuestionIndex - 1) {
+					/* uni.showToast({
+						title: '只能修改上一题的答案',
 						icon: 'none',
 						duration: 2000
-					});
+					}); */
 					return;
 				}
 				
@@ -1010,7 +1034,17 @@
 				}
 				
 				try {
-					// 如果是当前题目,调用选择逻辑
+					// 如果是上一题,先切换到上一题
+					if (qIndex === this.currentQuestionIndex - 1) {
+						this.currentQuestionIndex = qIndex;
+						this.currentScrollId = 'question-' + qIndex;
+						// 重置相关状态
+						this.showResult = false;
+						this.selectedOption = null;
+						this.selectedOptions = [];
+					}
+					
+					// 调用选择逻辑
 					this.selectOption(index);
 					
 					// 设置延时,防止快速重复点击
@@ -1149,9 +1183,9 @@
 					this.isSubmitting = true;
 					
 					// 显示提交中提示
-					uni.showLoading({
-						title: '正在提交答案...'
-					});
+					// uni.showLoading({
+					// 	title: '正在提交答案...'
+					// });
 					
 					// 构建提交数据
 					let answerContent = '';

+ 35 - 15
unpackage/dist/dev/mp-weixin/pages/camera/camera.js

@@ -395,8 +395,9 @@ const _sfc_main = {
         });
         return;
       }
-      if (this.showResult)
-        return;
+      if (this.showResult) {
+        this.showResult = false;
+      }
       console.log("selectOption", index);
       if (this.currentQuestion.questionType === 2) {
         const optionIndex = this.selectedOptions.indexOf(index);
@@ -413,12 +414,22 @@ const _sfc_main = {
           this.saveAnswer();
           this.submitCurrentAnswer().then(() => {
             setTimeout(() => {
-              this.goToNextQuestion();
+              if (this.currentQuestionIndex < this.answers.length - 1) {
+                this.currentQuestionIndex++;
+                this.currentScrollId = "question-" + this.currentQuestionIndex;
+              } else {
+                this.goToNextQuestion();
+              }
             }, 800);
           }).catch((error) => {
             console.error("提交答案失败:", error);
             setTimeout(() => {
-              this.goToNextQuestion();
+              if (this.currentQuestionIndex < this.answers.length - 1) {
+                this.currentQuestionIndex++;
+                this.currentScrollId = "question-" + this.currentQuestionIndex;
+              } else {
+                this.goToNextQuestion();
+              }
             }, 1e3);
           });
         }, 500);
@@ -441,12 +452,22 @@ const _sfc_main = {
           this.saveAnswer();
           this.submitCurrentAnswer().then(() => {
             setTimeout(() => {
-              this.goToNextQuestion();
+              if (this.currentQuestionIndex < this.answers.length - 1) {
+                this.currentQuestionIndex++;
+                this.currentScrollId = "question-" + this.currentQuestionIndex;
+              } else {
+                this.goToNextQuestion();
+              }
             }, 800);
           }).catch((error) => {
             console.error("提交答案失败:", error);
             setTimeout(() => {
-              this.goToNextQuestion();
+              if (this.currentQuestionIndex < this.answers.length - 1) {
+                this.currentQuestionIndex++;
+                this.currentScrollId = "question-" + this.currentQuestionIndex;
+              } else {
+                this.goToNextQuestion();
+              }
             }, 1e3);
           });
         }, 500);
@@ -645,12 +666,7 @@ const _sfc_main = {
     },
     // 修改 handleOptionClick 方法
     handleOptionClick(qIndex, index) {
-      if (qIndex < this.currentQuestionIndex) {
-        common_vendor.index.showToast({
-          title: "该题目已完成,无法修改",
-          icon: "none",
-          duration: 2e3
-        });
+      if (qIndex < this.currentQuestionIndex - 1) {
         return;
       }
       if (qIndex === this.questions.length - 1 && this.showContinueButton) {
@@ -679,6 +695,13 @@ const _sfc_main = {
         clearTimeout(this._clickTimer);
       }
       try {
+        if (qIndex === this.currentQuestionIndex - 1) {
+          this.currentQuestionIndex = qIndex;
+          this.currentScrollId = "question-" + qIndex;
+          this.showResult = false;
+          this.selectedOption = null;
+          this.selectedOptions = [];
+        }
         this.selectOption(index);
         this._clickTimer = setTimeout(() => {
           this._isClicking = false;
@@ -787,9 +810,6 @@ const _sfc_main = {
         return;
       try {
         this.isSubmitting = true;
-        common_vendor.index.showLoading({
-          title: "正在提交答案..."
-        });
         let answerContent = "";
         let answerOptions = [];
         if (this.currentAnswer.questionType === 0) {

+ 1 - 1
unpackage/dist/dev/mp-weixin/project.config.json

@@ -8,7 +8,7 @@
     "urlCheck": false,
     "es6": true,
     "postcss": false,
-    "minified": false,
+    "minified": true,
     "newFeature": true,
     "bigPackageSizeSupport": true,
     "babelSetting": {