From e28c8bb6f17ee0ac22f551abe82ce441b67a8c86 Mon Sep 17 00:00:00 2001 From: zhoulinf <2507241354@qq.com> Date: Tue, 4 Aug 2026 19:15:28 +0800 Subject: [PATCH] =?UTF-8?q?CRM=5F26-08-05#story#9126,=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=80=81=E6=9C=8D=E5=8A=A1=E5=95=86=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CameraGuide.vue | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/components/CameraGuide.vue b/src/components/CameraGuide.vue index ff039889..790940e3 100644 --- a/src/components/CameraGuide.vue +++ b/src/components/CameraGuide.vue @@ -2,8 +2,6 @@
- -
{{ navTitle }} @@ -34,6 +32,8 @@
+ +
@@ -61,15 +61,6 @@
车辆照片
- - - - - - - - -
@@ -219,10 +210,24 @@ export default { this.$toast('相机尚未就绪,请稍候') return } + // 按取景框比例(约 1.43:1)从视频中心裁剪,与框内可视区域(object-fit: cover)保持一致 + const frameAspect = 1.43 + const vw = video.videoWidth + const vh = video.videoHeight + let sw, sh + if (vw / vh > frameAspect) { + sh = vh + sw = Math.round(vh * frameAspect) + } else { + sw = vw + sh = Math.round(vw / frameAspect) + } + const sx = Math.round((vw - sw) / 2) + const sy = Math.round((vh - sh) / 2) const canvas = document.createElement('canvas') - canvas.width = video.videoWidth - canvas.height = video.videoHeight - canvas.getContext('2d').drawImage(video, 0, 0) + canvas.width = sw + canvas.height = sh + canvas.getContext('2d').drawImage(video, sx, sy, sw, sh, 0, 0, sw, sh) const dataURL = canvas.toDataURL('image/jpeg', 0.92) canvas.toBlob(blob => { if (!blob) {