Forráskód Böngészése

人脸比对提示信息优化

Michael Wang 6 éve
szülő
commit
2073d450ac

+ 6 - 3
src/components/FaceRecognition/FaceRecognition.vue

@@ -3,7 +3,7 @@
     <video id="video" ref="video" :width="width" :height="height" autoplay>
     </video>
     <div v-if="showRecognizeButton" style="position: absolute; width: 400px; text-align: center; margin-top: -50px; color: #232323;">
-      <span class="verify-button" @click="snap">开始识别</span>
+      <span class="verify-button" @click="snap">{{msg}}</span>
     </div>
   </div>
 </template>
@@ -17,7 +17,7 @@ import { UPYUN_URL } from "../../constants/constants.js";
 export default {
   name: "FaceRecognition",
   data() {
-    return { hide: true };
+    return { hide: true, msg: "开始识别" };
   },
   props: {
     width: String,
@@ -60,7 +60,7 @@ export default {
         try {
           console.log("启动摄像头");
           const stream = await navigator.mediaDevices.getUserMedia({
-            video: { facingMode: "user" }
+            video: { facingMode: "user", width: 400, height: 300 }
           });
 
           video.srcObject = stream;
@@ -83,8 +83,11 @@ export default {
       video && video.play();
     },
     async snap() {
+      this.msg = "拍照中...";
       const captureBlob = await this.getSnapShot();
+      this.msg = "上传照片中...";
       const [, captureFilePath] = await this.uploadToServer(captureBlob);
+      this.msg = "人脸比对中...";
       await this.faceCompareSync(UPYUN_URL + captureFilePath);
       const video = this.$refs.video;
       video && video.play();

+ 3 - 6
src/features/OnlineExam/OnlineExamFaceCheckModal.vue

@@ -57,12 +57,6 @@ export default {
       this.userPhoto = this.userPhoto;
     }
 
-    // const sysRes = await this.$http.get("/api/sys_param", {
-    //   params: {
-    //     orgId: this.$store.state.user.rootOrgId
-    //   }
-    // });
-
     // // FIXME: 将faceEnable和faceCheck放到global的state中
     // this.faceEnable = sysRes.data.faceEnable; // 模拟练习?
     // this.faceCheck = sysRes.data.faceCheck; // 考试
@@ -86,6 +80,9 @@ export default {
         return;
       }
       this.toggleFaceCheckModal(false);
+      if (!pass) {
+        this.$Message.error("人脸比对失败");
+      }
       if (!pass && this.course.faceCheck) {
         this.$Modal.confirm({
           title: "郑重承诺",