Browse Source

修复测试bug

chenxiong 3 years ago
parent
commit
247e015497
2 changed files with 66 additions and 38 deletions
  1. 1 1
      pages2/bank/questionBank.vue
  2. 65 37
      pages2/class/questionBank.vue

+ 1 - 1
pages2/bank/questionBank.vue

@@ -1068,7 +1068,7 @@ export default {
 								uni.showToast({
 									icon:'none',
 									mask:true,
-									title:'考试时间到,自动交卷',
+									title:'考试时间到,系统将自动交卷',
 									duration:10000
 								})
 

+ 65 - 37
pages2/class/questionBank.vue

@@ -490,6 +490,7 @@ export default {
 			avatarUrl:'',
 			ossAvatarUrl: '',
 			goodsDetail:{},
+			isTakePhoto:false,
 			needPhoto:false //是否需要拍照
 		};
 	},
@@ -511,7 +512,8 @@ export default {
 			this.showDialog = true;
 			uni.setStorageSync('showDialog','1');
 		}
-
+		
+		//考试时候用手势或者返回键 被迫返回做题
 		if (isBack) {
 			console.log(getApp());
 			let app = getApp();
@@ -520,22 +522,29 @@ export default {
 			for (var k in globalData.bankData) {
 				this[k] = globalData.bankData[k];
 			}
-
-			this.timer = setInterval(() => {
-				if (this.lastTime <= 0) {
-					clearInterval(this.timer);
-					uni.showToast({
-						icon:'none',
-						mask:true,
-						title:'考试时间到,自动交卷',
-						duration:10000
-					})
-
-					this.submit();
-					return;
+			
+			//需要拍没拍过直接弹出摄像头
+			if(this.needPhoto && !this.isTakePhoto) {
+				this.photoPopup = true;
+			} else { //不需要拍照
+				if(this.lastTime) {
+					this.timer = setInterval(() => {
+						if (this.lastTime <= 0) {
+							clearInterval(this.timer);
+							uni.showToast({
+								icon:'none',
+								mask:true,
+								title:'考试时间已到,系统将自动交卷',
+								duration:10000
+							})
+					
+							this.submit();
+							return;
+						}
+						this.lastTime--;
+					}, 1000);
 				}
-				this.lastTime--;
-			}, 1000);
+			}
 		} else {
 			this.goodsQuestionList();
 			this.bankExam();
@@ -553,7 +562,7 @@ export default {
 			app.globalData.bankData = this.$data;
 			clearInterval(this.timer);
 			uni.navigateTo({
-				url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
+				url: '/pages2/class/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
 			});
 		} else {
 			//点击返回按钮确认允许退出,交卷
@@ -583,6 +592,25 @@ export default {
 			};
 			this.$api.studyExamPhotoRecord(data).then(res => {
 				self.ossAvatarUrl = ''
+				self.isTakePhoto = true;
+				//拍照
+				if(this.lastTime) {
+					this.timer = setInterval(() => {
+						if (this.lastTime <= 0) {
+							clearInterval(this.timer);
+							uni.showToast({
+								icon:'none',
+								mask:true,
+								title:'考试时间已到,系统将自动交卷',
+								duration:10000
+							})
+					
+							this.submit();
+							return;
+						}
+						this.lastTime--;
+					}, 1000);
+				}
 			});
 		},
 		uploadFile(options, int) {
@@ -789,7 +817,7 @@ export default {
 					//简答题
 					if(hasSpecail) {
 						
-						if (item.ansText && (item.ansText.text.length || item.ansText.imageList.length)) {
+						if (item.ques && (item.ques.text.length || item.ques.imageList.length)) {
 							count++;
 						}
 					}
@@ -1090,25 +1118,7 @@ export default {
 					}
 					this.allTimes = res.data.data[0].answerTime * 60;
 					this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
-					//考试时间到了自动交卷
-					if (this.lastTime) {
-						this.timer = setInterval(() => {
-							if (this.lastTime <= 0) {
-								clearInterval(this.timer);
-								uni.showToast({
-									icon:'none',
-									mask:true,
-									title:'考试时间到,自动交卷',
-									duration:10000
-								})
-
-								this.submit();
-								return;
-							}
-							this.lastTime--;
-						}, 1000);
-					} else {
-					}
+					
 					res.data.data.forEach((item, index) => {
 						if (typeof item.jsonStr == 'string') {
 							item.jsonStr = JSON.parse(item.jsonStr);
@@ -1210,6 +1220,24 @@ export default {
 					this.recordId = res.data.data;
 					if(self.needPhoto){
 						self.photoPopup = true; //拍照
+					} else {
+						if(this.lastTime) {
+							this.timer = setInterval(() => {
+								if (this.lastTime <= 0) {
+									clearInterval(this.timer);
+									uni.showToast({
+										icon:'none',
+										mask:true,
+										title:'考试时间已到,系统将自动交卷',
+										duration:10000
+									})
+							
+									this.submit();
+									return;
+								}
+								this.lastTime--;
+							}, 1000);
+						}
 					}
 					
 				});