|
@@ -751,6 +751,11 @@
|
|
|
margin-top: 18rem;
|
|
|
margin-right: 35rem;
|
|
|
}
|
|
|
+ .upload-class {
|
|
|
+ min-width: 100rem;
|
|
|
+ height: 80rem;
|
|
|
+ line-height: 80rem;
|
|
|
+ }
|
|
|
</style>
|
|
|
<body>
|
|
|
<div id="collectPage">
|
|
@@ -932,6 +937,14 @@
|
|
|
var formData = new FormData();
|
|
|
formData.append('path', fileList[i].name)
|
|
|
formData.append('file', fileList[i])
|
|
|
+ // 显示上传中状态
|
|
|
+
|
|
|
+ const gallery = document.getElementById('imageGallery');
|
|
|
+ const photoBtn = document.getElementById('photoBtn');
|
|
|
+ const upload = document.createElement('p');
|
|
|
+ upload.className = 'upload-class';
|
|
|
+ upload.innerHTML = '上传中...'
|
|
|
+ gallery.insertBefore(upload,photoBtn);
|
|
|
let url = credentials.serverDomain+ '/open/v1/file/upload'
|
|
|
mui.ajax(url, {
|
|
|
data: formData,
|
|
@@ -945,15 +958,11 @@
|
|
|
},
|
|
|
success:function(res){
|
|
|
imgList.push(res.data.url)
|
|
|
- const gallery = document.getElementById('imageGallery');
|
|
|
- const photoBtn = document.getElementById('photoBtn');
|
|
|
- // imgList.forEach( item=> { // 假设data是一个包含图片URL的数组
|
|
|
- const img = document.createElement('img');
|
|
|
- img.src = res.data.url; // 假设每个图片对象都有一个url属性
|
|
|
- // gallery.appendChild(img); // 将图片添加到div中
|
|
|
- gallery.insertBefore(img,photoBtn);
|
|
|
- // });
|
|
|
- console.log('sdd', imgList);
|
|
|
+ const img = document.createElement('img');
|
|
|
+ img.className = 'upload-img';
|
|
|
+ img.src = res.data.url;
|
|
|
+ gallery.insertBefore(img,photoBtn);
|
|
|
+ gallery.removeChild(upload);
|
|
|
},
|
|
|
error:function(error){
|
|
|
//异常处理;
|
|
@@ -1090,6 +1099,13 @@
|
|
|
imgList = []
|
|
|
document.getElementById("textarea").innerHTML = "";
|
|
|
findCollectList()
|
|
|
+ const gallery = document.getElementById('imageGallery');
|
|
|
+ // 遍历gallery的所有子元素
|
|
|
+ var imgsToRemove = gallery.querySelectorAll('img.upload-img');
|
|
|
+ // 遍历找到的元素并移除它们
|
|
|
+ imgsToRemove.forEach(function(img) {
|
|
|
+ gallery.removeChild(img);
|
|
|
+ });
|
|
|
} else {
|
|
|
mui.toast(res.msg);
|
|
|
}
|
|
@@ -1175,6 +1191,13 @@
|
|
|
document.getElementById('closeText').addEventListener('click', function() {
|
|
|
document.getElementById('dialogText').style.display = 'none';
|
|
|
imgList = []
|
|
|
+ const gallery = document.getElementById('imageGallery');
|
|
|
+ // 遍历gallery的所有子元素
|
|
|
+ var imgsToRemove = gallery.querySelectorAll('img.upload-img');
|
|
|
+ // 遍历找到的元素并移除它们
|
|
|
+ imgsToRemove.forEach(function(img) {
|
|
|
+ gallery.removeChild(img);
|
|
|
+ });
|
|
|
document.getElementById("textarea").innerHTML = "";
|
|
|
onShowItem()
|
|
|
});
|