Browse Source

刷新获取用户信息;修复人脸比对的流程

Michael Wang 6 năm trước cách đây
mục cha
commit
6c3e4fe69d

+ 3 - 1
src/features/Login/Login.vue

@@ -49,6 +49,7 @@
 
 <script>
 import moment from "moment";
+import { mapMutations } from "vuex";
 /**
  * 在任何组件需要强制退出,做以下步骤
  * 1. this.$Message.info()
@@ -98,6 +99,7 @@ export default {
     window.localStorage.removeItem("key");
   },
   methods: {
+    ...mapMutations(["updateUser"]),
     async login(name) {
       const valid = await this.$refs[name].validate();
       if (valid) {
@@ -129,7 +131,7 @@ export default {
           const student = (await this.$http.get(
             "/api/ecs_core/student/getStudentInfoBySession"
           )).data;
-          this.$store.state.user = { ...data, ...student };
+          this.updateUser({ ...data, ...student });
           this.$router.push("/online-exam");
         } else {
           this.errorInfo = data.desc;

+ 18 - 2
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -15,7 +15,7 @@
         <QuestionNavView :paperStruct="paperStruct" />
       </div>
       <div class="camera">
-        <!-- <FaceRecognition width="100%" height="100%" :showRecognizeButton="false" /> -->
+        <FaceRecognition v-if="faceEnable" width="100%" height="100%" :showRecognizeButton="false" />
       </div>
     </div>
     <Modal v-if="showFaceId" v-model="showFaceId" :mask-closable="false" :closable="false">
@@ -41,7 +41,7 @@ const { mapState, mapMutations } = createNamespacedHelpers("examingHomeModule");
 export default {
   name: "ExamingHome",
   data() {
-    return { showFaceId: false };
+    return { showFaceId: false, faceEnable: false };
   },
   created() {
     this.initData();
@@ -55,6 +55,22 @@ export default {
       this.toggleSnapNow();
     }, 60 * 1000); // 一分钟后抓拍
 
+    this.$http
+      .get(
+        "/api/ecs_exam_work/exam/examOrgProperty/" +
+          this.$route.params.examId +
+          `/IS_FACE_ENABLE`
+      )
+      .then(res => {
+        // console.log(res);
+        if (res.data) {
+          this.faceEnable = true;
+        }
+      })
+      .catch(reason => {
+        this.$Message.error(reason);
+      });
+
     this.$http
       .get(
         "/api/ecs_exam_work/exam/examOrgProperty/" +

+ 13 - 13
src/features/OnlineExam/OnlineExamFaceCheckModal.vue

@@ -78,19 +78,19 @@ export default {
       this.toggleFaceCheckModal(false);
       if (!pass) {
         this.$Message.error("人脸比对失败");
-      }
-      if (!pass && this.course.faceCheck) {
-        this.$Modal.confirm({
-          title: "郑重承诺",
-          content:
-            "我承诺由本人参加考试,并且同意接受考试监控系统信息审核,一经发现作弊,立即取消本门课程考试成绩。",
-          onOk: () =>
-            this.$router.push(
-              `/online-exam/exam/${this.course.examId}/overview?examStudentId=${
-                this.course.examStudentId
-              }`
-            )
-        });
+        if (!this.course.faceCheck) {
+          this.$Modal.confirm({
+            title: "郑重承诺",
+            content:
+              "我承诺由本人参加考试,并且同意接受考试监控系统信息审核,一经发现作弊,立即取消本门课程考试成绩。",
+            onOk: () =>
+              this.$router.push(
+                `/online-exam/exam/${
+                  this.course.examId
+                }/overview?examStudentId=${this.course.examStudentId}`
+              )
+          });
+        }
         return;
       }
       this.$router.push(

+ 6 - 2
src/features/OnlineExam/OnlineExamList.vue

@@ -75,9 +75,13 @@ export default {
         //    让学生手动确认进入考试,若取消,则返回
         this.selectedCourse = course;
         this.toggleFaceCheckModal(true);
+      } else {
+        this.$router.push(
+          `/online-exam/exam/${course.examId}/overview?examStudentId=${
+            course.examStudentId
+          }`
+        );
       }
-
-      // this.$router.push("/online-exam/exam/:id/overview")
     },
     // eslint-disable-next-line
     async faceCheckResultCallback(course, faceMatched) {

+ 7 - 6
src/store.js

@@ -71,17 +71,18 @@ const examingHomeModule = {
   }
 };
 
-let initUser = {};
-if (process.env.NODE_ENV !== "production") {
-  const userStr = window.localStorage.getItem("user-for-dev");
-  initUser = JSON.parse(userStr);
-}
+const userStr = window.localStorage.getItem("user-for-dev");
+const initUser = userStr ? JSON.parse(userStr) : {};
 
 export default new Vuex.Store({
   state: {
     user: initUser
   },
-  mutations: {},
+  mutations: {
+    updateUser(state, payload) {
+      state = Object.assign(state, { user: payload });
+    }
+  },
   actions: {},
   modules: {
     examHomeModule,