//首页宣传图
(function () {
var uploadInstance = upload.render({
elem: "#advUpload",
data: baseParams,
auto: false,
accept: "images",
acceptMime: "image/jpg, image/png, image/jpeg",
size: 1024 * 3,
url: disSystemUtil.domain + "/travelLine/saveTravelImg",
multiple: false,
multipleOnce: false,
field: "file",
bindAction: "#advUploadBtn",
before: function (obj) {
//动态参数设定
uploadInstance.config.data = baseParams;
uploadInstance.config.data.recorderId = disSystemUtil.getRecordId();
var userInfo = disSystemUtil.getLocalUserInfo();
uploadInstance.config.data.accesskey = userInfo.accesskey;
//预读本地文件示例,不支持ie8
obj.preview(function (index, file, result) {
// $('#demo2').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img">')
});
uploadLoad = layer.load(2);
},
choose: function (obj) {
//清空文件的上传队列
for (var index = 0; index < deleteAdvFiles.length; index++) {
var element = deleteAdvFiles[index];
delete uploadAdvFiles[element];
}
uploadAdvFiles = obj.pushFile();
obj.preview(function (index, file, result) {
$(".advImg").attr("src", result);
$(".advImg").parent().removeClass("layui-hide");
deleteAdvFiles.push(index);
uploadAdvFile = file;
});
//解决重复选择文件后preview不能回调
$(".layui-upload-file").val("");
},
done: function (res, index, upload) {
//上传完毕
layer.close(uploadLoad);
},
error: function () {
//请求异常回调
layer.close(uploadLoad);
},
});
})();
//解决重复选择文件后preview不能回调
$(".layui-upload-file").val("");