1 |
- "use strict";const e=require("../../../../common/vendor.js");Math||t();const t=()=>"../wd-swiper-nav/wd-swiper-nav.js",o=e.defineComponent({name:"wd-swiper",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"},props:e.swiperProps,emits:["click","change","animationfinish","update:current"],setup(t,{emit:o}){const i=t,n=o,s=e.ref(i.current),a=e.ref(i.current),u=(e,t=!1)=>{a.value=e,t&&(s.value=e),n("update:current",e)},r=e.ref(!1),{proxy:l}=e.getCurrentInstance(),c=e.ref(e.uuid());e.watch((()=>i.current),(e=>{e<0?i.loop?f():m():e>=i.list.length?i.loop?m():f():v(e)}));const d=e.computed((()=>{const{list:t,direction:o,indicatorPosition:n,indicator:s}=i,u={current:a.value||0,total:t.length||0,direction:o||"horizontal",indicatorPosition:n||"bottom"};return e.isObj(s)&&(u.type=s.type||"dots",u.minShowNum=s.minShowNum||2,u.showControls=s.showControls||!1),u})),p=t=>((t,o)=>{const n=t=>e.isVideoUrl(t);return e.isObj(t)?t.type&&["video","image"].includes(t.type)?t.type===o:n(t[i.valueKey]):n(t)})(t,"video");function v(e){e!==a.value&&u(e,!0)}function m(){v(0)}function f(){v(i.list.length-1)}function h(){i.stopAutoplayWhenVideoPlay&&(r.value=!0)}function g(){r.value=!1}function y(e,t,o){let n="";return function(e,t,o){return(e-1+o.length)%o.length===t}(e,t,o)&&(n=i.customPrevClass||i.customPrevImageClass),function(e,t,o){return(e+1+o.length)%o.length===t}(e,t,o)&&(n=i.customNextClass||i.customNextImageClass),n}function w(t){const{current:o,source:s}=t.detail,r=a.value;if(n("change",{current:o,source:s}),o!==a.value){u(o,"autoplay"===s||"touch"===s)}!function(t,o){(function(t){if(i.stopPreviousVideo){const o=i.list[t];if(e.isDef(o)&&p(o)){e.index.createVideoContext(`video-${t}-${c.value}`,l).pause()}}else i.stopAutoplayWhenVideoPlay&&g()})(t),function(t){if(i.autoplayVideo){const o=i.list[t];if(e.isDef(o)&&p(o)){e.index.createVideoContext(`video-${t}-${c.value}`,l).play()}}}(o)}(r,o)}function x(e){const{current:t,source:o}=e.detail;if(t!==a.value){u(t,"autoplay"===o||"touch"===o)}n("animationfinish",{current:t,source:o})}function C(e,t){n("click",{index:e,item:t})}function $({dir:e}){const{list:t,loop:o}=i,n=t.length;let s="next"===e?a.value+1:a.value-1;s=o?"next"===e?(a.value+1)%n:(a.value-1+n)%n:s<0||s>=n?a.value:s,s!==a.value&&v(s)}return(t,o)=>e.e({a:e.f(t.list,((o,i,n)=>e.e({a:p(o)},p(o)?{b:`video-${i}-${c.value}`,c:e.unref(e.addUnit)(t.height),d:e.unref(e.isObj)(o)?o[t.valueKey]:o,e:e.unref(e.isObj)(o)?o.poster:"",f:e.n(`wd-swiper__video ${t.customItemClass} ${y(a.value,i,t.list)}`),g:e.o(h,i),h:e.o(g,i),i:t.videoLoop,j:t.muted,k:t.autoplayVideo,l:e.o((e=>C(i,o)),i)}:{m:e.unref(e.isObj)(o)?o[t.valueKey]:o,n:e.n(`wd-swiper__image ${t.customImageClass} ${t.customItemClass} ${y(a.value,i,t.list)}`),o:e.unref(e.addUnit)(t.height),p:t.imageMode,q:e.o((e=>C(i,o)),i)},{r:e.unref(e.isObj)(o)&&o[t.textKey]},e.unref(e.isObj)(o)&&o[t.textKey]?{s:e.t(o[t.textKey]),t:e.n(`wd-swiper__text ${t.customTextClass}`),v:e.s(t.customTextStyle)}:{},{w:i}))),b:t.adjustHeight,c:t.adjustVerticalHeight,d:t.autoplay&&!r.value,e:s.value,f:t.interval,g:t.duration,h:t.loop,i:"vertical"==t.direction,j:t.easingFunction,k:e.unref(e.addUnit)(t.previousMargin),l:e.unref(e.addUnit)(t.nextMargin),m:t.snapToEdge,n:t.displayMultipleItems,o:e.unref(e.addUnit)(t.height),p:e.o(w),q:e.o(x),r:t.indicator},t.indicator?e.e({s:e.r("indicator",{current:a.value,total:t.list.length}),t:!t.$slots.indicator},t.$slots.indicator?{}:{v:e.o($),w:e.p({"custom-class":t.customIndicatorClass,type:d.value.type,current:d.value.current,total:d.value.total,direction:d.value.direction,"indicator-position":d.value.indicatorPosition,"min-show-num":d.value.minShowNum,"show-controls":d.value.showControls})}):{},{x:e.n(`wd-swiper ${t.customClass}`),y:e.s(t.customStyle)})}}),i=e._export_sfc(o,[["__scopeId","data-v-3363b8d8"]]);wx.createComponent(i);
|