hookehuyr

fix

...@@ -106,7 +106,7 @@ const uploadQiniu = async (file, token, filename) => { ...@@ -106,7 +106,7 @@ const uploadQiniu = async (file, token, filename) => {
106 let formData = new FormData(); 106 let formData = new FormData();
107 formData.append("file", file); // 通过append向form对象添加数据 107 formData.append("file", file); // 通过append向form对象添加数据
108 formData.append("token", token); 108 formData.append("token", token);
109 - formData.append("key", formCode + "/" + uuid() + "." + file.name.split(".")[1]); 109 + formData.append("key", filename);
110 let config = { 110 let config = {
111 headers: { "Content-Type": "multipart/form-data" }, 111 headers: { "Content-Type": "multipart/form-data" },
112 }; 112 };
...@@ -136,7 +136,8 @@ const handleUpload = async (files) => { ...@@ -136,7 +136,8 @@ const handleUpload = async (files) => {
136 // 获取HASH值 136 // 获取HASH值
137 const hash = getEtag(files.content); 137 const hash = getEtag(files.content);
138 // 获取七牛token 138 // 获取七牛token
139 - const filename = formCode + "/" + uuid() + "." + files.file.name.split(".")[1]; 139 + const filename =
140 + "uploadForm/" + formCode + "/" + uuid() + "." + files.file.name.split(".")[1];
140 const { token, key, code } = await qiniuTokenAPI({ 141 const { token, key, code } = await qiniuTokenAPI({
141 name: filename, 142 name: filename,
142 hash, 143 hash,
...@@ -148,10 +149,10 @@ const handleUpload = async (files) => { ...@@ -148,10 +149,10 @@ const handleUpload = async (files) => {
148 return { imgUrl }; 149 return { imgUrl };
149 }; 150 };
150 151
152 +// 多选图片上传遍历
151 var muliUpload = async (files) => { 153 var muliUpload = async (files) => {
152 for (let item of files) { 154 for (let item of files) {
153 const res = await handleUpload(item); 155 const res = await handleUpload(item);
154 - console.warn(res.imgUrl.src);
155 // 上传失败提示 156 // 上传失败提示
156 if (!res.imgUrl.src) { 157 if (!res.imgUrl.src) {
157 item.status = "failed"; 158 item.status = "failed";
...@@ -160,7 +161,6 @@ var muliUpload = async (files) => { ...@@ -160,7 +161,6 @@ var muliUpload = async (files) => {
160 } else { 161 } else {
161 item.status = ""; 162 item.status = "";
162 item.message = ""; 163 item.message = "";
163 - // fileList.value.pop();
164 fileList.value.push({ 164 fileList.value.push({
165 url: res.imgUrl.src, 165 url: res.imgUrl.src,
166 isImage: true, 166 isImage: true,
...@@ -184,7 +184,6 @@ const afterRead = async (files) => { ...@@ -184,7 +184,6 @@ const afterRead = async (files) => {
184 } else { 184 } else {
185 files.status = ""; 185 files.status = "";
186 files.message = ""; 186 files.message = "";
187 - fileList.value.pop();
188 fileList.value.push({ 187 fileList.value.push({
189 url: imgUrl.src, 188 url: imgUrl.src,
190 isImage: true, 189 isImage: true,
...@@ -192,6 +191,7 @@ const afterRead = async (files) => { ...@@ -192,6 +191,7 @@ const afterRead = async (files) => {
192 loading.value = false; 191 loading.value = false;
193 } 192 }
194 } 193 }
194 + // 过滤非包含URL的图片
195 fileList.value = fileList.value.filter((item) => { 195 fileList.value = fileList.value.filter((item) => {
196 if (item.url) return item; 196 if (item.url) return item;
197 }); 197 });
...@@ -201,7 +201,6 @@ const afterRead = async (files) => { ...@@ -201,7 +201,6 @@ const afterRead = async (files) => {
201 value: fileList.value, 201 value: fileList.value,
202 }; 202 };
203 emit("active", props.item.value); 203 emit("active", props.item.value);
204 - console.warn(fileList.value);
205 }; 204 };
206 205
207 const beforeDelete = (files) => { 206 const beforeDelete = (files) => {
......