2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{U as t,aD as e,aE as o,aF as n,t as a,x as s,a as r,v as u,g as i,o as c,j as l,w as p,a0 as f,h as g,y as d,i as h,m,Q as v,aG as w,B as y}from"./index-90c12cc1.js";import{u as T}from"./useScroll.50272fa4.js";import{C as S}from"./config.6730da78.js";import{a2 as x}from"./images.cf3befb9.js";import{_ as A}from"./_plugin-vue_export-helper.1b428a4d.js";const _=A({__name:"index",props:{top:{type:Number,default:300},location:{type:Array,default:()=>[20,400]},size:{type:Number,default:80},round:{type:String,default:"50%"},background:{type:String,default:"#fff"},color:{type:String,default:"#333"},scrollTop:{type:Number,default:0}},setup(A){const _=A,{scrollTop:$,scrollToTop:b}=T(),{getSystemInfo:I}={getSystemInfo:function(){return new Promise(((e,o)=>{t({success:t=>e(t),fail:t=>o(t)})}))},getDeviceInfo:function(){return e()},getWindowInfo:function(){return o()},getAppBaseInfo:function(){return n()},getAppAuthorizeSetting:function(){return uni.getAppAuthorizeSetting()},getSystemSetting:function(){return uni.getSystemSetting()},openAppAuthorizeSetting:function(){return new Promise(((t,e)=>{uni.openAppAuthorizeSetting({success:()=>t(!0),fail:t=>e(t)})}))}},{top:j,location:k,size:z,round:O,background:H,color:N}=a(_),W=s((()=>({width:`${h(z)}rpx`,height:`${h(z)}rpx`,scale:h($)>=h(j)?1:0,top:h(P)[1]>0?`${h(P)[1]}px`:`calc(100vh - ${h(k)[1]||200}rpx - ${h(z)}rpx)`,left:h(P)[0]>0?`${h(P)[0]}px`:`calc(100vw - ${h(k)[0]||20}rpx - ${h(z)}rpx)`,background:h(H),color:h(N),borderRadius:h(O)}))),C=r({windowWidth:0,windowHeight:0}),P=r([0,0]);let E;const U=r(!1);function Y(t){E=setTimeout((()=>{U.value=!0}),1e3)}function B(t){if(!h(U))return;if(t.changedTouches.length<1)return;const{clientX:e,clientY:o}=t.changedTouches[0];let n=o-h(z)/2,a=e-h(z)/2;n<=0&&(n=1),a<=0&&(a=1),n>=(h(C).safeArea.height||h(C).windowHeight)-h(z)/2&&(n=(h(C).safeArea.height||h(C).windowHeight)-h(z)/2),a>=h(C).windowWidth&&(a=h(C).windowWidth-h(z)/2),P.value=[a,n]}function D(t){if(E&&clearTimeout(E),!U.value)return K();U.value=!1,(h(P)[0]>0||h(P)[1]>0)&&w(S.TOP_TOUCH_KEY,JSON.stringify(h(P)))}const J=r(!1);function K(){h(U)||(J.value=!0,setTimeout((()=>{b()}),500),setTimeout((()=>{J.value=!1}),1200))}return u((async()=>{C.value=await I();const t=i(S.TOP_TOUCH_KEY);t&&(P.value=JSON.parse(t))})),(t,e)=>{const o=y;return c(),l(o,{class:m(["return-top",{touch:U.value,click:J.value}]),style:d(h(W)),onTouchstart:v(Y,["prevent"]),onTouchmove:v(B,["stop"]),onTouchend:D,onClick:K},{default:p((()=>[f(t.$slots,"default",{},(()=>[g(o,{class:"top-icon",style:d({backgroundImage:`url(${h(x)})`})},null,8,["style"])]),!0)])),_:3},8,["class","style","onTouchstart","onTouchmove"])}}},[["__scopeId","data-v-af35607c"]]);export{_ as R};
|