Files
yshop-pro-uniapp/unpackage/dist/build/h5/assets/uv-upload.8ada27d8.js

2 lines
8.4 KiB
JavaScript
Raw Normal View History

var e,t;import{G as a,H as s,o as i,j as l,w as o,h as u,z as r,L as n,B as c,bg as d,bh as p,bi as m,Y as h,Z as f,a8 as _,bj as y,bk as v,bb as g,bl as b,b9 as w,e as k,F as C,k as z,y as j,I as x,l as I,Q as S,a0 as F,m as $,p as D,A as B}from"./index-90c12cc1.js";import{_ as O}from"./uv-icon.c815b875.js";import{a as P}from"./uv-loading-icon.ad70964c.js";import{_ as R}from"./uv-popup.a2d35ebb.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,d,p,m,h){const f=n,_=c,y=a(s("uv-popup"),R);return i(),l(y,{ref:"popup",onChange:h.change},{default:o((()=>[m.show?(i(),l(_,{key:0,class:"video-view"},{default:o((()=>[u(f,{class:"video",src:h.getSec,autoplay:d.autoplay},null,8,["src","autoplay"])])),_:1})):r("",!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 U({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":m({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":p({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":d({count:t?u:1,type:e,success:e=>r(L(e)),fail:n});break;default:d({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:[h,f,{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||_(e.url||e.thumb),isVideo:"video"===this.accept||y(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=v(this.capture)?this.capture:this.capture.split(",")}catch(l){i=[]}U(Object.assign({accept:this.accept,mu