Browse Source

考试摄像头隐藏

xionghaojie 3 years ago
parent
commit
a3e141a22a
2 changed files with 30 additions and 29 deletions
  1. 5 19
      pages/login/login.vue
  2. 25 10
      pages/test/test.vue

+ 5 - 19
pages/login/login.vue

@@ -185,16 +185,12 @@ export default {
 					// this.open()
 					
 					// 直接考试,是否允许考试
-					req.getRequest(api.get_exam_question + this.paperId,{},quests=>{
-						if (quests && quests.length > 0) {
-							uni.navigateTo({
-								url: '/pages/test/test?paperId='+this.paperId,
-								success:()=> {
-									this.close()
-								}
-							});
+					uni.navigateTo({
+						url: '/pages/test/test?paperId='+this.paperId,
+						success:()=> {
+							this.close()
 						}
-					})
+					});
 				}
 			});
 		},
@@ -214,16 +210,6 @@ export default {
 						url:'/pages/scoreQuery/scoreQuery?paperId='+ this.paperId+'&admissionNo='+this.testNumber
 					})
 			});
-			// req.postRequest('/api/admission/login', formP, data => {
-			// 	if(data){
-			// 		req.setStorage('userInfo', data);
-			// 		req.getRequest('/api/v3/exam/user/manager/result', formP, res => {
-			// 				uni.navigateTo({
-			// 					url:'/pages/scoreQuery/scoreQuery?paperId='+ this.paperId+'&admissionNo='+this.testNumber
-			// 				})
-			// 		});
-			// 	}
-			// });
 		},
 		// 验证提交
 		yanzhengSubmit(){

+ 25 - 10
pages/test/test.vue

@@ -5,8 +5,8 @@
 			<view style="width: 1200px;margin: auto;">{{paper.title}}</view>
 		</view>
 		
-		<view class="video-box" id="video-box" @click="takePhoto">
-			<video id="video" style="width: 100%;height: 100%;" :autoplay="true" :controls="true" :show-center-play-btn="false"></video>
+		<view class="video-box" id="video-box" @click="takePhoto" v-show="showVideo">
+			<video id="video" style="width: 100%;height: 100%;" :autoplay="true" :controls="false" :show-center-play-btn="false"></video>
 			<canvas id="canvas" style="width: 100%;height: 100%;"  canvas-id="canvas"></canvas>
 		</view>
 		<img  :src="imgUrl" ></img>
@@ -195,7 +195,6 @@
 				isGoBack: false,
 				isShowView: false,
 				
-				isClearLogin:true,//是否离开页面清除缓存
 				
 				result:null,//考试结果
 				
@@ -203,7 +202,8 @@
 				video:{src:null},
 				canvas:null,
 				ctx:null,
-				imgUrl:null
+				imgUrl:null,
+				showVideo:false
 			}
 		},
 		onReady() {},
@@ -215,10 +215,10 @@
 			await this.getQuests();
 			
 			// 摄像头
-			const query = uni.createSelectorQuery().in(this);
-			this.video = query.select('#video')
-			this.canvas = query.select('#canvas');
-			this.test()
+			// const query = uni.createSelectorQuery().in(this);
+			// this.video = query.select('#video')
+			// this.canvas = query.select('#canvas');
+			// this.test()
 			
 			
 			// 考生信息
@@ -228,7 +228,6 @@
 			// this.getQuests();
 		},
 		onUnload() {
-			if(this.isClearLogin)
 				uni.clearStorageSync();
 		},
 		methods: {
@@ -304,6 +303,22 @@
 							}
 							_ts.quests = quests;
 							r()
+						}else{
+							uni.showModal({
+								title:'提示',
+								content:'您已参加过该考试',
+								showCancel:false,
+								success(res) {
+									if(res.confirm){
+										uni.reLaunch({
+											url:'/pages/login/login',
+											success() {
+												console.log('您已参加过该考试')
+											}
+										})
+									}
+								}
+							})
 						}
 					})
 				})
@@ -558,7 +573,6 @@
 					dataP,
 					res => {
 						if (!_ts.paper.isScore) {//手动阅卷
-							_ts.isClearLogin = false
 							uni.redirectTo({
 								url:'/pages/scoreQuery/scoreQuery?paperId='+ _ts.paperId+'&admissionNo='+_ts.userInfo.admissionNo
 							})
@@ -701,6 +715,7 @@
 						that.video.src = window.URL && window.URL.createObjectURL(stream) || stream
 				    }
 				    video.play();
+					that.showVideo = true
 				}).catch(function (err) {
 				    console.log(err)
 					uni.showModal({