dedsudiyu 1 неделя назад
Родитель
Сommit
c5a8becc7d

+ 12 - 18
api/request/request.js

@@ -65,14 +65,13 @@ export const apiResquest = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}
@@ -140,14 +139,13 @@ export const apiResquestOutside = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}
@@ -213,14 +211,13 @@ export const apiResquestForm = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}
@@ -284,14 +281,13 @@ export const apiResquestJsonList = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}
@@ -357,14 +353,13 @@ export const apiResquestFormVideo = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}
@@ -427,14 +422,13 @@ export const apiResquestTimer = (prams) => {
 				// 失败
 				// 失败
 				uni.hideLoading()
 				uni.hideLoading()
 				uni.showToast({
 				uni.showToast({
-					mask: false,
+					mask: true,
 					icon: "none",
 					icon: "none",
 					position: "center",
 					position: "center",
 					title: '出错啦~请联系管理员!',
 					title: '出错啦~请联系管理员!',
 					duration: 2000
 					duration: 2000
 				});
 				});
-				reject(err);
-			},
+							},
 			complete: () => {
 			complete: () => {
 				// 完成
 				// 完成
 			}
 			}

+ 10 - 2
pages_safetyEducationExamination/views/exam/mockExamPlay.vue

@@ -379,6 +379,14 @@
 					console.error('保存答案失败', e)
 					console.error('保存答案失败', e)
 				})
 				})
 			},
 			},
+			// 超时兜底:request.js 的 fail 不 reject,Promise 可能永远 pending
+			// 用 race 强制在 ms 后 resolve,保证 isSaving 能被 finally 释放
+			withTimeout(promise, ms = 12000) {
+				return Promise.race([
+					promise,
+					new Promise(resolve => setTimeout(resolve, ms))
+				]);
+			},
 			// 切换题目(先保存当前答案)
 			// 切换题目(先保存当前答案)
 			async changeQuestion(targetGi, targetQi) {
 			async changeQuestion(targetGi, targetQi) {
 				if (this.isSaving) return
 				if (this.isSaving) return
@@ -389,10 +397,10 @@
 				const prevQi = this.questionIndex
 				const prevQi = this.questionIndex
 				this.isSaving = true
 				this.isSaving = true
 				try {
 				try {
-					await this.saveCurrentAnswer()
+					await this.withTimeout(this.saveCurrentAnswer())
 					this.groupIndex = targetGi
 					this.groupIndex = targetGi
 					this.questionIndex = targetQi
 					this.questionIndex = targetQi
-					await this.loadQuestion(group.questions[targetQi].snapshotQuestionId)
+					await this.withTimeout(this.loadQuestion(group.questions[targetQi].snapshotQuestionId))
 				} catch (e) {
 				} catch (e) {
 					this.groupIndex = prevGi
 					this.groupIndex = prevGi
 					this.questionIndex = prevQi
 					this.questionIndex = prevQi

+ 10 - 2
pages_safetyEducationExamination/views/exam/onlineExamPlay.vue

@@ -381,6 +381,14 @@
 					console.error('保存答案失败', e);
 					console.error('保存答案失败', e);
 				});
 				});
 			},
 			},
+			// 超时兜底:request.js 的 fail 不 reject,Promise 可能永远 pending
+			// 用 race 强制在 ms 后 resolve,保证 isSaving 能被 finally 释放
+			withTimeout(promise, ms = 12000) {
+				return Promise.race([
+					promise,
+					new Promise(resolve => setTimeout(resolve, ms))
+				]);
+			},
 			async changeQuestion(targetGi, targetQi) {
 			async changeQuestion(targetGi, targetQi) {
 				if (this.isSaving) return;
 				if (this.isSaving) return;
 				if (targetGi === this.groupIndex && targetQi === this.questionIndex) return;
 				if (targetGi === this.groupIndex && targetQi === this.questionIndex) return;
@@ -390,10 +398,10 @@
 				const prevQi = this.questionIndex;
 				const prevQi = this.questionIndex;
 				this.isSaving = true;
 				this.isSaving = true;
 				try {
 				try {
-					await this.saveCurrentAnswer();
+					await this.withTimeout(this.saveCurrentAnswer());
 					this.groupIndex = targetGi;
 					this.groupIndex = targetGi;
 					this.questionIndex = targetQi;
 					this.questionIndex = targetQi;
-					await this.loadQuestion(group.questions[targetQi].snapshotQuestionId);
+					await this.withTimeout(this.loadQuestion(group.questions[targetQi].snapshotQuestionId));
 				} catch (e) {
 				} catch (e) {
 					this.groupIndex = prevGi;
 					this.groupIndex = prevGi;
 					this.questionIndex = prevQi;
 					this.questionIndex = prevQi;