2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
import{bk as C,bl as M,x as b,c as f,j as d,w as u,k as g,af as w,l as _,b2 as E,m as T,t as D,aa as m,s as U,bm as O,bn as N,f as z,g as Y,a as A,aq as R,bo as I,bp as j,bq as V,br as q,bs as X,bt as L,bu as F,bv as W}from"./index-B-O76M86.js";const S={down:{offset:80,native:!1},up:{offset:150,toTop:{src:"https://www.mescroll.com/img/mescroll-totop.png",offset:1e3,right:20,bottom:120,width:72},empty:{use:!0,icon:"https://www.mescroll.com/img/mescroll-empty.png"}},i18n:{zh:{down:{textInOffset:"下拉刷新",textOutOffset:"释放更新",textLoading:"加载中 ...",textSuccess:"加载成功",textErr:"加载失败"},up:{textLoading:"加载中 ...",textNoMore:"-- END --",empty:{tip:"~ 空空如也 ~"}}},en:{down:{textInOffset:"drop down refresh",textOutOffset:"release updates",textLoading:"loading ...",textSuccess:"loaded successfully",textErr:"loading failed"},up:{textLoading:"loading ...",textNoMore:"-- END --",empty:{tip:"~ absolutely empty ~"}}}}},x={def:"zh",getType(){return M("mescroll-i18n")||this.def},setType(t){C("mescroll-i18n",t)}},G={props:{option:{type:Object,default(){return{}}}},computed:{icon(){if(this.option.icon!=null)return this.option.icon;{let t=x.getType();return this.option.i18n?this.option.i18n[t].icon:S.i18n[t].up.empty.icon||S.up.empty.icon}},tip(){if(this.option.tip!=null)return this.option.tip;{let t=x.getType();return this.option.i18n?this.option.i18n[t].tip:S.i18n[t].up.empty.tip||S.up.empty.tip}},btnText(){if(this.option.i18n){let t=x.getType();return this.option.i18n[t].btnText}else return this.option.btnText}},methods:{emptyClick(){this.$emit("emptyclick")}}};function J(t,o,n,i,p,r){const l=E,c=_;return d(),f(c,{class:U(["mescroll-empty",{"empty-fixed":n.option.fixed}]),style:m({"z-index":n.option.zIndex,top:n.option.top})},{default:u(()=>[g(c,null,{default:u(()=>[r.icon?(d(),f(l,{key:0,class:"empty-icon",src:r.icon,mode:"widthFix"},null,8,["src"])):w("",!0)]),_:1}),r.tip?(d(),f(c,{key:0,class:"empty-tip"},{default:u(()=>[T(D(r.tip),1)]),_:1})):w("",!0),r.btnText?(d(),f(c,{key:1,class:"empty-btn",onClick:r.emptyClick},{default:u(()=>[T(D(r.btnText),1)]),_:1},8,["onClick"])):w("",!0)]),_:1},8,["class","style"])}const Q=b(G,[["render",J],["__scopeId","data-v-3c1177fa"]]);function s(t,o){let n=this;n.version="1.3.7",n.options=t||{},n.isScrollBody=o||!1,n.isDownScrolling=!1,n.isUpScrolling=!1;let i=n.options.down&&n.options.down.callback;n.initDownScroll(),n.initUpScroll(),setTimeout(function(){(n.optDown.use||n.optDown.native)&&n.optDown.auto&&i&&(n.optDown.autoShowLoading?n.triggerDownScroll():n.optDown.callback&&n.optDown.callback(n)),n.isUpAutoLoad||setTimeout(function(){n.optUp.use&&n.optUp.auto&&!n.isUpAutoLoad&&n.triggerUpScroll()},100)},30)}s.prototype.extendDownScroll=function(t){s.extend(t,{use:!0,auto:!0,native:!1,autoShowLoading:!1,isLock:!1,offset:80,startTop:100,inOffsetRate:1,outOffsetRate:.2,bottomOffset:20,minAngle:45,textInOffset:"下拉刷新",textOutOffset:"释放更新",textLoading:"加载中 ...",textSuccess:"加载成功",textErr:"加载失败",beforeEndDelay:0,bgColor:"transparent",textColor:"gray",inited:null,inOffset:null,outOffset:null,onMoving:null,beforeLoading:null,showLoading:null,afterLoading:null,beforeEndDownScroll:null,endDownScroll:null,afterEndDownScroll:null,callback:function(o){o.resetUpScroll()}})};s.prototype.extendUpScroll=function(t){s.extend(t,{use:!0,auto:!0,isLock:!1,isBoth:!0,callback:null,page:{num:0,size:10,time:null},noMoreSize:5,offset:150,textLoading:"加载中 ...",textNoMore:"-- END --",bgColor:"transparent",textColor:"gray",inited:null,showLoading:null,showNoMore:null,hideUpScroll:null,errDistance:60,toTop:{src:null,offset:1e3,duration:300,btnClick:null,onShow:null,zIndex:9990,left:null,right:20,bottom:120,safearea:!1,width:72,radius:"50%"},empty:{use:!0,icon:null,tip:"~ 暂无相关数据 ~",btnText:"",btnClick:null,onShow:null,fixed:!1,top:"100rpx",zIndex:99},onScroll:!1})};s.extend=function(t,o){if(!t)return o;for(let n in o)if(t[n]==null){let i=o[n];i!=null&&typeof i=="object"?t[n]=s.extend({},i):t[n]=i}else typeof t[n]=="object"&&s.extend(t[n],o[n]);return t};s.prototype.hasColor=function(t){if(!t)return!1;let o=t.toLowerCase();return o!="#fff"&&o!="#ffffff"&&o!="transparent"&&o!="white"};s.prototype.initDownScroll=function(){let t=this;t.optDown=t.options.down||{},!t.optDown.textColor&&t.hasColor(t.optDown.bgColor)&&(t.optDown.textColor="#fff"),t.extendDownScroll(t.optDown),t.isScrollBody&&t.optDown.native?t.optDown.use=!1:t.optDown.native=!1,t.downHight=0,t.optDown.use&&t.optDown.inited&&setTimeout(function(){t.optDown.inited(t)},0)};s.prototype.touchstartEvent=function(t){this.optDown.use&&(this.startPoint=this.getPoint(t),this.startTop=this.getScrollTop(),this.startAngle=0,this.lastPoint=this.startPoint,this.maxTouchmoveY=this.getBodyHeight()-this.optDown.bottomOffset,this.inTouchend=!1)};s.prototype.touchmoveEvent=function(t){if(!this.optDown.use)return;let o=this,n=o.getScrollTop(),i=o.getPoint(t);if(i.y-o.startPoint.y>0&&(o.isScrollBody&&n<=0||!o.isScrollBody&&(n<=0||n<=o.optDown.startTop&&n===o.startTop))&&!o.inTouchend&&!o.isDownScrolling&&!o.optDown.isLock&&(!o.isUpScrolling||o.isUpScrolling&&o.optUp.isBoth)){if(o.startAngle||(o.startAngle=o.getAngle(o.lastPoint,i)),o.startAngle<o.optDown.minAngle)return;if(o.maxTouchmoveY>0&&i.y>=o.maxTouchmoveY){o.inTouchend=!0,o.touchendEvent();return}o.preventDefault(t);let r=i.y-o.lastPoint.y;o.downHight<o.optDown.offset?(o.movetype!==1&&(o.movetype=1,o.isDownEndSuccess=null,o.optDown.inOffset&&o.optDown.inOffset(o),o.isMoveDown=!0),o.downHight+=r*o.optDown.inOffsetRate):(o.movetype!==2&&(o.movetype=2,o.optDown.outOffset&&o.optDown.outOffset(o),o.isMoveDown=!0),r>0?o.downHight+=r*o.optDown.outOffsetRate:o.downHight+=r),o.downHight=Math.round(o.downHight);let l=o.downHight/o.optDown.offset;o.optDown.onMoving&&o.optDown.onMoving(o,l,o.downHight)}o.lastPoint=i};s.prototype.touchendEvent=function(t){this.optDown.use&&(this.isMoveDown?(this.downHight>=this.optDown.offset?this.triggerDownScroll():(this.downHight=0,this.endDownScrollCall(this)),this.movetype=0,this.isMoveDown=!1):!this.isScrollBody&&this.getScrollTop()===this.startTop&&this.getPoint(t).y-this.startPoint.y<0&&this.getAngle(this.getPoint(t),this.startPoint)>80&&this.triggerUpScroll(!0))};s.prototype.getPoint=function(t){return t?t.touches&&t.touches[0]?{x:t.touches[0].pageX,y:t.touches[0].pageY}:t.changedTouches&&t.changedTouches[0]?{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY}:{x:t.clientX,y:t.clientY}:{x:0,y:0}};s.prototype.getAngle=function(t,o){let n=Math.abs(t.x-o.x),i=Math.abs(t.y-o.y),p=Math.sqrt(n*n+i*i),r=0;return p!==0&&(r=Math.asin(i/p)/Math.PI*180),r};s.prototype.triggerDownScroll=function(){this.optDown.beforeLoading&&this.optDown.beforeLoading(this)||(this.showDownScroll(),!this.optDown.native&&this.optDown.callback&&this.optDown.callback(this))};s.prototype.showDownScroll=function(){this.isDownScrolling=!0,this.optDown.native?(O(),this.showDownLoadingCall(0)):(this.downHight=this.optDown.offset,this.showDownLoadingCall(this.downHight))};s.prototype.showDownLoadingCall=function(t){this.optDown.showLoading&&this.optDown.showLoading(this,t),this.optDown.afterLoading&&this.optDown.afterLoading(this,t)};s.prototype.onPullDownRefresh=function(){this.isDownScrolling=!0,this.showDownLoadingCall(0),this.optDown.callback&&this.optDown.callback(this)};s.prototype.endDownScroll=function(){if(this.optDown.native){this.isDownScrolling=!1,this.endDownScrollCall(this),N();return}let t=this,o=function(){t.downHight=0,t.isDownScrolling=!1,t.endDownScrollCall(t),t.isScrollBody||(t.setScrollHeight(0),t.scrollTo(0,0))},n=0;t.optDown.beforeEndDownScroll&&(n=t.optDown.beforeEndDownScroll(t),t.isDownEndSuccess==null&&(n=0)),typeof n=="number"&&n>0?setTimeout(o,n):o()};s.prototype.endDownScrollCall=function(){this.optDown.endDownScroll&&this.optDown.endDownScroll(this),this.optDown.afterEndDownScroll&&this.optDown.afterEndDownScroll(this)};s.prototype.lockDownScroll=function(t){t==null&&(t=!0),this.optDown.isLock=t};s.prototype.lockUpScroll=function(t){t==null&&(t=!0),this.optUp.isLock=t};s.prototype.initUpScroll=function(){let t=this;t.optUp=t.options.up||{use:!1},!t.optUp.textColor&&t.hasColor(t.optUp.bgColor)&&(t.optUp.textColor="#fff"),t.extendUpScroll(t.optUp),t.optUp.use!==!1&&(t.optUp.hasNext=!0,t.startNum=t.optUp.page.num+1,t.optUp.inited&&setTimeout(function(){t.optUp.inited(t)},0))};s.prototype.onReachBottom=function(){this.isScrollBody&&!this.isUpScrolling&&!this.optUp.isLock&&this.optUp.hasNext&&this.triggerUpScroll()};s.prototype.onPageScroll=function(t){this.isScrollBody&&(this.setScrollTop(t.scrollTop),t.scrollTop>=this.optUp.toTop.offset?this.showTopBtn():this.hideTopBtn())};s.prototype.scroll=function(t,o){this.setScrollTop(t.scrollTop),this.setScrollHeight(t.scrollHeight),this.preScrollY==null&&(this.preScrollY=0),this.isScrollUp=t.scrollTop-this.preScrollY>0,this.preScrollY=t.scrollTop,this.isScrollUp&&this.triggerUpScroll(!0),t.scrollTop>=this.optUp.toTop.offset?this.showTopBtn():this.hideTopBtn(),this.optUp.onScroll&&o&&o()};s.prototype.triggerUpScroll=function(t){if(!this.isUpScrolling&&this.optUp.use&&this.optUp.callback){if(t===!0){let o=!1;if(this.optUp.hasNext&&!this.optUp.isLock&&!this.isDownScrolling&&this.getScrollBottom()<=this.optUp.offset&&(o=!0),o===!1)return}this.showUpScroll(),this.optUp.page.num++,this.isUpAutoLoad=!0,this.num=this.optUp.page.num,this.size=this.optUp.page.size,this.time=this.optUp.page.time,this.optUp.callback(this)}};s.prototype.showUpScroll=function(){this.isUpScrolling=!0,this.optUp.showLoading&&this.optUp.showLoading(this)};s.prototype.showNoMore=function(){this.optUp.hasNext=!1,this.optUp.showNoMore&&this.optUp.showNoMore(this)};s.prototype.hideUpScroll=function(){this.optUp.hideUpScroll&&this.optUp.hideUpScroll(this)};s.prototype.endUpScroll=function(t){t!=null&&(t?this.showNoMore():this.hideUpScroll()),this.isUpScrolling=!1};s.prototype.resetUpScroll=function(t){if(this.optUp&&this.optUp.use){let o=this.optUp.page;this.prePageNum=o.num,this.prePageTime=o.time,o.num=this.startNum,o.time=null,!this.isDownScrolling&&t!==!1&&(t==null?(this.removeEmpty(),this.showUpScroll()):this.showDownScroll()),this.isUpAutoLoad=!0,this.num=o.num,this.size=o.size,this.time=o.time,this.optUp.callback&&this.optUp.callback(this)}};s.prototype.setPageNum=function(t){this.optUp.page.num=t-1};s.prototype.setPageSize=function(t){this.optUp.page.size=t};s.prototype.endByPage=function(t,o,n){let i;this.optUp.use&&o!=null&&(i=this.optUp.page.num<o),this.endSuccess(t,i,n)};s.prototype.endBySize=function(t,o,n){let i;this.optUp.use&&o!=null&&(i=(this.optUp.page.num-1)*this.optUp.page.size+t<o),this.endSuccess(t,i,n)};s.prototype.endSuccess=function(t,o,n){let i=this;if(i.isDownScrolling&&(i.isDownEndSuccess=!0,i.endDownScroll()),i.optUp.use){let p;if(t!=null){let r=i.optUp.page.num,l=i.optUp.page.size;r===1&&n&&(i.optUp.page.time=n),t<l||o===!1?(i.optUp.hasNext=!1,t===0&&r===1?(p=!1,i.showEmpty()):((r-1)*l+t<i.optUp.noMoreSize?p=!1:p=!0,i.removeEmpty())):(p=!1,i.optUp.hasNext=!0,i.removeEmpty())}i.endUpScroll(p)}};s.prototype.endErr=function(t){if(this.isDownScrolling){this.isDownEndSuccess=!1;let o=this.optUp.page;o&&this.prePageNum&&(o.num=this.prePageNum,o.time=this.prePageTime),this.endDownScroll()}this.isUpScrolling&&(this.optUp.page.num--,this.endUpScroll(!1),this.isScrollBody&&t!==0&&(t||(t=this.optUp.errDistance),this.scrollTo(this.getScrollTop()-t,0)))};s.prototype.showEmpty=function(){this.optUp.empty.use&&this.optUp.empty.onShow&&this.optUp.empty.onShow(!0)};s.prototype.removeEmpty=function(){this.optUp.empty.use&&this.optUp.empty.onShow&&this.optUp.empty.onShow(!1)};s.prototype.showTopBtn=function(){this.topBtnShow||(this.topBtnShow=!0,this.optUp.toTop.onShow&&this.optUp.toTop.onShow(!0))};s.prototype.hideTopBtn=function(){this.topBtnShow&&(this.topBtnShow=!1,this.optUp.toTop.onShow&&this.optUp.toTop.onShow(!1))};s.prototype.getScrollTop=function(){return this.scrollTop||0};s.prototype.setScrollTop=function(t){this.scrollTop=t};s.prototype.scrollTo=function(t,o){this.myScrollTo&&this.myScrollTo(t,o)};s.prototype.resetScrollTo=function(t){this.myScrollTo=t};s.prototype.getScrollBottom=function(){return this.getScrollHeight()-this.getClientHeight()-this.getScrollTop()};s.prototype.getStep=function(t,o,n,i,p){let r=o-t;if(i===0||r===0){n&&n(o);return}i=i||300,p=p||30;let l=i/p,c=r/l,h=0,y=setInterval(function(){h<l-1?(t+=c,n&&n(t,y),h++):(n&&n(o,y),clearInterval(y))},p)};s.prototype.getClientHeight=function(t){let o=this.clientHeight||0;return o===0&&t!==!0&&(o=this.getBodyHeight()),o};s.prototype.setClientHeight=function(t){this.clientHeight=t};s.prototype.getScrollHeight=function(){return this.scrollHeight||0};s.prototype.setScrollHeight=function(t){this.scrollHeight=t};s.prototype.getBodyHeight=function(){return this.bodyHeight||0};s.prototype.setBodyHeight=function(t){this.bodyHeight=t};s.prototype.preventDefault=function(t){t&&t.cancelable&&!t.defaultPrevented&&t.preventDefault()};const K={props:{option:{type:Object,default(){return{}}},value:!1,modelValue:!1},computed:{left(){return this.option.left?this.addUnit(this.option.left):"auto"},right(){return this.option.left?"auto":this.addUnit(this.option.right)},isShow(){return this.modelValue}},methods:{addUnit(t){return t?typeof t=="number"?t+"rpx":t:0},toTopClick(){this.$emit("update:modelValue",!1),this.$emit("click")}}};function Z(t,o,n,i,p,r){const l=E;return n.option.src?(d(),f(l,{key:0,class:U(["mescroll-totop",[r.isShow?"mescroll-totop-in":"mescroll-totop-out",{"mescroll-totop-safearea":n.option.safearea}]]),style:m({"z-index":n.option.zIndex,left:r.left,right:r.right,bottom:r.addUnit(n.option.bottom),width:r.addUnit(n.option.width),"border-radius":r.addUnit(n.option.radius)}),src:n.option.src,mode:"widthFix",onClick:r.toTopClick},null,8,["class","style","src","onClick"])):w("",!0)}const $=b(K,[["render",Z],["__scopeId","data-v-5af082bd"]]),tt={data(){return{wxsProp:{optDown:{},scrollTop:0,bodyHeight:0,isDownScrolling:!1,isUpScrolling:!1,isScrollBody:!0,isUpBoth:!0,t:0},callProp:{callType:"",t:0}}},methods:{wxsCall(t){t.type==="setWxsProp"?this.wxsProp={optDown:this.mescroll.optDown,scrollTop:this.mescroll.getScrollTop(),bodyHeight:this.mescroll.getBodyHeight(),isDownScrolling:this.mescroll.isDownScrolling,isUpScrolling:this.mescroll.isUpScrolling,isUpBoth:this.mescroll.optUp.isBoth,isScrollBody:this.mescroll.isScrollBody,t:Date.now()}:t.type==="setLoadType"?(this.downLoadType=t.downLoadType,this.$set(this.mescroll,"downLoadType",this.downLoadType),this.$set(this.mescroll,"isDownEndSuccess",null)):t.type==="triggerDownScroll"?this.mescroll.triggerDownScroll():t.type==="endDownScroll"?this.mescroll.endDownScroll():t.type==="triggerUpScroll"&&this.mescroll.triggerUpScroll(!0)}},mounted(){this.mescroll.optDown.afterLoading=()=>{this.callProp={callType:"showLoading",t:Date.now()}},this.mescroll.optDown.afterEndDownScroll=()=>{this.callProp={callType:"endDownScroll",t:Date.now()};let t=300+(this.mescroll.optDown.beforeEndDelay||0);setTimeout(()=>{(this.downLoadType===4||this.downLoadType===0)&&(this.callProp={callType:"clearTransform",t:Date.now()}),this.$set(this.mescroll,"downLoadType",this.downLoadType)},t)},this.wxsCall({type:"setWxsProp"})}};var e={};e.onMoving=function(t,o,n){t.requestAnimationFrame(function(){t.selectComponent(".mescroll-wxs-content").setStyle({"will-change":"transform",transform:"translateY("+n+"px)",transition:""});var i=t.selectComponent(".mescroll-wxs-progress");i&&i.setStyle({transform:"rotate("+360*o+"deg)"})})};e.showLoading=function(t){e.downHight=e.optDown.offset,t.requestAnimationFrame(function(){t.selectComponent(".mescroll-wxs-content").setStyle({"will-change":"auto",transform:"translateY("+e.downHight+"px)",transition:"transform 300ms"})})};e.endDownScroll=function(t){e.downHight=0,e.isDownScrolling=!1,t.requestAnimationFrame(function(){t.selectComponent(".mescroll-wxs-content").setStyle({"will-change":"auto",transform:"translateY(0)",transition:"transform 300ms"})})};e.clearTransform=function(t){t.requestAnimationFrame(function(){t.selectComponent(".mescroll-wxs-content").setStyle({"will-change":"",transform:"",transition:""})})};function ot(t){t&&(e.optDown=t.optDown,e.scrollTop=t.scrollTop,e.bodyHeight=t.bodyHeight,e.isDownScrolling=t.isDownScrolling,e.isUpScrolling=t.isUpScrolling,e.isUpBoth=t.isUpBoth,e.isScrollBody=t.isScrollBody,e.startTop=t.scrollTop)}function et(t,o,n){e.disabled()||t.callType&&(t.callType==="showLoading"?e.showLoading(n):t.callType==="endDownScroll"?e.endDownScroll(n):t.callType==="clearTransform"&&e.clearTransform(n))}function nt(t,o){e.downHight=0,e.startPoint=e.getPoint(t),e.startTop=e.getScrollTop(),e.startAngle=0,e.lastPoint=e.startPoint,e.maxTouchmoveY=e.getBodyHeight()-e.optDown.bottomOffset,e.inTouchend=!1,e.callMethod(o,{type:"setWxsProp"})}function it(t,o){var n=!0;if(e.disabled())return n;var i=e.getScrollTop(),p=e.getPoint(t),r=p.y-e.startPoint.y;if(r>0&&(e.isScrollBody&&i<=0||!e.isScrollBody&&(i<=0||i<=e.optDown.startTop&&i===e.startTop))&&!e.inTouchend&&!e.isDownScrolling&&!e.optDown.isLock&&(!e.isUpScrolling||e.isUpScrolling&&e.isUpBoth)){if(e.startAngle||(e.startAngle=e.getAngle(e.lastPoint,p)),e.startAngle<e.optDown.minAngle)return n;if(e.maxTouchmoveY>0&&p.y>=e.maxTouchmoveY)return e.inTouchend=!0,P(t,o),n;n=!1;var l=p.y-e.lastPoint.y;e.downHight<e.optDown.offset?(e.movetype!==1&&(e.movetype=1,e.callMethod(o,{type:"setLoadType",downLoadType:1}),e.isMoveDown=!0),e.downHight+=l*e.optDown.inOffsetRate):(e.movetype!==2&&(e.movetype=2,e.callMethod(o,{type:"setLoadType",downLoadType:2}),e.isMoveDown=!0),l>0?e.downHight+=l*e.optDown.outOffsetRate:e.downHight+=l),e.downHight=Math.round(e.downHight);var c=e.downHight/e.optDown.offset;e.onMoving(o,c,e.downHight)}return e.lastPoint=p,n}function P(t,o){if(e.isMoveDown)e.downHight>=e.optDown.offset?(e.downHight=e.optDown.offset,e.callMethod(o,{type:"triggerDownScroll"})):(e.downHight=0,e.callMethod(o,{type:"endDownScroll"})),e.movetype=0,e.isMoveDown=!1;else if(!e.isScrollBody&&e.getScrollTop()===e.startTop){var n=e.getPoint(t).y-e.startPoint.y<0;if(n){var i=e.getAngle(e.getPoint(t),e.startPoint);i>80&&e.callMethod(o,{type:"triggerUpScroll"})}}e.callMethod(o,{type:"setWxsProp"})}e.disabled=function(){return!e.optDown||!e.optDown.use||e.optDown.native};e.getPoint=function(t){return t?t.touches&&t.touches[0]?{x:t.touches[0].pageX,y:t.touches[0].pageY}:t.changedTouches&&t.changedTouches[0]?{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY}:{x:t.clientX,y:t.clientY}:{x:0,y:0}};e.getAngle=function(t,o){var n=Math.abs(t.x-o.x),i=Math.abs(t.y-o.y),p=Math.sqrt(n*n+i*i),r=0;return p!==0&&(r=Math.asin(i/p)/Math.PI*180),r};e.getScrollTop=function(){return e.scrollTop||0};e.getBodyHeight=function(){return e.bodyHeight||0};e.callMethod=function(t,o){t&&t.callMethod("wxsCall",o)};const lt={propObserver:ot,callObserver:et,touchstartEvent:nt,touchmoveEvent:it,touchendEvent:P},H=t=>{t.$wxs||(t.$wxs=[]),t.$wxs.push("wxsBiz"),t.mixins||(t.mixins=[]),t.mixins.push({beforeCreate(){this.wxsBiz=lt}})};var a={};window&&!window.$mescrollRenderInit&&(window.$mescrollRenderInit=!0,window.addEventListener("touchstart",function(t){a.disabled()||(a.startPoint=a.getPoint(t))},{passive:!0}),window.addEventListener("touchmove",function(t){if(!a.disabled()&&!(a.getScrollTop()>0)){var o=a.getPoint(t),n=o.y-a.startPoint.y;if(n>0&&!a.isDownScrolling&&!a.optDown.isLock&&(!a.isUpScrolling||a.isUpScrolling&&a.isUpBoth)){for(var i=t.target,p=!1;i&&i.tagName&&i.tagName!=="UNI-PAGE-BODY"&&i.tagName!="BODY";){var r=i.classList;if(r&&r.contains("mescroll-render-touch")){p=!0;break}i=i.parentNode}p&&t.cancelable&&!t.defaultPrevented&&t.preventDefault()}}},{passive:!1}));a.getScrollTop=function(){return a.scrollTop||document.documentElement.scrollTop||document.body.scrollTop||0};a.disabled=function(){return!a.optDown||!a.optDown.use||a.optDown.native};a.getPoint=function(t){return t?t.touches&&t.touches[0]?{x:t.touches[0].pageX,y:t.touches[0].pageY}:t.changedTouches&&t.changedTouches[0]?{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY}:{x:t.clientX,y:t.clientY}:{x:0,y:0}};function st(t){a.optDown=t.optDown,a.scrollTop=t.scrollTop,a.isDownScrolling=t.isDownScrolling,a.isUpScrolling=t.isUpScrolling,a.isUpBoth=t.isUpBoth}const rt={data(){return{propObserver:st}}},pt={mixins:[rt]},k=t=>{t.$renderjs||(t.$renderjs=[]),t.$renderjs.push("renderBiz"),t.mixins||(t.mixins=[]),t.mixins.push({beforeCreate(){this.renderBiz=this},mounted(){this.$ownerInstance=this.$gcd(this,!0)}}),t.mixins.push(pt)},v={name:"mescroll-body",mixins:[tt],components:{MescrollTop:$},props:{down:Object,up:Object,i18n:Object,top:[String,Number],topbar:[Boolean,String],bottom:[String,Number],safearea:Boolean,height:[String,Number],bottombar:{type:Boolean,default:!0},sticky:Boolean},data(){return{mescroll:{optDown:{},optUp:{}},downHight:0,downRate:0,downLoadType:0,upLoadType:0,isShowEmpty:!1,isShowToTop:!1,windowHeight:0,windowBottom:0,statusBarHeight:0}},computed:{minHeight(){return this.toPx(this.height||"100%")+"px"},numTop(){return this.toPx(this.top)},padTop(){return this.numTop+"px"},numBottom(){return this.toPx(this.bottom)},padBottom(){return this.numBottom+"px"},isDownReset(){return this.downLoadType===3||this.downLoadType===4},transition(){return this.isDownReset?"transform 300ms":""},translateY(){return this.downHight>0?"translateY("+this.downHight+"px)":""},isDownLoading(){return this.downLoadType===3},downRotate(){return"rotate("+360*this.downRate+"deg)"},downText(){if(!this.mescroll)return"";switch(this.downLoadType){case 1: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:this.mescroll.isDownEndSuccess==!1?this.mescroll.optDown.textErr:this.mescroll.optDown.textInOffset;default:return this.mescroll.optDown.textInOffset}}},methods:{toPx(t){if(typeof t=="string"){if(t.indexOf("px")!==-1)if(t.indexOf("rpx")!==-1)t=t.replace("rpx","");else if(t.indexOf("upx")!==-1)t=t.replace("upx","");else return Number(t.replace("px",""));else if(t.indexOf("%")!==-1){let o=Number(t.replace("%",""))/100;return this.windowHeight*o}}return t?W(Number(t)):0},emptyClick(){this.$emit("emptyclick",this.mescroll)},toTopClick(){this.mescroll.scrollTo(0,this.mescroll.optUp.toTop.duration),this.$emit("topclick",this.mescroll)}},created(){let t=this,o={down:{inOffset(){t.downLoadType=1},outOffset(){t.downLoadType=2},onMoving(l,c,h){t.downHight=h,t.downRate=c},showLoading(l,c){t.downLoadType=3,t.downHight=c},beforeEndDownScroll(l){return t.downLoadType=4,l.optDown.beforeEndDelay},endDownScroll(){t.downLoadType=4,t.downHight=0,t.downResetTimer&&(clearTimeout(t.downResetTimer),t.downResetTimer=null),t.downResetTimer=setTimeout(()=>{t.downLoadType===4&&(t.downLoadType=0)},300)},callback:function(l){t.$emit("down",l)}},up:{showLoading(){t.upLoadType=1},showNoMore(){t.upLoadType=2},hideUpScroll(l){t.upLoadType=l.optUp.hasNext?0:3},empty:{onShow(l){t.isShowEmpty=l}},toTop:{onShow(l){t.isShowToTop=l}},callback:function(l){t.$emit("up",l)}}},n=x.getType(),i={type:n};s.extend(i,t.i18n),s.extend(i,S.i18n),s.extend(o,i[n]),s.extend(o,{down:S.down,up:S.up});let p=JSON.parse(JSON.stringify({down:t.down,up:t.up}));s.extend(p,o),t.mescroll=new s(p,!0),t.mescroll.i18n=i,t.$emit("init",t.mescroll);const r=q();r.windowHeight&&(t.windowHeight=r.windowHeight),r.windowBottom&&(t.windowBottom=r.windowBottom),r.statusBarHeight&&(t.statusBarHeight=r.statusBarHeight),t.mescroll.setBodyHeight(r.windowHeight),t.mescroll.resetScrollTo((l,c)=>{typeof l=="string"?setTimeout(()=>{let h;l.indexOf("#")==-1&&l.indexOf(".")==-1?h="#"+l:(h=l,l.indexOf(">>>")!=-1&&(h=l.split(">>>")[1].trim())),X().select(h).boundingClientRect(function(y){if(y){let B=y.top;B+=t.mescroll.getScrollTop(),L({scrollTop:B,duration:c})}else console.error(h+" does not exist")}).exec()},30):L({scrollTop:l,duration:c})}),t.up&&t.up.toTop&&t.up.toTop.safearea!=null||(t.mescroll.optUp.toTop.safearea=t.safearea),F("setMescrollGlobalOption",l=>{if(!l)return;let c=l.i18n?l.i18n.type:null;if(c&&t.mescroll.i18n.type!=c&&(t.mescroll.i18n.type=c,x.setType(c),s.extend(l,t.mescroll.i18n[c])),l.down){let h=s.extend({},l.down);t.mescroll.optDown=s.extend(h,t.mescroll.optDown)}if(l.up){let h=s.extend({},l.up);t.mescroll.optUp=s.extend(h,t.mescroll.optUp)}})},destroyed(){V("setMescrollGlobalOption")}};function ct(t,o,n,i,p,r){const l=_,c=z(Y("mescroll-empty"),Q),h=A("mescroll-top");return d(),f(l,{class:U(["mescroll-body mescroll-render-touch",{"mescorll-sticky":n.sticky}]),style:m({minHeight:r.minHeight,"padding-top":r.padTop,"padding-bottom":r.padBottom}),onTouchstart:t.wxsBiz.touchstartEvent,onTouchmove:t.wxsBiz.touchmoveEvent,onTouchend:t.wxsBiz.touchendEvent,onTouchcancel:t.wxsBiz.touchendEvent,"change:prop":t.wxsBiz.propObserver,prop:t.wxsProp},{default:u(()=>[n.topbar&&p.statusBarHeight?(d(),f(l,{key:0,class:"mescroll-topbar",style:m({height:p.statusBarHeight+"px",background:n.topbar})},null,8,["style"])):w("",!0),g(l,{class:"mescroll-body-content mescroll-wxs-content",style:m({transform:r.translateY,transition:r.transition}),"change:prop":t.wxsBiz.callObserver,prop:t.callProp},{default:u(()=>[p.mescroll.optDown.use?(d(),f(l,{key:0,class:"mescroll-downwarp",style:m({background:p.mescroll.optDown.bgColor,color:p.mescroll.optDown.textColor})},{default:u(()=>[g(l,{class:"downwarp-content"},{default:u(()=>[g(l,{class:U(["downwarp-progress mescroll-wxs-progress",{"mescroll-rotate":r.isDownLoading}]),style:m({"border-color":p.mescroll.optDown.textColor,transform:r.downRotate})},null,8,["class","style"]),g(l,{class:"downwarp-tip"},{default:u(()=>[T(D(r.downText),1)]),_:1})]),_:1})]),_:1},8,["style"])):w("",!0),R(t.$slots,"default",{},void 0,!0),p.isShowEmpty?(d(),f(c,{key:1,option:p.mescroll.optUp.empty,onEmptyclick:r.emptyClick},null,8,["option","onEmptyclick"])):w("",!0),p.mescroll.optUp.use&&!r.isDownLoading&&p.upLoadType!==3?(d(),f(l,{key:2,class:"mescroll-upwarp",style:m({background:p.mescroll.optUp.bgColor,color:p.mescroll.optUp.textColor})},{default:u(()=>[I(g(l,null,{default:u(()=>[g(l,{class:"upwarp-progress mescroll-rotate",style:m({"border-color":p.mescroll.optUp.textColor})},null,8,["style"]),g(l,{class:"upwarp-tip"},{default:u(()=>[T(D(p.mescroll.optUp.textLoading),1)]),_:1})]),_:1},512),[[j,p.upLoadType===1]]),p.upLoadType===2?(d(),f(l,{key:0,class:"upwarp-nodata"},{default:u(()=>[T(D(p.mescroll.optUp.textNoMore),1)]),_:1})):w("",!0)]),_:1},8,["style"])):w("",!0)]),_:3},8,["style","change:prop","prop"]),n.bottombar&&p.windowBottom>0?(d(),f(l,{key:1,class:"mescroll-bottombar",style:m({height:p.windowBottom+"px"})},null,8,["style"])):w("",!0),n.safearea?(d(),f(l,{key:2,class:"mescroll-safearea"})):w("",!0),g(h,{modelValue:p.isShowToTop,"onUpdate:modelValue":o[0]||(o[0]=y=>p.isShowToTop=y),option:p.mescroll.optUp.toTop,onClick:r.toTopClick},null,8,["modelValue","option","onClick"]),g(l,{"change:prop":t.renderBiz.propObserver,prop:t.wxsProp},null,8,["change:prop","prop"])]),_:3},8,["class","style","onTouchstart","onTouchmove","onTouchend","onTouchcancel","change:prop","prop"])}typeof H=="function"&&H(v);typeof k=="function"&&k(v);const ht=b(v,[["render",ct],["__scopeId","data-v-30539da1"]]);function ut(t,o,n){let i=null;const p=h=>{i=h},r=()=>i,l=()=>{i.optUp.use?i.resetUpScroll():setTimeout(()=>{i.endSuccess()},500)},c=()=>{setTimeout(()=>{i.endErr()},500)};return t&&t(h=>{i&&i.onPageScroll(h)}),o&&o(()=>{i&&i.onReachBottom()}),{getMescroll:r,mescrollInit:p,downCallback:l,upCallback:c}}export{ht as _,ut as u};
|