2 lines
8.4 KiB
JavaScript
2 lines
8.4 KiB
JavaScript
![]() |
var e,t;import{g as a,o as s,c as i,w as l,a as o,m as u,aM as r,d as n,aN as c,aO as d,aP as p,x as m,y as h,z as f,aQ as _,aR as y,a5 as v,aS as g,aL as b,b as w,F as k,r as C,A as x,h as z,t as S,p as j,j as I,n as F,i as $,B as R}from"./index-3714412c.js";import{_ as D}from"./uv-icon.c593f91d.js";import{r as P}from"./useRouter.f44141c1.js";import{_ as B}from"./uv-loading-icon.8ba359c8.js";import{_ as O}from"./uv-popup.e5d0df45.js";import{_ as T}from"./_plugin-vue_export-helper.1b428a4d.js";const A=T({props:{src:{type:String,default:""},autoplay:{type:Boolean,default:!0}},data:()=>({videoSrc:"",show:!1}),computed:{getSec(){return this.src||this.videoSrc}},methods:{open(e){this.videoSrc=e,this.$refs.popup.open()},close(){this.$refs.popup.close()},change(e){this.show=e.show}}},[["render",function(e,t,c,d,p,m){const h=r,f=n,_=P(a("uv-popup"),O);return s(),i(_,{ref:"popup",onChange:m.change},{default:l((()=>[p.show?(s(),i(f,{key:0,class:"video-view"},{default:l((()=>[o(h,{class:"video",src:m.getSec,autoplay:c.autoplay},null,8,["src","autoplay"])])),_:1})):u("",!0)])),_:1},8,["onChange"])}],["__scopeId","data-v-ca9595a3"]]);function V(e,t){return["[object Object]","[object File]"].includes(Object.prototype.toString.call(e))?Object.keys(e).reduce(((a,s)=>(t.includes(s)||(a[s]=e[s]),a)),{}):{}}function L(e){return e.tempFiles.map((e=>({...V(e,["path"]),url:e.path,size:e.size,name:e.name,type:e.type})))}function M({accept:e,multiple:t,capture:a,compressed:s,maxDuration:i,sizeType:l,camera:o,maxCount:u}){return new Promise(((r,n)=>{switch(e){case"image":p({count:t?Math.min(u,9):1,sourceType:a,sizeType:l,success:e=>r(function(e){return e.tempFiles.map((e=>({...V(e,["path"]),type:"image",url:e.path,thumb:e.path,size:e.size,name:e.name})))}(e)),fail:n});break;case"video":d({sourceType:a,compressed:s,maxDuration:i,camera:o,success:e=>r(function(e){return[{...V(e,["tempFilePath","thumbTempFilePath","errMsg"]),type:"video",url:e.tempFilePath,thumb:e.thumbTempFilePath,size:e.size,name:e.name}]}(e)),fail:n});break;case"file":c({count:t?u:1,type:e,success:e=>r(L(e)),fail:n});break;default:c({count:t?u:1,type:"all",success:e=>r(L(e)),fail:n})}}))}const N=T({name:"uv-upload",emits:["error","beforeRead","oversize","afterRead","delete","clickPreview"],mixins:[m,h,{watch:{accept:{immediate:!0,handler(e){}}}},{props:{accept:{type:String,default:"image"},capture:{type:[String,Array],default:()=>["album","camera"]},compressed:{type:Boolean,default:!0},camera:{type:String,default:"back"},maxDuration:{type:Number,default:60},uploadIcon:{type:String,default:"camera-fill"},uploadIconColor:{type:String,default:"#D3D4D6"},useBeforeRead:{type:Boolean,default:!1},afterRead:{type:Function,default:null},beforeRead:{type:Function,default:null},previewFullImage:{type:Boolean,default:!0},previewFullVideo:{type:Boolean,default:!0},maxCount:{type:[String,Number],default:52},disabled:{type:Boolean,default:!1},imageMode:{type:String,default:"aspectFill"},name:{type:String,default:""},sizeType:{type:Array,default:()=>["original","compressed"]},multiple:{type:Boolean,default:!1},deletable:{type:Boolean,default:!0},maxSize:{type:[String,Number],default:Number.MAX_VALUE},fileList:{type:Array,default:()=>[]},uploadText:{type:String,default:""},width:{type:[String,Number],default:80},height:{type:[String,Number],default:80},previewImage:{type:Boolean,default:!0},...null==(t=null==(e=uni.$uv)?void 0:e.props)?void 0:t.upload}}],data:()=>({lists:[],isInCount:!0}),watch:{fileList:{deep:!0,immediate:!0,handler(){this.formatFileList()}}},methods:{formatFileList(){const{fileList:e=[],maxCount:t}=this,a=e.map((e=>Object.assign(Object.assign({},e),{isImage:"image"===this.accept||f(e.url||e.thumb),isVideo:"video"===this.accept||_(e.url||e.thumb),deletable:"boolean"==typeof e.deletable?e.deletable:this.deletable})));this.lists=a,this.isInCount=a.length<t},chooseFile(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{const{maxCount:e,multiple:t,lists:a,disabled:s}=this;if(s)return;let i;try{i=y(this.capture)?this.capture:this.capture.split(",")}catch(l){i=[]}M(
|