From 3e9235844a8fde68da72c91abe28c2e299fe3647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=9D=B0?= <727475508@qq.com> Date: Wed, 6 May 2026 15:01:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E8=A7=86=E9=A2=91=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E5=92=8C=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/shop/photoAlbum/addPhoto.vue | 11 ++++---- utils/albumUploadImage.js | 41 +++++++++++++++++------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/pages/shop/photoAlbum/addPhoto.vue b/pages/shop/photoAlbum/addPhoto.vue index 32a005a..51c7d5e 100644 --- a/pages/shop/photoAlbum/addPhoto.vue +++ b/pages/shop/photoAlbum/addPhoto.vue @@ -428,11 +428,12 @@ title: '取消上传', icon: 'none' }); - } else { - uni.showToast({ - title: '上传失败', - icon: 'none' - }); // 新增:上传失败提示 + } else { + console.error('上传失败:', err.errMsg); + uni.showToast({ + title: err.errMsg || '上传失败', + icon: 'none' + }); // 新增:上传失败提示 } } finally { diff --git a/utils/albumUploadImage.js b/utils/albumUploadImage.js index 4d6d211..ae649cc 100644 --- a/utils/albumUploadImage.js +++ b/utils/albumUploadImage.js @@ -77,6 +77,21 @@ const handleUpload = async (userId, type, sourceType = ['album', 'camera'], uplo // #ifdef APP-PLUS || MP-WEIXIN file = res; // #endif + const duration = res.duration; + if (duration < 3) { + uni.showToast({ + title: "视频时长不能少于3秒", + icon: "none", + }); + return null; + } + if (duration > 59.9) { + uni.showToast({ + title: "视频时长不能超过1分钟", + icon: "none", + }); + return null; + } } @@ -149,23 +164,15 @@ const uploadFile = async (file, userId, type, uploadType) => { console.log('file=======', file) console.log('userId=======', userId) // 检查文件大小 - if (uploadType == 'image') { - if (file.size > 5 * 1024 * 1024) { - uni.showToast({ - title: `文件大小不能超过5MB`, - icon: 'none' - }) - return Promise.reject(new Error('文件大小超出限制')) - } - } else if (uploadType == 'video') { - if (file.size > 100 * 1024 * 1024) { - uni.showToast({ - title: `文件大小不能超过100MB`, - icon: 'none' - }) - return Promise.reject(new Error('文件大小超出限制')) - } - } + if (uploadType == "image") { + if (file.size > 5 * 1024 * 1024) { + return Promise.reject({errMsg: "文件大小不能超过5MB"}); + } + } else if (uploadType == "video") { + if (file.size > 500 * 1024 * 1024) { + return Promise.reject({errMsg: "文件大小不能超过500MB"}); + } + } let date = new Date().getTime() console.log('file', file)