From 530ba15f95e205dfe6a5b87f9eced44009f0af2a Mon Sep 17 00:00:00 2001 From: jinna Date: Tue, 21 Jan 2025 11:27:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E7=89=87=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E4=B8=BA=E9=99=90=E5=88=B65M=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/components/requestSub.vue | 70 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/views/components/requestSub.vue b/src/views/components/requestSub.vue index 17017c8..c1ac3dc 100644 --- a/src/views/components/requestSub.vue +++ b/src/views/components/requestSub.vue @@ -656,42 +656,42 @@ export default { console.log('file------>',file) if(this.addForm[index].form.videoAttaches && this.addForm[index].form.picAttaches && this.addForm[index].form.videoAttaches.length + this.addForm[index].form.picAttaches.length < 3){ const isLt3M = file.size - console.log('isLt2M==============>',isLt3M) - if(isLt3M > 1024 * 1024 * 3){ - const r = confirm( - `您上传的图片大小超过3Mb,是否进行压缩上传?(此操作会降低图片质量)` - ) - console.log('r=========>',r) - if(r){ - const _this = this - return new Promise((resolve, reject) => { - const image = new Image() - let resultBlob = '' - image.src = URL.createObjectURL(file) - image.onload = () => { - // 调用方法获取blob格式,方法写在下边 - resultBlob = _this.compressUpload(image, file) - const fs = new File([resultBlob], file.name, { - type: file.type, - width:200, - height:200 - }) - console.log('fs============>',fs) - if (fs.size > 1024 * 1024 * 3) { - // this.commonZipPic(fs) - this.$message.warning('压缩后图片仍大于3Mb,请您手动压缩') - reject() - } - resolve(fs) - } - image.onerror = () => { - reject() - } - }) - }else{ - this.$message.warning('您上传的图片大小超过3Mb,请手动压缩后在上传') + if(isLt3M > 1024 * 1024 * 5){ + // const r = confirm( + // // `您上传的图片大小超过5Mb,是否进行压缩上传?(此操作会降低图片质量)` + // `您上传的图片大小超过5Mb,请压缩后再次上传` + // ) + // console.log('r=========>',r) + // if(r){ + // // const _this = this + // // return new Promise((resolve, reject) => { + // // const image = new Image() + // // let resultBlob = '' + // // image.src = URL.createObjectURL(file) + // // image.onload = () => { + // // // 调用方法获取blob格式,方法写在下边 + // // resultBlob = _this.compressUpload(image, file) + // // const fs = new File([resultBlob], file.name, { + // // type: file.type, + // // width:200, + // // height:200 + // // }) + // // console.log('fs============>',fs) + // // if (fs.size > 1024 * 1024 * 3) { + // // // this.commonZipPic(fs) + // // this.$message.warning('压缩后图片仍大于3Mb,请您手动压缩') + // // reject() + // // } + // // resolve(fs) + // // } + // // image.onerror = () => { + // // reject() + // // } + // // }) + // }else{ + this.$message.warning('您上传的图片大小超过5Mb,请手动压缩后在上传') return false - } + // } }else{ return true }