From 24c81b5bfe2b1d8abf156fbf8cb8753d508b6643 Mon Sep 17 00:00:00 2001 From: ShenQiLun <97694732@qq.com> Date: Thu, 25 Jun 2026 18:06:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=94=B9=E7=94=A8takePhotoSnapshot?= =?UTF-8?q?=E6=8B=8D=E9=A2=84=E8=A7=88=E5=8C=BA=E5=9F=9F,=E4=B8=8E?= =?UTF-8?q?=E5=8F=96=E6=99=AF=E6=A1=86=E6=89=80=E8=A7=81=E5=8D=B3=E6=89=80?= =?UTF-8?q?=E5=BE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/camera_capture.nvue | 44 ++------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/pages/upload/camera_capture.nvue b/pages/upload/camera_capture.nvue index 2dc44b2..2a64b78 100644 --- a/pages/upload/camera_capture.nvue +++ b/pages/upload/camera_capture.nvue @@ -130,7 +130,7 @@ uni.showToast({ title: '相机未就绪', icon: 'none' }) return } - this.$refs.cameraRef.takePhoto() + this.$refs.cameraRef.takePhotoSnapshot() }, onPictureTaken(e) { var path = '' @@ -138,49 +138,9 @@ path = e.detail.path || '' } if (path) { - this.resizeToSquare(path) + this.capturedList.push(path) } }, - // 裁剪为 1080×1080 正方形 - resizeToSquare(srcPath) { - var that = this - uni.getImageInfo({ - src: srcPath, - success: function(info) { - var w = info.width - var h = info.height - // 居中裁剪正方形 - var size = Math.min(w, h) - var clipX = Math.floor((w - size) / 2) - var clipY = Math.floor((h - size) / 2) - // 使用 5+ 原生压缩 API 裁剪 + 缩放到 1080x1080 - plus.zip.compressImage({ - src: srcPath, - dst: '_doc/resize_' + Date.now() + '.jpg', - width: '1080', - height: '1080', - quality: 90, - overwrite: true, - clip: { - x: clipX, - y: clipY, - width: size, - height: size - } - }, - function(res) { - that.capturedList.push(res.target) - }, - function() { - // 失败时用原始路径 - that.capturedList.push(srcPath) - }) - }, - fail: function() { - that.capturedList.push(srcPath) - } - }) - }, flipCamera() { this.facing = this.facing === 'back' ? 'front' : 'back' this.$refs.cameraRef.changeFacing(this.facing)