index-legacy.b5cefa24.js 9.5 KB

1
  1. !function(){var e=document.createElement("style");e.innerHTML="._uploader-section_tym2a_1{display:flex;align-items:center;flex-wrap:wrap;box-sizing:border-box;position:relative}._uploader-section_tym2a_1 ._img-close_tym2a_8{position:absolute;top:.13333rem;right:.32rem;z-index:99;font-size:.34667rem;background-color:rgba(0,0,0,.2);color:#fff;font-weight:700;width:.48rem;height:.48rem;display:flex;justify-content:center;align-items:center;border-radius:50%}._uploader-section_tym2a_1 ._singleImgClose_tym2a_24{right:.13333rem}._uploader-section_tym2a_1 ._uploader_tym2a_1{position:relative}._uploader-section_tym2a_1 ._uploader_tym2a_1._default_tym2a_30 .van-uploader__upload{width:2.61333rem;height:2.50667rem;background-color:#fff}._uploader-section_tym2a_1 ._uploader_tym2a_1._default_tym2a_30 ._previewImg_tym2a_35,._uploader-section_tym2a_1 ._uploader_tym2a_1._default_tym2a_30 ._uploadImg_tym2a_41{width:2.61333rem;height:2.50667rem;border-radius:.26667rem;overflow:hidden}._uploader-section_tym2a_1 ._uploader_tym2a_1 .van-uploader__upload-icon,._uploader-section_tym2a_1 ._uploader_tym2a_1 .van-icon__image{width:100%;height:100%}\n",document.head.appendChild(e),System.register(["./index-legacy.eb062188.js","./index-legacy.fecc738b.js","./index-legacy.bd6987bf.js"],(function(e){"use strict";var a,t,l,o,i,s,d,n,r,p,u,c,m,h,f;return{setters:[function(e){a=e.d,t=e.e,l=e.o,o=e.bj,i=e.g,s=e.m,d=e.bv,n=e.bD,r=e.bE,p=e.b8,u=e.c,c=e.a5,m=e.F},function(e){h=e.I},function(e){f=e.U}],execute:function(){var g={"uploader-section":"_uploader-section_tym2a_1","img-close":"_img-close_tym2a_8",singleImgClose:"_singleImgClose_tym2a_24",uploader:"_uploader_tym2a_1",default:"_default_tym2a_30",previewImg:"_previewImg_tym2a_35",uploadImg:"_uploadImg_tym2a_41"};e("O",a({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:"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/ZZ18gcvKFgYANZ7KFsroHQrW6iT4hYI/0JWM54wKJ0Hz6D3NjFW8uPS6QDjTcRyz+IdULwdPOtuLzL8B5TvfaEtu1RfZDQvdtG9wAI2wAYZeIFg5rBy9/3hM2AOoSXsU2IvNjIfXkKLeBdskYEX0bz6c7ldAM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ZD+enS9Bbhh7Mopr/KbKU16Mshp5NagcaUmmeYU/lUV2fN7c/kL/H9ncPWZFiS9eAXzYxwpg8+k+AAAAAElFTkSuQmCC"},size:{type:String,default:"default"},disabled:{type:Boolean,default:!1}},methods:{nativeUpload(){if(this.disabled)return;const e="VIDEO"===this.uploadType?"video":"img";t({api:"chooseFile",content:{type:e,max:1,bucket:this.bucket,path:this.path}},(e=>{console.log(e,"fileUrl"),this.maxCount>1?(this.$emit("update:modelValue",[...this.modelValue,e.fileUrl]),this.onUploadChange([...this.modelValue,e.fileUrl])):(this.$emit("update:modelValue",[e.fileUrl]),this.onUploadChange([e.fileUrl]))}))},beforeRead(e){console.log(e,"beforeRead");return!!(e.size/1024/1024<this.uploadSize)||(l(`上传文件大小不能超过 ${this.uploadSize}MB`),!1)},beforeDelete:(e,a)=>!0,async afterRead(e,a){try{e.status="uploading",e.message="上传中...",await this.uploadFile(e.file)}catch(t){o()}},onClose(e,a){const t=this.modelValue,l=t.findIndex((e=>e==a));l>-1&&(t.splice(l,1),this.$emit("update:modelValue",t),this.onUploadChange()),e.stopPropagation()},async getFile(e){try{await this.uploadFile(e)}catch{}},async uploadFile(e){try{"SCHOOL"===i.platformType?i.platformApi="/api-school":"TEACHER"===i.platformType?i.platformApi="/api-teacher":"STUDENT"===i.platformType&&(i.platformApi="/api-student");const a=i.platformApi+"/open/getUploadSign",t=e.name||"",l=this.path+"/"+(t&&t.replace(/ /gi,"_")),p=(new Date).getTime()+l;console.log(e);const u=await s.post(a,{data:{filename:l,bucketName:this.bucket,postData:{filename:l,acl:"public-read",key:p,unknowValueField:[]}}});d({message:"加载中...",forbidClick:!0,loadingType:"spinner",duration:0});const c={policy:u.data.policy,signature:u.data.signature,key:p,KSSAccessKeyId:u.data.kssAccessKeyId,acl:"public-read",name:l},m=new FormData;for(const e in c)m.append(e,c[e]);m.append("file",e,l),await n(r(this.bucket),{method:"POST",data:m}),console.log(r(this.bucket)+p);const h=r(this.bucket)+p;o(),this.maxCount>1?(this.$emit("update:modelValue",[...this.modelValue,h]),this.onUploadChange([...this.modelValue,h])):(this.$emit("update:modelValue",[h]),this.onUploadChange([h]))}catch(a){console.log(a,"uploadFile")}}},render(){return p((()=>this.modelValue)),u("div",{class:g["uploader-section"]},[this.modelValue.length>0&&this.maxCount>1&&this.modelValue.map((e=>u("div",{class:[g.uploader,g[this.size]]},[this.deletable&&!this.disabled&&u(c,{name:"cross",onClick:a=>this.onClose(a,e),class:g["img-close"]},null),u("div",{class:["van-uploader__upload"]},["IMAGE"===this.uploadType?u(h,{src:e,class:g.previewImg,fit:"cover"},null):u("video",{ref:"videoUpload",style:{backgroundColor:"#F8F8F8"},class:g.previewImg,src:e+"#t=1,4"},null)])]))),this.native?this.maxCount>1?u("div",{class:[g.uploader,g[this.size]],onClick:this.nativeUpload},[u(c,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):u("div",{class:[g.uploader,g[this.size]],onClick:this.nativeUpload},[this.modelValue.length>0?u("div",{class:["van-uploader__upload"]},[this.modelValue.map((e=>u(m,null,[this.deletable&&!this.disabled&&u(c,{name:"cross",onClick:a=>this.onClose(a,e),class:[g["img-close"],g.singleImgClose]},null),"IMAGE"===this.uploadType?u(h,{fit:"cover",position:"center",class:g.uploadImg,src:e},null):u("video",{ref:"videoUpload",class:g.uploadImg,style:{backgroundColor:"#F8F8F8"},src:e+"#t=1,4"},null)])))]):u(c,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):this.maxCount>1?u(f,{class:[g.uploader,g[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):u(f,{class:[g.uploader,g[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?u("div",{class:["van-uploader__upload"]},[this.modelValue.map((e=>u(m,null,[this.deletable&&!this.disabled&&u(c,{name:"cross",onClick:a=>this.onClose(a,e),class:[g["img-close"],g.singleImgClose]},null),"IMAGE"===this.uploadType?u(h,{fit:"cover",position:"center",class:g.uploadImg,src:e},null):u("video",{ref:"videoUpload",class:g.uploadImg,style:{backgroundColor:"#F8F8F8"},src:e+"#t=1,4"},null)])))]):u(c,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]})])}}))}}}))}();