import{aw as o,an as t,ah as e,M as s,N as l,v as i,G as n,o as r,d as p,w as a,e as c,H as d,L as m,x as h,f as u,t as w,_ as x,Q as f,R as T,i as g,a3 as y}from"./index-C0ioWTxp.js";import{r as b,b as B,W as S,a as H,m as L,c as k,G as D,_ as C}from"./mescroll-mixins.BldZscRg.js";import{r as O}from"./uni-app.es.BJUZsD-t.js";import{_ as v}from"./_plugin-vue_export-helper.BCo6x5W8.js";const _={mixins:[b]},E=o=>{o.$renderjs||(o.$renderjs=[]),o.$renderjs.push("renderBiz"),o.mixins||(o.mixins=[]),o.mixins.push({beforeCreate(){this.renderBiz=this},mounted(){this.$ownerInstance=this.$gcd(this,!0)}}),o.mixins.push(_)},N={name:"mescroll-uni",mixins:[S],components:{MescrollTop:H},props:{down:Object,up:Object,i18n:Object,top:[String,Number],topbar:[Boolean,String],bottom:[String,Number],safearea:Boolean,fixed:{type:Boolean,default:!0},height:[String,Number],bottombar:{type:Boolean,default:!0},disableScroll:Boolean},data:()=>({mescroll:{optDown:{},optUp:{}},viewId:"id_"+Math.random().toString(36).substr(2,16),downHight:0,downRate:0,downLoadType:0,upLoadType:0,isShowEmpty:!1,isShowToTop:!1,scrollTop:0,scrollAnim:!1,windowTop:0,windowBottom:0,windowHeight:0,statusBarHeight:0}),watch:{height(){this.setClientHeight()}},computed:{isFixed(){return!this.height&&this.fixed},scrollHeight(){return this.isFixed?"auto":this.height?this.toPx(this.height)+"px":"100%"},numTop(){return this.toPx(this.top)},fixedTop(){return this.isFixed?this.numTop+this.windowTop+"px":0},padTop(){return this.isFixed?0:this.numTop+"px"},numBottom(){return this.toPx(this.bottom)},fixedBottom(){return this.isFixed?this.numBottom+this.windowBottom+"px":0},padBottom(){return this.isFixed?0:this.numBottom+"px"},isDownReset(){return 3===this.downLoadType||4===this.downLoadType},transition(){return this.isDownReset?"transform 300ms":""},translateY(){return this.downHight>0?"translateY("+this.downHight+"px)":""},scrollable(){return!this.disableScroll&&(0===this.downLoadType||this.isDownReset)},isDownLoading(){return 3===this.downLoadType},downRotate(){return"rotate("+360*this.downRate+"deg)"},downText(){if(!this.mescroll)return"";switch(this.downLoadType){case 1:default:return this.mescroll.optDown.textInOffset;case 2:return this.mescroll.optDown.textOutOffset;case 3:return this.mescroll.optDown.textLoading;case 4:return this.mescroll.isDownEndSuccess?this.mescroll.optDown.textSuccess:0==this.mescroll.isDownEndSuccess?this.mescroll.optDown.textErr:this.mescroll.optDown.textInOffset}}},methods:{toPx(t){if("string"==typeof t)if(-1!==t.indexOf("px"))if(-1!==t.indexOf("rpx"))t=t.replace("rpx","");else{if(-1===t.indexOf("upx"))return Number(t.replace("px",""));t=t.replace("upx","")}else if(-1!==t.indexOf("%")){let o=Number(t.replace("%",""))/100;return this.windowHeight*o}return t?o(Number(t)):0},scroll(o){this.mescroll.scroll(o.detail,(()=>{this.$emit("scroll",this.mescroll)}))},emptyClick(){this.$emit("emptyclick",this.mescroll)},toTopClick(){this.mescroll.scrollTo(0,this.mescroll.optUp.toTop.duration),this.$emit("topclick",this.mescroll)},setClientHeight(){this.isExec||(this.isExec=!0,this.$nextTick((()=>{this.getClientInfo((o=>{this.isExec=!1,o?this.mescroll.setClientHeight(o.height):3!=this.clientNum&&(this.clientNum=null==this.clientNum?1:this.clientNum+1,setTimeout((()=>{this.setClientHeight()}),100*this.clientNum))}))})))},getClientInfo(o){t().in(this).select("#"+this.viewId).boundingClientRect((t=>{o(t)})).exec()}},created(){let o=this,l={down:{inOffset(){o.downLoadType=1},outOffset(){o.downLoadType=2},onMoving(t,e,s){o.downHight=s,o.downRate=e},showLoading(t,e){o.downLoadType=3,o.downHight=e},beforeEndDownScroll:t=>(o.downLoadType=4,t.optDown.beforeEndDelay),endDownScroll(){o.downLoadType=4,o.downHight=0,o.downResetTimer&&clearTimeout(o.downResetTimer),o.downResetTimer=setTimeout((()=>{4===o.downLoadType&&(o.downLoadType=0)}),300)},callback:function(t){o.$emit("down",t)}},up:{showLoading(){o.upLoadType=1},showNoMore(){o.upLoadType=2},hideUpScroll(t){o.upLoadType=t.optUp.hasNext?0:3},empty:{onShow(t){o.isShowEmpty=t}},toTop:{onShow(t){o.isShowToTop=t}},callback:function(t){o.$emit("up",t),o.setClientHeight()}}},i=L.getType(),n={type:i};k.extend(n,o.i18n),k.extend(n,D.i18n),k.extend(l,n[i]),k.extend(l,{down:D.down,up:D.up});let r=JSON.parse(JSON.stringify({down:o.down,up:o.up}));k.extend(r,l),o.mescroll=new k(r),o.mescroll.viewId=o.viewId,o.mescroll.i18n=n,o.$emit("init",o.mescroll);const p=e();p.windowTop&&(o.windowTop=p.windowTop),p.windowBottom&&(o.windowBottom=p.windowBottom),p.windowHeight&&(o.windowHeight=p.windowHeight),p.statusBarHeight&&(o.statusBarHeight=p.statusBarHeight),o.mescroll.setBodyHeight(p.windowHeight),o.mescroll.resetScrollTo(((e,s)=>{if(o.scrollAnim=0!==s,"string"==typeof e)return void o.getClientInfo((function(s){let l,i=s.top;-1==e.indexOf("#")&&-1==e.indexOf(".")?l="#"+e:(l=e,-1!=e.indexOf(">>>")&&(l=e.split(">>>")[1].trim())),t().select(l).boundingClientRect((function(t){if(t){let e=o.mescroll.getScrollTop(),s=t.top-i;s+=e,o.isFixed||(s-=o.numTop),o.scrollTop=e,o.$nextTick((function(){o.scrollTop=s}))}else console.error(l+" does not exist")})).exec()}));let l=o.mescroll.getScrollTop();0===s||300===s?(o.scrollTop=l,o.$nextTick((function(){o.scrollTop=e}))):o.mescroll.getStep(l,e,(t=>{o.scrollTop=t}),s)})),o.up&&o.up.toTop&&null!=o.up.toTop.safearea||(o.mescroll.optUp.toTop.safearea=o.safearea),s("setMescrollGlobalOption",(t=>{if(!t)return;let e=t.i18n?t.i18n.type:null;if(e&&o.mescroll.i18n.type!=e&&(o.mescroll.i18n.type=e,L.setType(e),k.extend(t,o.mescroll.i18n[e])),t.down){let e=k.extend({},t.down);o.mescroll.optDown=k.extend(e,o.mescroll.optDown)}if(t.up){let e=k.extend({},t.up);o.mescroll.optUp=k.extend(e,o.mescroll.optUp)}}))},mounted(){this.setClientHeight()},destroyed(){l("setMescrollGlobalOption")}};"function"==typeof B&&B(N),E(N);const U=v(N,[["render",function(o,t,e,s,l,b){const B=g,S=O(i("mescroll-empty"),C),H=y,L=n("mescroll-top");return r(),p(B,{class:"mescroll-uni-warp"},{default:a((()=>[c(H,{id:l.viewId,class:d(["mescroll-uni",{"mescroll-uni-fixed":b.isFixed}]),style:m({height:b.scrollHeight,"padding-top":b.padTop,"padding-bottom":b.padBottom,top:b.fixedTop,bottom:b.fixedBottom}),"scroll-top":l.scrollTop,"scroll-with-animation":l.scrollAnim,onScroll:b.scroll,"scroll-y":b.scrollable,"enable-back-to-top":!0,throttle:!1},{default:a((()=>[c(B,{class:"mescroll-uni-content mescroll-render-touch",onTouchstart:o.wxsBiz.touchstartEvent,onTouchmove:o.wxsBiz.touchmoveEvent,onTouchend:o.wxsBiz.touchendEvent,onTouchcancel:o.wxsBiz.touchendEvent,"change:prop":o.wxsBiz.propObserver,prop:o.wxsProp},{default:a((()=>[e.topbar&&l.statusBarHeight?(r(),p(B,{key:0,class:"mescroll-topbar",style:m({height:l.statusBarHeight+"px",background:e.topbar})},null,8,["style"])):h("",!0),c(B,{class:"mescroll-wxs-content",style:m({transform:b.translateY,transition:b.transition}),"change:prop":o.wxsBiz.callObserver,prop:o.callProp},{default:a((()=>[l.mescroll.optDown.use?(r(),p(B,{key:0,class:"mescroll-downwarp",style:m({background:l.mescroll.optDown.bgColor,color:l.mescroll.optDown.textColor})},{default:a((()=>[c(B,{class:"downwarp-content"},{default:a((()=>[c(B,{class:d(["downwarp-progress mescroll-wxs-progress",{"mescroll-rotate":b.isDownLoading}]),style:m({"border-color":l.mescroll.optDown.textColor,transform:b.downRotate})},null,8,["class","style"]),c(B,{class:"downwarp-tip"},{default:a((()=>[u(w(b.downText),1)])),_:1})])),_:1})])),_:1},8,["style"])):h("",!0),x(o.$slots,"default",{},void 0,!0),l.isShowEmpty?(r(),p(S,{key:1,option:l.mescroll.optUp.empty,onEmptyclick:b.emptyClick},null,8,["option","onEmptyclick"])):h("",!0),l.mescroll.optUp.use&&!b.isDownLoading&&3!==l.upLoadType?(r(),p(B,{key:2,class:"mescroll-upwarp",style:m({background:l.mescroll.optUp.bgColor,color:l.mescroll.optUp.textColor})},{default:a((()=>[f(c(B,null,{default:a((()=>[c(B,{class:"upwarp-progress mescroll-rotate",style:m({"border-color":l.mescroll.optUp.textColor})},null,8,["style"]),c(B,{class:"upwarp-tip"},{default:a((()=>[u(w(l.mescroll.optUp.textLoading),1)])),_:1})])),_:1},512),[[T,1===l.upLoadType]]),2===l.upLoadType?(r(),p(B,{key:0,class:"upwarp-nodata"},{default:a((()=>[u(w(l.mescroll.optUp.textNoMore),1)])),_:1})):h("",!0)])),_:1},8,["style"])):h("",!0)])),_:3},8,["style","change:prop","prop"]),e.bottombar&&l.windowBottom>0?(r(),p(B,{key:1,class:"mescroll-bottombar",style:m({height:l.windowBottom+"px"})},null,8,["style"])):h("",!0),e.safearea?(r(),p(B,{key:2,class:"mescroll-safearea"})):h("",!0)])),_:3},8,["onTouchstart","onTouchmove","onTouchend","onTouchcancel","change:prop","prop"])])),_:3},8,["id","class","style","scroll-top","scroll-with-animation","onScroll","scroll-y"]),c(L,{modelValue:l.isShowToTop,"onUpdate:modelValue":t[0]||(t[0]=o=>l.isShowToTop=o),option:l.mescroll.optUp.toTop,onClick:b.toTopClick},null,8,["modelValue","option","onClick"]),c(B,{"change:prop":o.renderBiz.propObserver,prop:o.wxsProp},null,8,["change:prop","prop"])])),_:3})}],["__scopeId","data-v-e1681846"]]);export{U as _};
-
zuoliyuan authored2d40a35a