|
@@ -76,15 +76,21 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async snapTimer() {
|
|
|
- const examRecordDataId = this.$route.params.examRecordDataId;
|
|
|
- const captureBlob = await this.getSnapShot();
|
|
|
- const [fileName, captureFilePath] = await this.uploadToServer(
|
|
|
- captureBlob
|
|
|
- );
|
|
|
- await this.faceCompare(fileName, captureFilePath, examRecordDataId);
|
|
|
- this.decreaseSnapCount();
|
|
|
- const video = this.$refs.video;
|
|
|
- video && video.play();
|
|
|
+ try {
|
|
|
+ const examRecordDataId = this.$route.params.examRecordDataId;
|
|
|
+ const captureBlob = await this.getSnapShot();
|
|
|
+ const [fileName, captureFilePath] = await this.uploadToServer(
|
|
|
+ captureBlob
|
|
|
+ );
|
|
|
+ await this.faceCompare(fileName, captureFilePath, examRecordDataId);
|
|
|
+ } catch (error) {
|
|
|
+ // FIXME: more processing
|
|
|
+ console.log("定时抓拍流程失败");
|
|
|
+ } finally {
|
|
|
+ const video = this.$refs.video;
|
|
|
+ video && video.play();
|
|
|
+ this.decreaseSnapCount();
|
|
|
+ }
|
|
|
},
|
|
|
async snap() {
|
|
|
// TODO: chrome 70. FaceDetector检测人脸
|
|
@@ -98,17 +104,24 @@ export default {
|
|
|
// const v = await f.detect(canvas);
|
|
|
// console.log(v);
|
|
|
// return;
|
|
|
- this.disableSnap = true;
|
|
|
- this.msg = "拍照中...";
|
|
|
- const captureBlob = await this.getSnapShot();
|
|
|
- this.msg = "上传照片中...";
|
|
|
- const [, captureFilePath] = await this.uploadToServer(captureBlob);
|
|
|
- this.msg = "人脸比对中...";
|
|
|
- await this.faceCompareSync(captureFilePath);
|
|
|
- const video = this.$refs.video;
|
|
|
- video && video.play();
|
|
|
- this.msg = "开始识别";
|
|
|
- this.disableSnap = false;
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.disableSnap = true;
|
|
|
+ this.msg = "拍照中...";
|
|
|
+ const captureBlob = await this.getSnapShot();
|
|
|
+ this.msg = "上传照片中...";
|
|
|
+ const [, captureFilePath] = await this.uploadToServer(captureBlob);
|
|
|
+ this.msg = "人脸比对中...";
|
|
|
+ await this.faceCompareSync(captureFilePath);
|
|
|
+ } catch (error) {
|
|
|
+ // FIXME: more processing
|
|
|
+ console.log("同步照片比对流程失败");
|
|
|
+ } finally {
|
|
|
+ const video = this.$refs.video;
|
|
|
+ video && video.play();
|
|
|
+ this.msg = "开始识别";
|
|
|
+ this.disableSnap = false;
|
|
|
+ }
|
|
|
},
|
|
|
async getSnapShot() {
|
|
|
return new Promise(resolve => {
|
|
@@ -136,13 +149,18 @@ export default {
|
|
|
});
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
- this.$Message.error(e.message);
|
|
|
- return;
|
|
|
+ this.$Message.error("保存抓拍照片到又拍云失败!");
|
|
|
+ throw "保存抓拍照片到又拍云失败!";
|
|
|
}
|
|
|
|
|
|
- const UPYUN_URL = (await this.$http.get("/api/ecs_oe_student_face/upyun"))
|
|
|
- .data.downloadPrefix;
|
|
|
-
|
|
|
+ let UPYUN_URL;
|
|
|
+ try {
|
|
|
+ UPYUN_URL = (await this.$http.get("/api/ecs_oe_student_face/upyun"))
|
|
|
+ .data.downloadPrefix;
|
|
|
+ } catch (error) {
|
|
|
+ this.$Message.error("获取又拍云下载前缀失败!");
|
|
|
+ throw "获取又拍云下载前缀失败!";
|
|
|
+ }
|
|
|
return [
|
|
|
fileName,
|
|
|
UPYUN_URL + "/capture_photo/" + this.user.userId + "/" + fileName
|
|
@@ -164,7 +182,7 @@ export default {
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
// this.$Message.error(e.message);
|
|
|
- return;
|
|
|
+ throw "同步照片比较失败!";
|
|
|
}
|
|
|
},
|
|
|
async faceCompare(fileName, captureFilePath, examRecordDataId) {
|
|
@@ -177,11 +195,15 @@ export default {
|
|
|
"&examRecordDataId=" +
|
|
|
examRecordDataId
|
|
|
);
|
|
|
- await this.showSnapResult(fileName, examRecordDataId);
|
|
|
+ try {
|
|
|
+ await this.showSnapResult(fileName, examRecordDataId);
|
|
|
+ } catch (error) {
|
|
|
+ this.$Message.error("设置获取抓拍结果失败!");
|
|
|
+ }
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
this.$Message.error(e.message);
|
|
|
- return;
|
|
|
+ throw "异步比较抓拍照片失败";
|
|
|
}
|
|
|
},
|
|
|
async showSnapResult(fileName, examRecordDataId) {
|
|
@@ -213,6 +235,7 @@ export default {
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
this.$Message.error(e.message);
|
|
|
+ throw e.message;
|
|
|
}
|
|
|
}
|
|
|
},
|