From a67deea0f1d84dbabcdf92055013b9487a18eed7 Mon Sep 17 00:00:00 2001 From: haomingming Date: Wed, 17 Sep 2025 12:10:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- case/pages/createCase/createCase.js | 14 +++++++++++ components/image-cropper/image-cropper.js | 4 +-- components/paintCanvas/paintCanvas.wxml | 1 - project.config.json | 3 ++- utils/utils.js | 30 +++++++++++++++++++---- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/case/pages/createCase/createCase.js b/case/pages/createCase/createCase.js index b5bd0a3..832b2b3 100644 --- a/case/pages/createCase/createCase.js +++ b/case/pages/createCase/createCase.js @@ -2263,8 +2263,22 @@ Page({ }) const {imgSrc,name}=e.detail console.log(e); + // this.getFileSize(imgSrc) this.uploadImg(imgSrc,name) }, + // 获取临时文件大小 + getFileSize(filePath) { + wx.getFileInfo({ + filePath: filePath, + success: (res) => { + console.log('文件大小:', res.size/1024); + }, + fail: (err) => { + console.error('获取文件信息失败:', err); + wx.showToast({ title: '获取文件大小失败', icon: 'none' }); + } + }); + }, afterRead(event) { console.log( event.detail) const { file,name} = event.detail; diff --git a/components/image-cropper/image-cropper.js b/components/image-cropper/image-cropper.js index 06a6383..e9b45c8 100644 --- a/components/image-cropper/image-cropper.js +++ b/components/image-cropper/image-cropper.js @@ -310,7 +310,7 @@ Component({ height: Math.round(this.data.height * this.data.export_scale), destWidth: this.data.width * this.data.export_scale, destHeight: Math.round(this.data.height) * this.data.export_scale, - fileType: 'png', + fileType: 'jpg', quality: this.data.quality, canvasId: this.data.el, success: (res) => { @@ -849,7 +849,7 @@ Component({ height: Math.round(this.data.height * this.data.export_scale), destWidth: this.data.width * this.data.export_scale, destHeight: Math.round(this.data.height) * this.data.export_scale, - fileType: 'png', + fileType: 'jpg', quality: this.data.quality, canvasId: this.data.el, success: (res) => { diff --git a/components/paintCanvas/paintCanvas.wxml b/components/paintCanvas/paintCanvas.wxml index f630333..9d2d7b3 100644 --- a/components/paintCanvas/paintCanvas.wxml +++ b/components/paintCanvas/paintCanvas.wxml @@ -2,7 +2,6 @@ - { + console.log('文件信息:', res); + console.log('文件大小:', res.size/1024); + }, + fail: (err) => { + console.error('获取文件信息失败:', err); + wx.showToast({ title: '获取文件大小失败', icon: 'none' }); + } + }); +} function _canvaseSaveToImg(_this,from,isSmall) { let that=_this; console.log(from) @@ -186,7 +206,7 @@ function formatTime(date) { setTimeout(()=>{ wx.canvasToTempFilePath({ canvasId: 'myCanvas', - fileType:'png', + fileType:'jpg', quality:isSmall?0.8:1, success: function (res) { // wx.previewImage({