import{_ as e}from"./el-empty.CMLN1lgh.js";import{r as l,b as o,d as t,e as a,f as s,w as r,l as u,x as n,g as d,M as p,v as c,A as f,j as i,G as v,n as g,p as y,y as m,S as h}from"./index-DVkgSHpn.js";import{_ as w}from"./el-loading-icon.Bh3RKCou.js";import{_}from"./el-layout._U-vZTft.js";const D=_({__name:"el-refresh",props:{scrollHeight:{type:[Number,String],default:"auto"},defaultOffset:{type:Number,default:60},fontColor:{type:String,default:"#303133"},background:{type:String,default:"transparent"}},emits:["refresh","scrolltolower"],setup(_,{expose:D,emit:T}){const x=_,S=T;let k=l({top:0,startY:0,isDropDown:!1,isRefreshing:!1,dropDownState:1,dropDownInfo:{downText:"下拉更新",upText:"释放更新",refreshText:"加载中..."},scrollTop:0,allow_scroll_y:!0,allowTouchMove:!0,status:"more"}),b=l(1),Y=l(0),C=l(0);const M=()=>{"end"!=k.value.status&&"endLock"!=k.value.status&&S("scrolltolower",{page:b.value,size:Y.value,total:C.value})},P=e=>{g((()=>{k.value.scrollTop=e.detail.scrollTop}))},R=()=>{k.value.dropDownState=3,k.value.top=x.defaultOffset,k.value.status="more",b.value=1,setTimeout((()=>{S("refresh"),j()}),600)},j=()=>{k.value.isRefreshing=!1,k.value.isDropDown=!1,k.value.dropDownState=1,k.value.top=0},H=()=>{k.value.status="more"},I=()=>{k.value.status="end"},O=e=>k.value.status==e;return D({refresh:R,setData:(e=10,l=10)=>{Y.value=l,C.value=e,b.value>=e||l<=0?I():(b.value+=1,H())},resetPage:()=>{H(),S("scrolltolower",{page:1,size:Y.value,total:C.value})},emptyPage:()=>{k.value.status="empty"},morePage:H,loadingPage:()=>{k.value.status="loading"},endPage:I,endLockPage:()=>{k.value.status="endLock"},isStatus:O,isEmpty:()=>O("empty"),isMore:()=>O("more"),isLoading:()=>O("loading"),isEnd:()=>O("end")}),(l,D)=>{const T=o(t("el-empty"),e),S=o(t("el-loading-icon"),w),b=y,Y=m,C=h;return a(),s(b,null,{default:r((()=>["empty"==u(k).status?(a(),s(T,{key:0,mode:"data"})):(a(),s(C,{key:1,style:n({"min-height":"auto"!=_.scrollHeight?_.scrollHeight+"px":"auto","background-color":_.background}),"scroll-y":u(k).allow_scroll_y,"scroll-with-animation":!0,"scroll-anchoring":!0,onScroll:P,onScrolltolower:M},{default:r((()=>[d(b,{class:"refresh-moudle",onTouchstart:D[0]||(D[0]=e=>{return l=e,k.value.startY=l.changedTouches[0].pageY,k.value.startScrollTop=k.value.scrollTop,void(k.value.allowTouchMove=!0);var l}),onTouchmove:D[1]||(D[1]=e=>(e=>{if(k.value.allowTouchMove&&(g((()=>{k.value.scrollTop<0?k.value.allow_scroll_y=!1:k.value.allow_scroll_y=!0})),k.value.scrollTop<=0))if(e.changedTouches[0].pageY>k.value.startY){if(k.value.isDropDown=!0,!k.value.isRefreshing){let l=e.changedTouches[0].pageY-k.value.startY-k.value.startScrollTop;k.value.top=Math.pow(l,.8)+(3===k.value.dropDownState?x.defaultOffset:0),k.value.top>=x.defaultOffset?k.value.dropDownState=2:k.value.dropDownState=1}}else k.value.isDropDown=!1,k.value.dropDownState=1})(e)),onTouchend:D[2]||(D[2]=e=>(g((()=>{k.value.allow_scroll_y=!0})),void(k.value.isDropDown&&!k.value.isRefreshing&&(k.value.top>=x.defaultOffset?(k.value.isRefreshing=!0,R()):(k.value.isRefreshing=!1,k.value.isDropDown=!1,k.value.dropDownState=1,k.value.top=0))))),style:n({transform:"translate3d(0,"+u(k).top+"px, 0)","min-height":"auto"!=_.scrollHeight?_.scrollHeight+"px":"auto"})},{default:r((()=>[d(b,{class:"pull-refresh"},{default:r((()=>[p(l.$slots,"refresh",{},(()=>[d(b,{class:"refresh-box"},{default:r((()=>[1==u(k).dropDownState?(a(),s(b,{key:0,class:"tips-box"},{default:r((()=>[d(S,{modelValue:!0}),d(b,{class:"text",style:n({color:_.fontColor})},{default:r((()=>[c(f(u(k).dropDownInfo.downText),1)])),_:1},8,["style"])])),_:1})):i("",!0),2==u(k).dropDownState?(a(),s(b,{key:1,class:"tips-box"},{default:r((()=>[d(S,{modelValue:!0}),d(b,{class:"text",style:n({color:_.fontColor})},{default:r((()=>[c(f(u(k).dropDownInfo.upText),1)])),_:1},8,["style"])])),_:1})):i("",!0),3==u(k).dropDownState?(a(),s(b,{key:2,class:"tips-box"},{default:r((()=>[d(S,{modelValue:!0}),d(b,{class:"text",style:n({color:_.fontColor})},{default:r((()=>[c(f(u(k).dropDownInfo.refreshText),1)])),_:1},8,["style"])])),_:1})):i("",!0)])),_:1})]),!0)])),_:3}),p(l.$slots,"default",{},void 0,!0),p(l.$slots,"more",{},(()=>[u(v)(u(k).status,["loading","end"])?(a(),s(b,{key:0,class:"more-wrap"},{default:r((()=>["loading"==u(k).status?(a(),s(b,{key:0},{default:r((()=>[d(S,{modelValue:!0}),d(Y,{class:"more-text",style:n({color:_.fontColor})},{default:r((()=>[c("加载中...")])),_:1},8,["style"])])),_:1})):i("",!0),"end"==u(k).status?(a(),s(b,{key:1},{default:r((()=>[d(Y,{class:"more-text",style:n({color:_.fontColor})},{default:r((()=>[c("没有更多了~")])),_:1},8,["style"])])),_:1})):i("",!0)])),_:1})):i("",!0)]),!0)])),_:3},8,["style"])])),_:3},8,["style","scroll-y"]))])),_:3})}}},[["__scopeId","data-v-55c7d624"]]);export{D as _};
//# sourceMappingURL=el-refresh.CkIPFmzm.js.map
