Explorar o código

修复拍照缺少id bug

chenxiong %!s(int64=3) %!d(string=hai) anos
pai
achega
9e376030b2
Modificáronse 1 ficheiros con 55 adicións e 52 borrados
  1. 55 52
      pages2/class/questionBank.vue

+ 55 - 52
pages2/class/questionBank.vue

@@ -678,7 +678,6 @@ export default {
 				self.ossAvatarUrl = ''
 				self.isTakePhoto = true;
 				//拍照
-				this.examRecord();
 				if(this.lastTime) {
 					this.timer = setInterval(() => {
 						if (this.lastTime <= 0) {
@@ -1210,7 +1209,7 @@ export default {
 				.goodsQuestionList({
 					examId: this.id
 				})
-				.then(res => {
+				.then(async res => {
 					if (!res.data.data.length) {
 						this.hideDialog();
 						uni.showModal({
@@ -1296,65 +1295,69 @@ export default {
 					this.questionList = res.data.data;
 					this.lastCount = this.questionList.length;
 					
-					if(this.needPhoto) {
-						this.photoPopup = true; //拍照
-					} else {
-						this.examRecord();
-					}
+					
+					await this.examRecord();
 					
 				});
 		},
 		/**
-		 * 记录总题数
+		 * 记录总题数,获取recordId
 		 * hasSpecial (是否包含简答和案例) true 包含  false 不包含
 		 */
 		examRecord(hasSpecial) {
-			let self = this
-			let questionList = 0;
-			if(!hasSpecial) {
-				this.questionList.forEach((item, index) => {
-					if(item.type == 1 || item.type == 2 || item.type == 3) {
-						questionList++;
-					}
-				})
-			} else {
-				questionList = this.questionList.length;
-			}
-			 
-			this.$api
-				.bankRecord({
-					chapterExamId: this.chapterId || 0,
-					moduleExamId: this.moduleId || 0,
-					examId: this.id,
-					goodsId: this.goodsId,
-					gradeId:this.gradeId,
-					totalQuestionNum: questionList
-				})
-				.then(res => {
-					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
-									})
+			return new Promise(resolve => {
+				let self = this
+				let questionList = 0;
+				if(!hasSpecial) {
+					this.questionList.forEach((item, index) => {
+						if(item.type == 1 || item.type == 2 || item.type == 3) {
+							questionList++;
+						}
+					})
+				} else {
+					questionList = this.questionList.length;
+				}
+				 
+				this.$api
+					.bankRecord({
+						chapterExamId: this.chapterId || 0,
+						moduleExamId: this.moduleId || 0,
+						examId: this.id,
+						goodsId: this.goodsId,
+						gradeId:this.gradeId,
+						totalQuestionNum: questionList
+					})
+					.then(res => {
+						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);
+							}
 							
-									this.submit();
-									return;
-								}
-								this.lastTime--;
-							}, 1000);
+							
+							resolve()
 						}
-					// }
-					
-				});
+						
+					});
+			})
+			
 			
 		},
 		/**