Selaa lähdekoodia

补充阿里云SLS日志:活体检测流程

Michael Wang 5 vuotta sitten
vanhempi
commit
b2cc28bf53
1 muutettua tiedostoa jossa 24 lisäystä ja 20 poistoa
  1. 24 20
      src/features/OnlineExam/Examing/FaceId.vue

+ 24 - 20
src/features/OnlineExam/Examing/FaceId.vue

@@ -111,11 +111,7 @@ export default {
       page: "活体检测弹出框",
       action: "关闭框",
     });
-    try {
-      if (this.ws && this.ws.readyState === 1) this.ws.close();
-    } catch (e) {
-      console.log("关闭ws异常。");
-    }
+    this.closeWS();
     clearTimeout(this.faceIdTimeout);
     clearInterval(this.timeCountInterval);
     clearTimeout(this.iframeDomReadyTimeout);
@@ -168,7 +164,7 @@ export default {
             clearTimeout(this.faceIdTimeout);
             clearInterval(this.timeCountInterval);
             this.$emit("closeFaceId");
-            this.closeWS();
+            // this.closeWS();
           })
           .catch(() => {
             shouldTimeout = true;
@@ -240,16 +236,6 @@ export default {
       this.ws.onmessage = response => {
         console.log("faceid websocket response: ", response);
         if (response.data.indexOf("verifyResult") > -1) {
-          this.haveReceivedMsg = true;
-          var receivedMsgData = JSON.parse(response.data);
-          var receivedMsg = JSON.parse(receivedMsgData.content.returnMsgJson);
-          // 两个结束点。第二个结束点:从websocket得到消息。
-          this.faceTestEnd(receivedMsg);
-          clearTimeout(this.faceIdTimeout);
-          clearInterval(this.timeCountInterval);
-          this.$emit("closeFaceId");
-          this.closeWS();
-
           window._hmt.push([
             "_trackEvent",
             "活体检测弹出框",
@@ -259,6 +245,16 @@ export default {
             page: "活体检测弹出框",
             action: "websocket得到消息",
           });
+          this.haveReceivedMsg = true;
+          var receivedMsgData = JSON.parse(response.data);
+          var receivedMsg = JSON.parse(receivedMsgData.content.returnMsgJson);
+          // 两个结束点。第二个结束点:从websocket得到消息。
+          this.faceTestEnd(receivedMsg);
+          clearTimeout(this.faceIdTimeout);
+          clearInterval(this.timeCountInterval);
+          this.$emit("closeFaceId");
+          // 无需关闭,在beforeDestory会关闭
+          // this.closeWS();
         }
       };
 
@@ -305,7 +301,10 @@ export default {
     },
     closeWS() {
       try {
-        if (this.ws && this.ws.readyState === 1) this.ws.close();
+        if (this.ws && this.ws.readyState === 1) {
+          this.logger({ page: "活体检测弹出框", action: "准备关闭websocket" });
+          this.ws.close();
+        }
       } catch (e) {
         console.log("关闭ws异常。");
         window._hmt.push([
@@ -392,6 +391,11 @@ export default {
      * 指定动作检测结果返回后台处理
      */
     faceTestUploadResult(result) {
+      this.logger({
+        page: "活体检测弹出框",
+        action: "上传活体检测结果",
+        result,
+      });
       return this.$http
         .get(
           "/api/ecs_oe_student/examFaceLivenessVerify/faceLivenessVerifyEnd/" +
@@ -401,12 +405,12 @@ export default {
         )
         .then(() => {
           if (result != "SUCCESS") {
-            this.logout("?LogoutReason=活体检测失败");
             window._hmt.push(["_trackEvent", "活体检测弹出框", "活体检测失败"]);
             this.logger({
               page: "活体检测弹出框",
-              action: "活体检测失败",
+              action: "活体检测失败-退出登录",
             });
+            this.logout("?LogoutReason=活体检测失败");
           } else {
             window._hmt.push(["_trackEvent", "活体检测弹出框", "活体检测成功"]);
             this.logger({
@@ -428,7 +432,7 @@ export default {
           ]);
           this.logger({
             page: "活体检测弹出框",
-            action: "上传指定动作检测结果出错!",
+            action: "上传指定动作检测结果出错!--退出登录",
           });
           console.log("上传指定动作检测结果出错!");
           this.logout("?LogoutReason=上传指定动作检测结果出错!");