2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{U as t,aB as e,aC as o,aD 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,aE as w,B as y}from"./index-d4baa715.js";import{u as T}from"./useScroll.dcb46f58.js";import{C as S}from"./config.6730da78.js";import{a2 as x}from"./images.f0a6f614.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:C,color:H}=a(_),N=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(C),color:h(H),borderRadius:h(O)}))),W=r({windowWidth:0,windowHeight:0}),P=r([0,0]);let B;const E=r(!1);function U(t){B=setTimeout((()=>{E.value=!0}),1e3)}function Y(t){if(!h(E))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(W).safeArea.height||h(W).windowHeight)-h(z)/2&&(n=(h(W).safeArea.height||h(W).windowHeight)-h(z)/2),a>=h(W).windowWidth&&(a=h(W).windowWidth-h(z)/2),P.value=[a,n]}function D(t){if(B&&clearTimeout(B),!E.value)return K();E.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(E)||(J.value=!0,setTimeout((()=>{b()}),500),setTimeout((()=>{J.value=!1}),1200))}return u((async()=>{W.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:E.value,click:J.value}]),style:d(h(N)),onTouchstart:v(U,["prevent"]),onTouchmove:v(Y,["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};
|