|
@@ -93,10 +93,8 @@ export default {
|
|
const examRecordDataId = this.$route.params.examRecordDataId;
|
|
const examRecordDataId = this.$route.params.examRecordDataId;
|
|
const captureBlob = await this.getSnapShot();
|
|
const captureBlob = await this.getSnapShot();
|
|
// console.log(captureBlob.size);
|
|
// console.log(captureBlob.size);
|
|
- const [fileName, captureFilePath] = await this.uploadToServer(
|
|
|
|
- captureBlob
|
|
|
|
- );
|
|
|
|
- await this.faceCompare(fileName, captureFilePath, examRecordDataId);
|
|
|
|
|
|
+ const captureFilePath = await this.uploadToServer(captureBlob);
|
|
|
|
+ await this.faceCompare(captureFilePath, examRecordDataId);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
// FIXME: more processing
|
|
// FIXME: more processing
|
|
console.log("定时抓拍流程失败");
|
|
console.log("定时抓拍流程失败");
|
|
@@ -133,7 +131,7 @@ export default {
|
|
this.msg = "拍照中...";
|
|
this.msg = "拍照中...";
|
|
const captureBlob = await this.getSnapShot();
|
|
const captureBlob = await this.getSnapShot();
|
|
this.msg = "上传照片中...";
|
|
this.msg = "上传照片中...";
|
|
- const [, captureFilePath] = await this.uploadToServer(captureBlob);
|
|
|
|
|
|
+ const captureFilePath = await this.uploadToServer(captureBlob);
|
|
this.msg = "人脸比对中...";
|
|
this.msg = "人脸比对中...";
|
|
await this.faceCompareSync(captureFilePath);
|
|
await this.faceCompareSync(captureFilePath);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -164,38 +162,38 @@ export default {
|
|
var context = canvas.getContext("2d");
|
|
var context = canvas.getContext("2d");
|
|
context.drawImage(video, 0, 0, 220, 165);
|
|
context.drawImage(video, 0, 0, 220, 165);
|
|
|
|
|
|
- canvas.toBlob(resolve);
|
|
|
|
|
|
+ canvas.toBlob(resolve, "image/jpeg", 0.95);
|
|
video.play();
|
|
video.play();
|
|
});
|
|
});
|
|
},
|
|
},
|
|
async uploadToServer(captureBlob) {
|
|
async uploadToServer(captureBlob) {
|
|
- //保存抓拍照片到又拍云
|
|
|
|
- var fileName = new Date().getTime() + ".jpg";
|
|
|
|
- var fileUrl = "/capture_photo/" + this.user.userId + "/" + fileName;
|
|
|
|
|
|
+ //保存抓拍照片到服务器
|
|
|
|
+ // var fileName = new Date().getTime() + ".png";
|
|
|
|
+ // var fileUrl = "/api/exchange/inner/upyun/put/capturePhoto/" + fileName;
|
|
|
|
+ var fileUrl = "/api/exchange/inner/upyun/put/capturePhoto/jpg";
|
|
|
|
+ let resultUrl;
|
|
try {
|
|
try {
|
|
- await this.$upyunhttp.put(fileUrl, captureBlob, {
|
|
|
|
|
|
+ const res = await this.$http.put(fileUrl, captureBlob, {
|
|
headers: {
|
|
headers: {
|
|
- "Content-Type": "image/jpeg"
|
|
|
|
|
|
+ "Content-Type": "image/jpg"
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ resultUrl = res.data;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e);
|
|
console.log(e);
|
|
- this.$Message.error("保存抓拍照片到又拍云失败!");
|
|
|
|
- throw "保存抓拍照片到又拍云失败!";
|
|
|
|
|
|
+ this.$Message.error("保存抓拍照片到服务器失败!");
|
|
|
|
+ throw "保存抓拍照片到服务器失败!";
|
|
}
|
|
}
|
|
|
|
|
|
- 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
|
|
|
|
- ];
|
|
|
|
|
|
+ // 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 resultUrl;
|
|
},
|
|
},
|
|
async faceCompareSync(captureFilePath) {
|
|
async faceCompareSync(captureFilePath) {
|
|
try {
|
|
try {
|
|
@@ -216,16 +214,15 @@ export default {
|
|
throw "同步照片比较失败!";
|
|
throw "同步照片比较失败!";
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async faceCompare(fileName, captureFilePath, examRecordDataId) {
|
|
|
|
|
|
+ async faceCompare(captureFilePath, examRecordDataId) {
|
|
try {
|
|
try {
|
|
- await this.$http.post(
|
|
|
|
|
|
+ const res = await this.$http.post(
|
|
"/api/ecs_oe_student_face/examCaptureQueue/uploadExamCapture?fileUrl=" +
|
|
"/api/ecs_oe_student_face/examCaptureQueue/uploadExamCapture?fileUrl=" +
|
|
captureFilePath +
|
|
captureFilePath +
|
|
- "&fileName=" +
|
|
|
|
- fileName +
|
|
|
|
"&examRecordDataId=" +
|
|
"&examRecordDataId=" +
|
|
examRecordDataId
|
|
examRecordDataId
|
|
);
|
|
);
|
|
|
|
+ const fileName = res.data;
|
|
try {
|
|
try {
|
|
await this.showSnapResult(fileName, examRecordDataId);
|
|
await this.showSnapResult(fileName, examRecordDataId);
|
|
} catch (error) {
|
|
} catch (error) {
|