From d00a7752b9451c0f8f5ff4f1236b8dbc0b1e9d07 Mon Sep 17 00:00:00 2001 From: dzq Date: Tue, 11 Nov 2025 10:41:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=95=86=E5=93=81=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9):=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E8=BF=9B=E5=BA=A6=E6=98=BE=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除压缩进度显示组件注释,修复上传结果状态码判断 添加调试日志输出,便于排查压缩和上传问题 设置默认企业微信ID作为回退方案 --- src/utils/goodsImageCompressor.ts | 11 +++++++++-- src/views/shop/goods/index.vue | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/utils/goodsImageCompressor.ts b/src/utils/goodsImageCompressor.ts index 9948e0d..156e87e 100644 --- a/src/utils/goodsImageCompressor.ts +++ b/src/utils/goodsImageCompressor.ts @@ -58,7 +58,8 @@ const uploadImage = async (file: File): Promise => { } const result = await response.json(); - if (result.code !== 200) { + console.log('上传图片结果', result); + if (result.code !== 0) { throw new Error(result.msg || "上传失败"); } @@ -103,6 +104,9 @@ const compressGoodsImage = async ( }); // 上传压缩后的图片 + console.log('压缩图片名称', compressedFile.name); + console.log('压缩前图片大小', file.size); + console.log('压缩后图片大小', compressedFile.size); const newImageUrl = await uploadImage(compressedFile); // 更新商品信息 @@ -114,6 +118,8 @@ const compressGoodsImage = async ( delete (updateData as any).createTime; delete (updateData as any).updateTime; + console.log('压缩图片信息', compressed); + await updateGoodsApi(goods.goodsId!, updateData); return { @@ -124,6 +130,7 @@ const compressGoodsImage = async ( newImageUrl }; } catch (error) { + console.error('压缩商品图片失败', error); return { goodsId: goods.goodsId!, goodsName: goods.goodsName, @@ -183,7 +190,7 @@ export const compressAllGoodsImages = async ( } = {} ): Promise => { const wxStore = useWxStore(); - const corpid = wxStore.corpid; + const corpid = wxStore.corpid || 'wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw'; if (!corpid) { throw new Error("未获取到企业微信ID"); diff --git a/src/views/shop/goods/index.vue b/src/views/shop/goods/index.vue index f290f68..47cb738 100644 --- a/src/views/shop/goods/index.vue +++ b/src/views/shop/goods/index.vue @@ -296,7 +296,7 @@ const handleCompressAllImages = async () => { -
+