// 缩略图预览 document.querySelector('#uploaderFiles').addEventListener('click', function (e) { var target = e.target; // var _that = this.children.length; // console.log(_that);
while (!target.classList.contains('weui-uploader__file') && target) { target = target.parentNode;
} if (!target) return;
var url = target.getAttribute('style') || ''; var id = target.getAttribute('data-id');
if (url) { url = url.match(/url\((.*?)\)/)[1].replace(/"/g, ''); } var gallery = weui.gallery(url, { onDelete: function onDelete() { weui.confirm('确定删除该图片?', function () { var index; for (var i = 0, len = uploadCustomFileList.length; i < len; ++i) { var file = uploadCustomFileList[i]; if (file.id == id) { index = i; break; } } if (index !== undefined) uploadCustomFileList.splice(index, 1); uploadCount --; target.remove(); gallery.hide(); }); } }); });
var arr=[]; var urls=$("[name=upload_url]").val(); $("#uploaderFiles").find("li").each(function(index,item){ var data_id = $(item).data("id"); var img_url = $(item)[0].style.backgroundImage.split("\"")[1];