import{_ as e,c as o,aj as s,ak as a,U as n,b as t,o as l,f as c,w as r,v as i,i as u}from"./index-DMmmdxfQ.js";const d=e({name:"image-upload",data:()=>({uploadHeaders:{accessToken:o("loginInfo").accessToken}}),props:{maxCount:{type:Number,default:1},maxSize:{type:Number,default:5242880},sourceType:{type:String,default:"album"},onBefore:{type:Function,default:null},onSuccess:{type:Function,default:null},onError:{type:Function,default:null}},methods:{selectAndUpload(){s({count:this.maxCount,sourceType:[this.sourceType],sizeType:["original"],success:e=>{e.tempFiles.forEach((e=>{console.log("图片选择成功，进行马赛克处理:"+e),this.onBefore&&!this.onBefore(e)||this.uploadImage(e)}))}})},uploadImage(e){console.log("上传图片前验证："+JSON.stringify(e)),a({url:n.BASE_URL+"/image/upload",header:{accessToken:o("loginInfo").accessToken},filePath:e.path,name:"file",success:o=>{let s=JSON.parse(o.data);200!=s.code?(t({icon:"none",title:s.message}),this.onError&&this.onError(e,s)):this.onSuccess&&this.onSuccess(e,s)},fail:o=>{console.log(o),this.onError&&this.onError(e,o)}})}}},[["render",function(e,o,s,a,n,t){const d=u;return l(),c(d,{class:"image-upload",onClick:o[0]||(o[0]=e=>t.selectAndUpload())},{default:r((()=>[i(e.$slots,"default",{},void 0,!0)])),_:3})}],["__scopeId","data-v-f6de493f"]]);export{d as _};
