/** * Created by hzd on 2017/10/23. */ /** * 移除图片 */ function removePic(_self,deleteurl){ $(_self).parent().remove(); if(deleteurl){ $.post(deleteurl,{path:$(_self).parent().find('img').attr('src')}); } } /** * 图片上传 */ function imgfiveup (object){ /* */ this.target = object.target?object.target:"#imgUpload", //上传按钮id this.progress = object.progress?object.progress:"#progress",//进度条id this.imgbox = object.imgbox?object.imgbox:"#imgsbox",//头像图片id this.multi = object.multi?object.multi:false; //多图/单图 this.name = object.name?object.name:'img'; //表单name this.deleteurl = object.deleteurl?object.deleteurl:''; //表单name if(this.multi){ this.name = this.name+'[]'; $(this.target).attr('multiple','multiple'); }else{ $(this.target).removeAttr('multiple'); } that = this; this.upload = function(){ $(that.target).fileupload({ dataType: 'json', done: function (e, data) { if (data.result && data.result.status == 1) { /*
×
*/ var img = '
'; img += '
×
'; img += ''; img += ''; img += '
'; if(that.multi){ $(that.imgbox).append(img); }else{ $(that.imgbox).html(img); } } else { layer.msg(data.result.msg); } }, progressall: function (e, data) { var progressnum = parseInt(data.loaded / data.total * 100); if (progressnum == 100) { $(that.progress).text(''); } else { $(that.progress).text(progressnum + "%"); } }, error: function(e,data){ layer.msg('上传请求失败'); } }); } }