|
@@ -90,6 +90,9 @@ export default {
|
|
this.examRecordId = this.$route.params.examRecordDataId;
|
|
this.examRecordId = this.$route.params.examRecordDataId;
|
|
console.debug("startFaceVerify");
|
|
console.debug("startFaceVerify");
|
|
window._hmt.push(["_trackEvent", "活体检测弹出框", "弹出框"]);
|
|
window._hmt.push(["_trackEvent", "活体检测弹出框", "弹出框"]);
|
|
|
|
+ // open websocket
|
|
|
|
+ this.openWebsocketToStartFaceIDTest();
|
|
|
|
+
|
|
this.startFaceVerify();
|
|
this.startFaceVerify();
|
|
if (typeof nodeRequire != "undefined") {
|
|
if (typeof nodeRequire != "undefined") {
|
|
// console.log(nodeRequire("electron").remote.app);
|
|
// console.log(nodeRequire("electron").remote.app);
|
|
@@ -126,8 +129,37 @@ export default {
|
|
{ params: { errorMsg: errorMsg } }
|
|
{ params: { errorMsg: errorMsg } }
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- faceidLoadedButTimeouted() {
|
|
|
|
- this.ws.close();
|
|
|
|
|
|
+ async faceidLoadedButTimeouted() {
|
|
|
|
+ this.closeWS();
|
|
|
|
+ let shouldTimeout = true;
|
|
|
|
+
|
|
|
|
+ if (!this.haveReceivedMsg) {
|
|
|
|
+ await this.$http
|
|
|
|
+ .get(
|
|
|
|
+ "/api/ecs_oe_student/examFaceLivenessVerify/getFaceVerifyResult/" +
|
|
|
|
+ this.faceVerifyId
|
|
|
|
+ )
|
|
|
|
+ .then(response => {
|
|
|
|
+ window._hmt.push([
|
|
|
|
+ "_trackEvent",
|
|
|
|
+ "活体检测弹出框",
|
|
|
|
+ "60秒超时非websocket处理结果",
|
|
|
|
+ ]);
|
|
|
|
+ var receivedMsg = response.data;
|
|
|
|
+ shouldTimeout = false;
|
|
|
|
+ return this.faceTestEnd(receivedMsg);
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ shouldTimeout = true;
|
|
|
|
+ window._hmt.push([
|
|
|
|
+ "_trackEvent",
|
|
|
|
+ "活体检测弹出框",
|
|
|
|
+ "60秒超时非websocket处理结果--api失败",
|
|
|
|
+ ]);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (!shouldTimeout) return;
|
|
|
|
+
|
|
let faceTestEndCalled = false;
|
|
let faceTestEndCalled = false;
|
|
this.$http
|
|
this.$http
|
|
.get(
|
|
.get(
|
|
@@ -172,13 +204,14 @@ export default {
|
|
this.ws.onmessage = response => {
|
|
this.ws.onmessage = response => {
|
|
console.log("faceid websocket response: ", response);
|
|
console.log("faceid websocket response: ", response);
|
|
if (response.data.indexOf("verifyResult") > -1) {
|
|
if (response.data.indexOf("verifyResult") > -1) {
|
|
|
|
+ this.haveReceivedMsg = true;
|
|
var receivedMsg = JSON.parse(response.data);
|
|
var receivedMsg = JSON.parse(response.data);
|
|
// 两个结束点。第二个结束点:从websocket得到消息。
|
|
// 两个结束点。第二个结束点:从websocket得到消息。
|
|
this.faceTestEnd(receivedMsg);
|
|
this.faceTestEnd(receivedMsg);
|
|
clearTimeout(this.faceIdTimeout);
|
|
clearTimeout(this.faceIdTimeout);
|
|
clearInterval(this.timeCountInterval);
|
|
clearInterval(this.timeCountInterval);
|
|
this.$emit("closeFaceId");
|
|
this.$emit("closeFaceId");
|
|
- this.ws.close();
|
|
|
|
|
|
+ this.closeWS();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -192,9 +225,29 @@ export default {
|
|
"活体检测弹出框",
|
|
"活体检测弹出框",
|
|
"websocket连接失败",
|
|
"websocket连接失败",
|
|
]);
|
|
]);
|
|
|
|
+ if (!this.haveReceivedMsg) {
|
|
|
|
+ this.ws = new WebSocket(VUE_APP_WK_SERVER_SOCKET + this.examRecordId);
|
|
|
|
+ window._hmt.push([
|
|
|
|
+ "_trackEvent",
|
|
|
|
+ "活体检测弹出框",
|
|
|
|
+ "websocket重新连接",
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
// this.showRedo("websocket连接异常,请手动点击重试");
|
|
// this.showRedo("websocket连接异常,请手动点击重试");
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ closeWS() {
|
|
|
|
+ try {
|
|
|
|
+ if (this.ws && this.ws.readyState === 1) this.ws.close();
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log("关闭ws异常。");
|
|
|
|
+ window._hmt.push([
|
|
|
|
+ "_trackEvent",
|
|
|
|
+ "活体检测弹出框",
|
|
|
|
+ "关闭websocket异常",
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 人脸检测结束
|
|
* 人脸检测结束
|
|
*/
|
|
*/
|
|
@@ -304,9 +357,6 @@ export default {
|
|
this.faceIdTimeout = setTimeout(() => {
|
|
this.faceIdTimeout = setTimeout(() => {
|
|
this.faceidLoadedButTimeouted();
|
|
this.faceidLoadedButTimeouted();
|
|
}, 60000); //60000
|
|
}, 60000); //60000
|
|
-
|
|
|
|
- // open websocket
|
|
|
|
- this.openWebsocketToStartFaceIDTest();
|
|
|
|
},
|
|
},
|
|
async startFaceVerify() {
|
|
async startFaceVerify() {
|
|
this.redoBtnDisabled = true;
|
|
this.redoBtnDisabled = true;
|
|
@@ -314,10 +364,18 @@ export default {
|
|
|
|
|
|
let response = null;
|
|
let response = null;
|
|
try {
|
|
try {
|
|
- response = await this.$http.get(
|
|
|
|
- "/api/ecs_oe_student/examFaceLivenessVerify/getFaceLivenessVerifyToken/" +
|
|
|
|
- this.examRecordId
|
|
|
|
- );
|
|
|
|
|
|
+ if (this.faceVerifyId) {
|
|
|
|
+ response = await this.$http.get(
|
|
|
|
+ "/api/ecs_oe_student/examFaceLivenessVerify/getFaceVerifyToken/" +
|
|
|
|
+ this.faceVerifyId
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ response = await this.$http.get(
|
|
|
|
+ "/api/ecs_oe_student/examFaceLivenessVerify/startFaceVerify/" +
|
|
|
|
+ this.examRecordId
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ this.faceVerifyId = response.data.faceVerifyId;
|
|
} catch (error) {
|
|
} catch (error) {
|
|
this.$Message.error({
|
|
this.$Message.error({
|
|
content: "获取底照token失败,请重新登录!",
|
|
content: "获取底照token失败,请重新登录!",
|