su-swiper.55cf865c.js 4.8 KB

1
  1. import{v as e,e as t,f as a,w as i,j as s,y as l,af as r,ag as u,i as o,ah as d,c as n,l as p,m as c,z as g,u as y,k as m,F as f,r as h,s as v,g as b,p as _,t as w,a8 as S,ai as T,q as k,R as x,T as P}from"./index-9880b451.js";import{_ as N}from"./_plugin-vue_export-helper.1b428a4d.js";const H=N({__name:"su-video",props:{moveX:{type:[Number],default:0},uid:{type:[Number,String],default:0},height:{type:Number,default:300},width:{type:Number,default:750},initialTime:{type:Number,default:1},src:{type:String,default:""},poster:{type:String,default:"https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto"},autoplay:{type:Boolean,default:!1}},emits:["videoTimeupdate"],setup(n,{expose:p,emit:c}){const g=n,y=d(),m=e({enableProgressGesture:!1,showModal:!1}),f=e=>{c("videoTimeupdate",e)},h=e=>{console.log("视频错误信息:",e.target.errMsg)},v=()=>{console.log("视频开始")},b=()=>{console.log("视频暂停")},_=()=>{console.log("视频结束")};return p({pausePlay:()=>{r(`sVideo${g.index}`,y).pause()}}),(e,r)=>{const d=u,p=o;return t(),a(p,{class:"ui-video-wrap"},{default:i((()=>[s(d,{id:`sVideo${n.uid}`,class:"radius",style:l([{height:n.height+"rpx"}]),src:n.src,controls:"","object-fit":"contain","enable-progress-gesture":m.enableProgressGesture,"initial-time":n.initialTime,"x5-video-player-type":"h5","x-webkit-airplay":"allow","webkit-playsinline":"true",onError:h,onTimeupdate:f,onPlay:v,onPause:b,onEnded:_,poster:n.poster,autoplay:n.autoplay},null,8,["id","style","src","enable-progress-gesture","initial-time","poster","autoplay"])])),_:1})}}},[["__scopeId","data-v-f5e784aa"]]),$=N({__name:"su-swiper",props:{circular:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},interval:{type:Number,default:3e3},duration:{type:Number,default:500},mode:{type:String,default:"default"},imageMode:{type:String,default:"scaleToFill"},list:{type:Array,default:()=>[]},dotStyle:{type:String,default:"long"},dotCur:{type:String,default:"ss-bg-opactity-block"},bg:{type:String,default:"bg-none"},height:{type:Number,default:0},imgHeight:{type:Number,default:0},imgTopRadius:{type:Number,default:0},imgBottomRadius:{type:Number,default:0},isPreview:{type:Boolean,default:!1},seizeHeight:{type:Number,default:200}},setup(r){const u=r,d=e({imgHeight:0,cur:0,moveX:0,videoPlaySataus:!1,heightList:[]}),N=e({videoRef:{}}),$=e=>{"touch"!==e.detail.source&&"autoplay"!==e.detail.source||(d.cur=e.detail.current,d.videoPlaySataus=!1,"video"===u.list[d.cur].type&&N.videoRef[`video_${d.cur}`].pausePlay())},C=()=>{if(!u.isPreview)return;let e=S.clone(u.list);e.forEach(((t,a)=>{"video"===t.type&&e.splice(a,1)})),T({urls:e.length<1?[u.src]:e.reduce(((e,t)=>(e.push(t.src),e)),[]),current:d.cur})},R=e=>{},X=e=>{d.moveX=0},z=e=>{u.list[d.cur].currentTime=e.detail.currentTime},B=n((()=>{let e;return 0!==u.height&&(e=u.height),0===u.height&&(0!==d.imgHeight?e=d.imgHeight:0!==u.seizeHeight&&(e=u.seizeHeight)),{height:e+"rpx"}}));function j(e){if(0===u.height){let t=e.detail.height/e.detail.width*750;d.imgHeight<t&&(d.imgHeight=t)}}return(e,n)=>{const S=k,T=p(c("su-video"),H),M=o,E=x,V=P;return t(),a(M,null,{default:i((()=>[s(M,{class:g(["ui-swiper",[u.mode,u.bg,u.ui]])},{default:i((()=>[s(V,{circular:u.circular,current:d.cur,autoplay:u.autoplay&&!d.videoPlaySataus,interval:u.interval,duration:u.duration,onTransition:R,onAnimationfinish:X,style:l(y(B)),onChange:$},{default:i((()=>[(t(!0),m(f,null,h(u.list,((e,l)=>(t(),a(E,{class:g(["swiper-item",{cur:d.cur==l}]),key:l,onClick:t=>(e=>{"video"===e.type?d.videoPlaySataus=!0:(v.$router.go(e.url),C())})(e)},{default:i((()=>[s(M,{class:"ui-swiper-main"},{default:i((()=>["image"===e.type?(t(),a(S,{key:0,class:"swiper-image",mode:u.imageMode,src:e.src,width:"100%",height:"100%",onLoad:j},null,8,["mode","src"])):(t(),a(T,{key:1,ref_for:!0,ref:e=>N.videoRef[`video_${l}`]=e,poster:y(v).$url.cdn(e.poster),src:y(v).$url.cdn(e.src),index:l,moveX:d.moveX,initialTime:e.currentTime||0,height:r.seizeHeight,onVideoTimeupdate:z},null,8,["poster","src","index","moveX","initialTime","height"]))])),_:2},1024)])),_:2},1032,["class","onClick"])))),128))])),_:1},8,["circular","current","autoplay","interval","duration","style"]),d.videoPlaySataus?b("",!0):(t(),m(f,{key:0},["tag"!=u.dotStyle?(t(),a(M,{key:0,class:g(["ui-swiper-dot",u.dotStyle])},{default:i((()=>[(t(!0),m(f,null,h(u.list,((e,i)=>(t(),a(M,{class:g(["line-box",[d.cur==i?"cur":"",u.dotCur]]),key:i},null,8,["class"])))),128))])),_:1},8,["class"])):b("",!0),"tag"==u.dotStyle?(t(),a(M,{key:1,class:g(["ui-swiper-dot",u.dotStyle])},{default:i((()=>[s(M,{class:g(["ui-tag radius-lg",[u.dotCur]]),style:{"pointer-events":"none",padding:"0 10rpx"}},{default:i((()=>[s(M,{style:{transform:"scale(0.7)"}},{default:i((()=>[_(w(d.cur+1)+" / "+w(u.list.length),1)])),_:1})])),_:1},8,["class"])])),_:1},8,["class"])):b("",!0)],64))])),_:1},8,["class"])])),_:1})}}},[["__scopeId","data-v-c43ff05c"]]);export{$ as _,H as a};