fix(商品图片压缩): 修复图片压缩进度显示和上传逻辑
移除压缩进度显示组件注释,修复上传结果状态码判断 添加调试日志输出,便于排查压缩和上传问题 设置默认企业微信ID作为回退方案
This commit is contained in:
parent
e9c8bdd385
commit
d00a7752b9
|
|
@ -58,7 +58,8 @@ const uploadImage = async (file: File): Promise<string> => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result.code !== 200) {
|
console.log('上传图片结果', result);
|
||||||
|
if (result.code !== 0) {
|
||||||
throw new Error(result.msg || "上传失败");
|
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);
|
const newImageUrl = await uploadImage(compressedFile);
|
||||||
|
|
||||||
// 更新商品信息
|
// 更新商品信息
|
||||||
|
|
@ -114,6 +118,8 @@ const compressGoodsImage = async (
|
||||||
delete (updateData as any).createTime;
|
delete (updateData as any).createTime;
|
||||||
delete (updateData as any).updateTime;
|
delete (updateData as any).updateTime;
|
||||||
|
|
||||||
|
console.log('压缩图片信息', compressed);
|
||||||
|
|
||||||
await updateGoodsApi(goods.goodsId!, updateData);
|
await updateGoodsApi(goods.goodsId!, updateData);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -124,6 +130,7 @@ const compressGoodsImage = async (
|
||||||
newImageUrl
|
newImageUrl
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('压缩商品图片失败', error);
|
||||||
return {
|
return {
|
||||||
goodsId: goods.goodsId!,
|
goodsId: goods.goodsId!,
|
||||||
goodsName: goods.goodsName,
|
goodsName: goods.goodsName,
|
||||||
|
|
@ -183,7 +190,7 @@ export const compressAllGoodsImages = async (
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<CompressResult[]> => {
|
): Promise<CompressResult[]> => {
|
||||||
const wxStore = useWxStore();
|
const wxStore = useWxStore();
|
||||||
const corpid = wxStore.corpid;
|
const corpid = wxStore.corpid || 'wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw';
|
||||||
|
|
||||||
if (!corpid) {
|
if (!corpid) {
|
||||||
throw new Error("未获取到企业微信ID");
|
throw new Error("未获取到企业微信ID");
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ const handleCompressAllImages = async () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 压缩进度显示 -->
|
<!-- 压缩进度显示 -->
|
||||||
<div v-if="compressLoading || compressProgress" class="compress-progress">
|
<!-- <div v-if="compressLoading || compressProgress" class="compress-progress">
|
||||||
<el-card class="progress-card">
|
<el-card class="progress-card">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
|
@ -323,7 +323,7 @@ const handleCompressAllImages = async () => {
|
||||||
<p>准备中...</p>
|
<p>准备中...</p>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div> -->
|
||||||
<!-- 新增商品弹窗 -->
|
<!-- 新增商品弹窗 -->
|
||||||
<goods-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
<goods-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
||||||
<goods-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
<goods-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue