index.8a425810.js 8.0 KB

1
  1. import{d as m,e as g,o as f,bf as u,bq as b,bA as A,b4 as y,c as l,a5 as i,F as r}from"./index.332c7f08.js";import{g as I,o as v,U as c}from"./oss-file-upload.e630303f.js";import{I as p}from"./index.96a8db5e.js";const z="_singleImgClose_tym2a_24",U="_uploader_tym2a_1",T="_previewImg_tym2a_35",k="_uploadImg_tym2a_41";var t={"uploader-section":"_uploader-section_tym2a_1","img-close":"_img-close_tym2a_8",singleImgClose:z,uploader:U,default:"_default_tym2a_30",previewImg:T,uploadImg:k},M="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMwAAAC8CAMAAAAD3rEBAAABWVBMVEUAAADZ2dna2tra2trZ2dna2trZ2dnb29va2trZ2dnc3Nz5+fn5+fn4+Pj4+Pj5+fnb29v////Z2dn29vbi4uLa2trj4+Pq6ur4+Pjg4OD4+PjZ2dk9PT13d3ff39/29vbj4+Px8fHc3Nzu7u6CgoLs7OzX19fq6url5eW8vLypqan09PTPz8+vr6/w8PDLy8u9vb2ZmZn/o3zHx8eJiYnAwMD/pn98fHz/kGiOjo7/qoJ5eXn/jWWLi4v/oHj/iWGjo6P/mXFGRkbz8/NRUVFBQUHY2NjR0dH61sampqacnJz/kmqurq6WlpaSkpL9p4h/f3//nXX/lWyGhobh4eG0tLRxcXG4uLifn5//lm5ZWVmysrL+tZVdXV3ExMT9uJr47OfJycn9rI9bW1v6z776zbz/rYbn5+f55Nv639PGxsb60MH6zr2zs7P8wKWTk5NnZ2f7x7X8wqd47tpPAAAAGnRSTlMA+Jbr46yHeDcbE7T465dXVwnS69PTl+vTtLW+UnUAAAeQSURBVHja7NpbTyIxGIDh4lk8u5vN7tcJM0BABWOMCgGjEo4L4YIoGxLNGAigkWhc9f9fbFvc4ViRWEI7mfcSufDJlG/aAdTb0uL89qwLdwUs+V5xzW7PLy4hbssLc7iddP8675W5heWhFPeMC2PfbsAb1kGB9LA3sOvD2PXDPWjZ+ObDxgEo1oGB02sb/ZZ18gcvK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2V4z0yBvLSnJmFc3D7yAIlewlCzxJIOUsAZqYAcgaxbj4xB1BFIcxnjlGFi5iLeO+lj7GqkwDujDzUeLOTAOzwbive2+JDI+LxctNN0uDq0HTtIJ4a2DYHfPZELl7OA24hY3yzT8hl9uxh6+YTmezxQx1HZD+enS9Bbhh7Mopr/KbKU16Mshp5NagcaUmmeYU/lUV2fN7c/kL/H9ncPWZFiS9eAXzYxwpg8+k+AAAAAElFTkSuQmCC",L=m({name:"col-upload",props:{modelValue:{type:Array,default:()=>[]},deletable:{type:Boolean,default:!0},maxCount:{type:Number,default:1},native:{type:Boolean,default:!1},uploadSize:{type:Number,default:5},uploadType:{type:String,default:"IMAGE"},accept:{type:String,default:"image/*"},onUploadChange:{type:Function,default:e=>{}},bucket:{type:String,default:"gyt"},path:{type:String,default:""},uploadIcon:{type:String,default:M},size:{type:String,default:"default"},disabled:{type:Boolean,default:!1}},methods:{nativeUpload(){if(this.disabled)return;const e=this.uploadType==="VIDEO"?"video":"img";g({api:"chooseFile",content:{type:e,max:1,bucket:this.bucket,path:this.path}},a=>{console.log(a,"fileUrl"),this.maxCount>1?(this.$emit("update:modelValue",[...this.modelValue,a.fileUrl]),this.onUploadChange([...this.modelValue,a.fileUrl])):(this.$emit("update:modelValue",[a.fileUrl]),this.onUploadChange([a.fileUrl]))})},beforeRead(e){return console.log(e,"beforeRead"),e.size/1024/1024<this.uploadSize?!0:(f(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.uploadSize}MB`),!1)},beforeDelete(e,a){return!0},async afterRead(e,a){try{e.status="uploading",e.message="\u4E0A\u4F20\u4E2D...",await this.uploadFile(e.file)}catch{u()}},onClose(e,a){const o=this.modelValue,s=o.findIndex(d=>d==a);s>-1&&(o.splice(s,1),this.$emit("update:modelValue",o),this.onUploadChange()),e.stopPropagation()},async getFile(e){try{await this.uploadFile(e)}catch{}},async uploadFile(e){try{const a=e.name||"",o=this.path?this.path+"/"+(a&&a.replace(/ /gi,"_")):a&&a.replace(/ /gi,"_"),s=new Date().getTime()+o,{data:d}=await I({filename:s,bucketName:this.bucket,postData:{filename:s,acl:"public-read",key:s,unknowValueField:[]}});b({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const h={policy:d.policy,signature:d.signature,key:s,KSSAccessKeyId:d.kssAccessKeyId,acl:"public-read",name:s,file:e},n=await v(A(this.bucket),h);console.log(n,"uploadUrl"),u(),this.maxCount>1?(this.$emit("update:modelValue",[...this.modelValue,n]),this.onUploadChange([...this.modelValue,n])):(this.$emit("update:modelValue",[n]),this.onUploadChange([n]))}catch(a){console.log(a,"uploadFile"),u()}}},render(){return y(()=>this.modelValue),l("div",{class:t["uploader-section"]},[this.modelValue.length>0&&this.maxCount>1&&this.modelValue.map(e=>l("div",{class:[t.uploader,t[this.size]]},[this.deletable&&!this.disabled&&l(i,{name:"cross",onClick:a=>this.onClose(a,e),class:t["img-close"]},null),l("div",{class:["van-uploader__upload"]},[this.uploadType==="IMAGE"?l(p,{src:e,class:t.previewImg,fit:"cover"},null):l("video",{ref:"videoUpload",style:{backgroundColor:"#F8F8F8"},class:t.previewImg,src:e+"#t=1,4"},null)])])),this.native?this.maxCount>1?l("div",{class:[t.uploader,t[this.size]],onClick:this.nativeUpload},[l(i,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):l("div",{class:[t.uploader,t[this.size]],onClick:this.nativeUpload},[this.modelValue.length>0?l("div",{class:["van-uploader__upload"]},[this.modelValue.map(e=>l(r,null,[this.deletable&&!this.disabled&&l(i,{name:"cross",onClick:a=>this.onClose(a,e),class:[t["img-close"],t.singleImgClose]},null),this.uploadType==="IMAGE"?l(p,{fit:"cover",position:"center",class:t.uploadImg,src:e},null):l("video",{ref:"videoUpload",class:t.uploadImg,style:{backgroundColor:"#F8F8F8"},src:e+"#t=1,4"},null)]))]):l(i,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):this.maxCount>1?l(c,{class:[t.uploader,t[this.size]],afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete,uploadIcon:this.uploadIcon,disabled:this.modelValue.length===this.maxCount||this.disabled,accept:this.accept},null):l(c,{class:[t.uploader,t[this.size]],afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete,uploadIcon:this.uploadIcon,accept:this.accept,disabled:this.disabled},{default:()=>[this.modelValue.length>0?l("div",{class:["van-uploader__upload"]},[this.modelValue.map(e=>l(r,null,[this.deletable&&!this.disabled&&l(i,{name:"cross",onClick:a=>this.onClose(a,e),class:[t["img-close"],t.singleImgClose]},null),this.uploadType==="IMAGE"?l(p,{fit:"cover",position:"center",class:t.uploadImg,src:e},null):l("video",{ref:"videoUpload",class:t.uploadImg,style:{backgroundColor:"#F8F8F8"},src:e+"#t=1,4"},null)]))]):l(i,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]})])}});export{L as O};