1 |
- import{j as ee,d as Z,ai as H,t as $,O as ae,aj as Fe,i as te,E as N,w as O,ak as qe,g as o,al as G,am as B,a7 as ue,an as Se,v as E,q as de,ao as T,x as le,n as Y,ap as me,o as Ie,aq as Pe,ar as xe,y as ze,m as oe,p as L,P as ke,Y as Ve,as as Me,I as P,at as ge,z as De,A as j,au as Ee,av as Re,D as Ae,aw as fe,ax as Ue,H as he,ay as Te,l as Ye,ad as ve,az as Ne,aA as Be,aB as He,M as Le,f as Oe,af as se,a as Xe,a3 as Ze,ag as Ke,ah as J,F as ie}from"./index-1d4a9afa.js";import{c as We,b as je}from"./index-22c9ea74.js";import{I as X}from"./index-c272bcfa.js";const ne=e=>Math.sqrt((e[0].clientX-e[1].clientX)**2+(e[0].clientY-e[1].clientY)**2),Q=ee("image-preview")[1];var Ge=Z({props:{src:String,show:Boolean,active:Number,minZoom:H($),maxZoom:H($),rootWidth:H(Number),rootHeight:H(Number),disableZoom:Boolean},emits:["scale","close","longPress"],setup(e,{emit:t,slots:n}){const a=ae({scale:1,moveX:0,moveY:0,moving:!1,zooming:!1,imageRatio:0,displayWidth:0,displayHeight:0}),i=Fe(),f=te(),b=N(()=>{const{rootWidth:s,rootHeight:d}=e,u=d/s;return a.imageRatio>u}),C=N(()=>{const{scale:s,moveX:d,moveY:u,moving:I,zooming:D}=a,K={transitionDuration:D||I?"0s":".3s"};if(s!==1){const be=d/s,Ce=u/s;K.transform=`scale(${s}, ${s}) translate(${be}px, ${Ce}px)`}return K}),A=N(()=>{if(a.imageRatio){const{rootWidth:s,rootHeight:d}=e,u=b.value?d/a.imageRatio:s;return Math.max(0,(a.scale*u-s)/2)}return 0}),r=N(()=>{if(a.imageRatio){const{rootWidth:s,rootHeight:d}=e,u=b.value?d:s*a.imageRatio;return Math.max(0,(a.scale*u-d)/2)}return 0}),h=s=>{s=B(s,+e.minZoom,+e.maxZoom+1),s!==a.scale&&(a.scale=s,t("scale",{scale:s,index:e.active}))},F=()=>{h(1),a.moveX=0,a.moveY=0},w=()=>{const s=a.scale>1?1:2;h(s),a.moveX=0,a.moveY=0};let q,k,V,R,M,c,x,l=!1;const m=s=>{const{touches:d}=s;if(q=d.length,q===2&&e.disableZoom)return;const{offsetX:u}=i;i.start(s),k=a.moveX,V=a.moveY,x=Date.now(),l=!1,a.moving=q===1&&a.scale!==1,a.zooming=q===2&&!u.value,a.zooming&&(R=a.scale,M=ne(s.touches))},y=s=>{const{touches:d}=s;if(i.move(s),a.moving){const{deltaX:u,deltaY:I}=i,D=u.value+k,K=I.value+V;if((D>A.value||D<-A.value)&&!l&&i.isHorizontal()){a.moving=!1;return}l=!0,G(s,!0),a.moveX=B(D,-A.value,A.value),a.moveY=B(K,-r.value,r.value)}if(a.zooming&&(G(s,!0),d.length===2)){const u=ne(d),I=R*u/M;h(I)}},p=()=>{if(q>1)return;const{offsetX:s,offsetY:d}=i,u=Date.now()-x,I=250,D=5;s.value<D&&d.value<D&&(u<I?c?(clearTimeout(c),c=null,w()):c=setTimeout(()=>{t("close"),c=null},I):u>Se&&t("longPress"))},S=s=>{let d=!1;if((a.moving||a.zooming)&&(d=!0,a.moving&&k===a.moveX&&V===a.moveY&&(d=!1),!s.touches.length)){a.zooming&&(a.moveX=B(a.moveX,-A.value,A.value),a.moveY=B(a.moveY,-r.value,r.value),a.zooming=!1),a.moving=!1,k=0,V=0,R=1,a.scale<1&&F();const u=+e.maxZoom;a.scale>u&&(a.scale=u)}G(s,d),p(),i.reset()},z=s=>{const{naturalWidth:d,naturalHeight:u}=s.target;a.imageRatio=u/d};return O(()=>e.active,F),O(()=>e.show,s=>{s||F()}),qe("touchmove",y,{target:N(()=>{var s;return(s=f.value)==null?void 0:s.$el})}),()=>{const s={loading:()=>o(ue,{type:"spinner"},null)};return o(We,{ref:f,class:Q("swipe-item"),onTouchstartPassive:m,onTouchend:S,onTouchcancel:S},{default:()=>[n.image?o("div",{class:Q("image-wrap")},[n.image({src:e.src})]):o(X,{src:e.src,fit:"contain",class:Q("image",{vertical:b.value}),style:C.value,onLoad:z},s)]})}}});const[Je,U]=ee("image-preview"),Qe=["show","teleport","transition","overlayStyle","closeOnPopstate"],_e={show:Boolean,loop:E,images:de(),minZoom:T(1/3),maxZoom:T(3),overlay:E,closeable:Boolean,showIndex:E,className:le,closeIcon:Y("clear"),transition:String,beforeClose:Function,overlayClass:le,overlayStyle:Object,swipeDuration:T(300),startPosition:T(0),showIndicators:Boolean,closeOnPopstate:E,closeIconPosition:Y("top-right"),teleport:[String,Object]};var pe=Z({name:Je,props:_e,emits:["scale","close","closed","change","longPress","update:show"],setup(e,{emit:t,slots:n}){const a=te(),i=ae({active:0,rootWidth:0,rootHeight:0,disableZoom:!1}),f=()=>{if(a.value){const c=Ve(a.value.$el);i.rootWidth=c.width,i.rootHeight=c.height,a.value.resize()}},b=c=>t("scale",c),C=c=>t("update:show",c),A=()=>{ge(e.beforeClose,{args:[i.active],done:()=>C(!1)})},r=c=>{c!==i.active&&(i.active=c,t("change",c))},h=()=>{if(e.showIndex)return o("div",{class:U("index")},[n.index?n.index({index:i.active}):`${i.active+1} / ${e.images.length}`])},F=()=>{if(n.cover)return o("div",{class:U("cover")},[n.cover()])},w=()=>{i.disableZoom=!0},q=()=>{i.disableZoom=!1},k=()=>o(je,{ref:a,lazyRender:!0,loop:e.loop,class:U("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:r,onDragEnd:q,onDragStart:w},{default:()=>[e.images.map((c,x)=>o(Ge,{src:c,show:e.show,active:i.active,maxZoom:e.maxZoom,minZoom:e.minZoom,rootWidth:i.rootWidth,rootHeight:i.rootHeight,disableZoom:i.disableZoom,onScale:b,onClose:A,onLongPress:()=>t("longPress",{index:x})},{image:n.image}))]}),V=()=>{if(e.closeable)return o(P,{role:"button",name:e.closeIcon,class:[U("close-icon",e.closeIconPosition),Me],onClick:A},null)},R=()=>t("closed"),M=(c,x)=>{var l;return(l=a.value)==null?void 0:l.swipeTo(c,x)};return me({swipeTo:M}),Ie(f),O([Pe,xe],f),O(()=>e.startPosition,c=>r(+c)),O(()=>e.show,c=>{const{images:x,startPosition:l}=e;c?(r(+l),ze(()=>{f(),M(+l,{immediate:!0})})):t("close",{index:i.active,url:x[i.active]})}),()=>o(ke,oe({class:[U(),e.className],overlayClass:[U("overlay"),e.overlayClass],onClosed:R,"onUpdate:show":C},L(e,Qe)),{default:()=>[V(),k(),h(),F()]})}});let W;const $e={loop:!0,images:[],maxZoom:3,minZoom:1/3,onScale:void 0,onClose:void 0,onChange:void 0,teleport:"body",className:"",showIndex:!0,closeable:!1,closeIcon:"clear",transition:void 0,beforeClose:void 0,overlayStyle:void 0,overlayClass:void 0,startPosition:0,swipeDuration:300,showIndicators:!1,closeOnPopstate:!0,closeIconPosition:"top-right"};function ea(){({instance:W}=Ee({setup(){const{state:e,toggle:t}=Re(),n=()=>{e.images=[]};return()=>o(pe,oe(e,{onClosed:n,"onUpdate:show":t}),null)}}))}const aa=(e,t=0)=>{if(De)return W||ea(),e=Array.isArray(e)?{images:e,startPosition:t}:e,W.open(j({},$e,e)),W};Ae(pe);const[ta,v,oa]=ee("uploader");function re(e,t){return new Promise(n=>{if(t==="file"){n();return}const a=new FileReader;a.onload=i=>{n(i.target.result)},t==="dataUrl"?a.readAsDataURL(e):t==="text"&&a.readAsText(e)})}function we(e,t){return fe(e).some(n=>n.file?Ue(t)?t(n.file):n.file.size>+t:!1)}function la(e,t){const n=[],a=[];return e.forEach(i=>{we(i,t)?a.push(i):n.push(i)}),{valid:n,invalid:a}}const sa=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i,ia=e=>sa.test(e);function ye(e){return e.isImage?!0:e.file&&e.file.type?e.file.type.indexOf("image")===0:e.url?ia(e.url):typeof e.content=="string"?e.content.indexOf("data:image")===0:!1}var na=Z({props:{name:$,item:H(Object),index:Number,imageFit:String,lazyLoad:Boolean,deletable:Boolean,previewSize:[Number,String,Array],beforeDelete:Function},emits:["delete","preview"],setup(e,{emit:t,slots:n}){const a=()=>{const{status:r,message:h}=e.item;if(r==="uploading"||r==="failed"){const F=r==="failed"?o(P,{name:"close",class:v("mask-icon")},null):o(ue,{class:v("loading")},null),w=Te(h)&&h!=="";return o("div",{class:v("mask")},[F,w&&o("div",{class:v("mask-message")},[h])])}},i=r=>{const{name:h,item:F,index:w,beforeDelete:q}=e;r.stopPropagation(),ge(q,{args:[F,{name:h,index:w}],done:()=>t("delete")})},f=()=>t("preview"),b=()=>{if(e.deletable&&e.item.status!=="uploading"){const r=n["preview-delete"];return o("div",{role:"button",class:v("preview-delete",{shadow:!r}),tabindex:0,"aria-label":oa("delete"),onClick:i},[r?r():o(P,{name:"cross",class:v("preview-delete-icon")},null)])}},C=()=>{if(n["preview-cover"]){const{index:r,item:h}=e;return o("div",{class:v("preview-cover")},[n["preview-cover"](j({index:r},h))])}},A=()=>{const{item:r,lazyLoad:h,imageFit:F,previewSize:w}=e;return ye(r)?o(X,{fit:F,src:r.content||r.url,class:v("preview-image"),width:Array.isArray(w)?w[0]:w,height:Array.isArray(w)?w[1]:w,lazyLoad:h,onClick:f},{default:C}):o("div",{class:v("file"),style:he(e.previewSize)},[o(P,{class:v("file-icon"),name:"description"},null),o("div",{class:[v("file-name"),"van-ellipsis"]},[r.file?r.file.name:r.url]),C()])};return()=>o("div",{class:v("preview")},[A(),a(),b()])}});const ra={name:T(""),accept:Y("image/*"),capture:String,multiple:Boolean,disabled:Boolean,readonly:Boolean,lazyLoad:Boolean,maxCount:T(1/0),imageFit:Y("cover"),resultType:Y("dataUrl"),uploadIcon:Y("photograph"),uploadText:String,deletable:E,afterRead:Function,showUpload:E,modelValue:de(),beforeRead:Function,beforeDelete:Function,previewSize:[Number,String,Array],previewImage:E,previewOptions:Object,previewFullImage:E,maxSize:{type:[Number,String,Function],default:1/0}};var ca=Z({name:ta,props:ra,emits:["delete","oversize","clickUpload","closePreview","clickPreview","update:modelValue"],setup(e,{emit:t,slots:n}){const a=te(),i=[],f=(l=e.modelValue.length)=>({name:e.name,index:l}),b=()=>{a.value&&(a.value.value="")},C=l=>{if(b(),we(l,e.maxSize))if(Array.isArray(l)){const m=la(l,e.maxSize);if(l=m.valid,t("oversize",m.invalid,f()),!l.length)return}else{t("oversize",l,f());return}l=ae(l),t("update:modelValue",[...e.modelValue,...fe(l)]),e.afterRead&&e.afterRead(l,f())},A=l=>{const{maxCount:m,modelValue:y,resultType:p}=e;if(Array.isArray(l)){const S=+m-y.length;l.length>S&&(l=l.slice(0,S)),Promise.all(l.map(z=>re(z,p))).then(z=>{const s=l.map((d,u)=>{const I={file:d,status:"",message:""};return z[u]&&(I.content=z[u]),I});C(s)})}else re(l,p).then(S=>{const z={file:l,status:"",message:""};S&&(z.content=S),C(z)})},r=l=>{const{files:m}=l.target;if(e.disabled||!m||!m.length)return;const y=m.length===1?m[0]:[].slice.call(m);if(e.beforeRead){const p=e.beforeRead(y,f());if(!p){b();return}if(He(p)){p.then(S=>{A(S||y)}).catch(b);return}}A(y)};let h;const F=()=>t("closePreview"),w=l=>{if(e.previewFullImage){const m=e.modelValue.filter(ye),y=m.map(p=>(p.file&&!p.url&&p.status!=="failed"&&(p.url=URL.createObjectURL(p.file),i.push(p.url)),p.url)).filter(Boolean);h=aa(j({images:y,startPosition:m.indexOf(l),onClose:F},e.previewOptions))}},q=()=>{h&&h.close()},k=(l,m)=>{const y=e.modelValue.slice(0);y.splice(m,1),t("update:modelValue",y),t("delete",l,f(m))},V=(l,m)=>{const y=["imageFit","deletable","previewSize","beforeDelete"],p=j(L(e,y),L(l,y,!0));return o(na,oe({item:l,index:m,onClick:()=>t("clickPreview",l,f(m)),onDelete:()=>k(l,m),onPreview:()=>w(l)},L(e,["name","lazyLoad"]),p),L(n,["preview-cover","preview-delete"]))},R=()=>{if(e.previewImage)return e.modelValue.map(V)},M=l=>t("clickUpload",l),c=()=>{if(e.modelValue.length>=+e.maxCount)return;const l=e.readonly?null:o("input",{ref:a,type:"file",class:v("input"),accept:e.accept,capture:e.capture,multiple:e.multiple,disabled:e.disabled,onChange:r},null);return n.default?o("div",{class:v("input-wrapper"),onClick:M},[n.default(),l]):Ne(o("div",{class:v("upload",{readonly:e.readonly}),style:he(e.previewSize),onClick:M},[o(P,{name:e.uploadIcon,class:v("upload-icon")},null),e.uploadText&&o("span",{class:v("upload-text")},[e.uploadText]),l]),[[Be,e.showUpload]])},x=()=>{a.value&&!e.disabled&&a.value.click()};return Ye(()=>{i.forEach(l=>URL.revokeObjectURL(l))}),me({chooseFile:x,closeImagePreview:q}),ve(()=>e.modelValue),()=>o("div",{class:v()},[o("div",{class:v("wrapper",{disabled:e.disabled})},[R(),c()])])}});const ce=Ae(ca),ua="_singleImgClose_1ti1e_25",da="_uploader_1ti1e_1",ma="_previewImg_1ti1e_36",ga="_uploadImg_1ti1e_42",g={"uploader-section":"_uploader-section_1ti1e_1","img-close":"_img-close_1ti1e_9",singleImgClose:ua,uploader:da,default:"_default_1ti1e_31",previewImg:ma,uploadImg:ga},Aa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJgAAACYCAMAAAAvHNATAAABOFBMVEUAAADa2tr39/f////a2tr39/fa2trZ2dnV1dX5+fn5+fnp6en29vbZ2dn4+Pjo6OjZ2dk9PT2ZmZmXl5f29vbx8fHk5OTh4eHq6urOzs66urrBwcH19fW1tbXz8/Ps7Oza2trm5uaysrJERETe3t6vr6/g4ODV1dW+vr6cnJzc3Nwly7zv7++np6fQ0NDKyspA0sHJycnFxcU50L8pzL2dnZ3w8PDu7u40z78gyru4uLirq6tKSkovzb5iYmJZWVnGxsY80cCurq6qqqqfn59paWnX19dF1MJBQUHT09Nz3dBp2s/MzMzDw8MbyLqjo6OhoaGSkpJa1spL1MWMjIyHh4dwcHBSUlJMTExi2M3w9vbb8u/U1NR7e3tycnJR1cfn9fON4th839J/f3/M7uvG7um76+eX5Nt5K7d4AAAADnRSTlMA8s8Gx2xszwbyx8cbGz8Ohn8AAAbPSURBVHja7NppU9pQFMbx2M2uT3IwgYzVAC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KXC1qgaUy1hDNuV/s3OtyqjAQB/D9k6Dcb4KKihbrqdrT2tr6/s92JmDHfnBObwTozP5egA+ZJJvdZbXw0VrGLIbiE9Pi2NY16UE5EtPDKAEgTEizJASAkiNWbaQNAHZKWqX1VzgVoJEP5SBJI3ngC1K/PZTiRNqcCih7YlqtoOy0reRpBx6r0woXSiFJC1mAi5DtCCIoh5Q0SA9QooCYdoNXKHZCjUtsKK/cWd6KQQQl9KhhXggl4nVsSeCiEhvUICNGxeVztT0rVGYZNSabgePV9u1RsTxqiGeB349d8G1UnCE1YOigYnM+p3WyRMV6CeiHghcLlZLzqx0wjg1M0VFGM9SOXO/owuV4FW5G35a5go/Vrg1z1IST0rekjkAt576OLv19Qk2MR/Rlo7FA7Yn75TpmLEKcPa/v6Avu1s84Cxd8O3ZP5gJnZu4b9CmGn5s4EzkHq/3wxxV4c+PcS/qAvHdu8Ea4/L9Vf8jYxMVk6WUBXRVk3nKCCzPm3dgvw+kE75nFeHqbpPJxUBVMHmWa3E7HhYn3JlMOVXtos7RwhbBtgSusJc/P6auBF4X4lDDyuOrYa0aynZv4L3O+Tfi58RsMHhZuaeEKq3QXD7wVf5fhZr1dxU403+3mkROvtusNhzaMMcYY+8ceHAgAAAAAAPm/NoKqqqqqqqqqqqqqqqqqqgp7cCAAAAAAAOT/2giqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkp7cEgAAAAAIOj/a2dYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF4BjB5ee44lPcgAAAAASUVORK5CYII=",pa=Z({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/*"},bucket:{type:String,default:"gyt"},path:{type:String,default:""},uploadIcon:{type:String,default:Aa},size:{type:String,default:"default"},disabled:{type:Boolean,default:!1},position:{type:String,default:"outside"}},emits:["uploadChange","update:modelValue"],methods:{nativeUpload(){if(this.disabled)return;const e=this.uploadType==="VIDEO"?"video":"img";let t=1;this.maxCount>1?t=this.maxCount-this.modelValue.length:t=this.maxCount,Le({api:"chooseFile",content:{type:e,max:t,bucket:this.bucket,path:this.path}},n=>{if(console.log(n,"fileUrl"),this.maxCount>1){const a=n.fileUrl;console.log(a,"files"),this.$emit("update:modelValue",[...this.modelValue,...a.split(",")]),this.$emit("uploadChange",[...this.modelValue,...a.split(",")])}else this.$emit("update:modelValue",[n.fileUrl]),this.$emit("uploadChange",[n.fileUrl])})},beforeRead(e){return console.log(e,"beforeRead"),e.size/1024/1024<this.uploadSize?!0:(Oe(`上传文件大小不能超过 ${this.uploadSize}MB`),!1)},beforeDelete(){return!0},async afterRead(e){try{e.status="uploading",e.message="上传中...",await this.uploadFile(e.file)}catch(t){se()}},onClose(e,t){const n=this.modelValue,a=n.findIndex(i=>i==t);a>-1&&(n.splice(a,1),this.$emit("update:modelValue",n),this.$emit("uploadChange")),e.stopPropagation()},async getFile(e){try{await this.uploadFile(e)}catch(t){}},async uploadFile(e){try{const t="/api-web/getUploadSign",n=e.name||"",a=this.path+"/"+(n&&n.replace(/ /gi,"_")),i=new Date().getTime()+a;console.log(e);const f=await Xe.post(t,{data:{filename:a,bucketName:this.bucket,postData:{filename:a,acl:"public-read",key:i,unknowValueField:[]}}});Ze({message:"加载中...",forbidClick:!0,loadingType:"spinner",duration:0});const b={policy:f.data.policy,signature:f.data.signature,key:i,KSSAccessKeyId:f.data.kssAccessKeyId,acl:"public-read",name:a},C=new FormData;for(const r in b)C.append(r,b[r]);C.append("file",e,a),await Ke(J(this.bucket),{method:"POST",data:C}),console.log(J(this.bucket)+i);const A=J(this.bucket)+i;se(),this.maxCount>1?(this.$emit("update:modelValue",[...this.modelValue,A]),this.$emit("uploadChange",[...this.modelValue,A])):(this.$emit("update:modelValue",[A]),this.$emit("uploadChange",[A]))}catch(t){console.log(t,"uploadFile")}}},render(){return ve(()=>this.modelValue),o("div",{class:g["uploader-section"]},[this.modelValue.length>0&&this.maxCount>1&&this.modelValue.map(e=>o("div",{class:["van-uploader",g.uploader,g[this.size]]},[this.deletable&&!this.disabled&&o(P,{name:"cross",onClick:t=>this.onClose(t,e),class:g["img-close"]},null),o("div",{class:["van-uploader__upload"]},[this.uploadType==="IMAGE"?o(X,{src:e+"@base@tag=imgScale&w=200",class:g.previewImg,fit:"cover"},null):o("video",{ref:"videoUpload",style:{backgroundColor:"#F8F8F8"},class:g.previewImg,poster:_,src:e+"#t=1,4"},null)])])),this.native?this.maxCount>1?this.modelValue.length<this.maxCount&&o("div",{class:["van-uploader",g.uploader,g[this.size]],onClick:this.nativeUpload},[o(P,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):o("div",{class:["van-uploader",g.uploader,g[this.size]],onClick:this.nativeUpload},[this.modelValue.length>0?o("div",{class:["van-uploader__upload"]},[this.modelValue.map(e=>o(ie,null,[this.deletable&&!this.disabled&&o(P,{name:"cross",onClick:t=>this.onClose(t,e),class:[g["img-close"],g.singleImgClose]},null),this.uploadType==="IMAGE"?o(X,{fit:"cover",position:"center",class:g.uploadImg,src:e+"@base@tag=imgScale&w=200"},null):o("video",{ref:"videoUpload",class:g.uploadImg,style:{backgroundColor:"#F8F8F8"},poster:_,src:e+"#t=1,4"},null)]))]):o(P,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]):this.maxCount>1?this.modelValue.length<this.maxCount&&o(ce,{class:["van-uploader",g.uploader,g[this.size]],afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete,uploadIcon:this.uploadIcon,maxCount:this.maxCount,disabled:this.disabled,accept:this.accept},null):o(ce,{class:["van-uploader",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?o("div",{class:["van-uploader__upload"]},[this.modelValue.map(e=>o(ie,null,[this.deletable&&!this.disabled&&o(P,{name:"cross",onClick:t=>this.onClose(t,e),class:[g["img-close"],g.singleImgClose]},null),this.uploadType==="IMAGE"?o(X,{fit:"cover",position:"center",class:g.uploadImg,src:e+"@base@tag=imgScale&w=200"},null):o("video",{ref:"videoUpload",class:g.uploadImg,style:{backgroundColor:"#F8F8F8"},poster:_,src:e+"#t=1,4"},null)]))]):o(P,{name:this.uploadIcon,class:["van-uploader__upload"],size:"32"},null)]}),this.$slots.default&&this.$slots.default()])}});export{pa as M,ce as U,Aa as a,_ as i,g as s};
|