feat(custom): 大转盘第一版

This commit is contained in:
2024-01-13 16:48:25 +08:00
parent 79990aeca1
commit 21ff388259
5 changed files with 5819 additions and 12513 deletions

View File

@@ -2,6 +2,7 @@
import { ref } from "vue";
import Taro from "@tarojs/taro";
import { userSign } from "@/api/user";
import { debounce } from "@/utils";
const show = ref(false);
@@ -32,7 +33,7 @@ const toSign = async () => {
:close-on-click-overlay="false"
>
<view class="wrapper">
<view @click.stop="toSign">
<view @click.stop="debounce(toSign)">
<image class="image" src="../static/index/poppBg.png" />
</view>
<view @click.stop="show = false">

View File

@@ -53,3 +53,44 @@ export function parseQueryString(url: string) {
return result;
}
/**
*
* @param rdix 随机因子
* @param length 取的长度
* @param isAddStr 是否限制随机结果中的长度,不允许输出长度
* @returns String
*/
export function getUid(rdix = 1, length = 12, isAddStr = false) {
return Math.floor(
Math.random() * rdix * Math.floor(Math.random() * Date.now())
)
.toString(isAddStr ? 16 : 10)
.substring(0, length);
}
/*
防抖
防抖原理在一定时间内只有最后一次操作再过wait毫秒后才执行函数
@param {Function} func 要执行的回调函数
@param {Number} wait 延迟的时间
@param{Boolean} immediate 是否要立即执行
*/
var timeout: any = getUid(1);
export function debounce(func: Function, wait = 500, immediate = false) {
// 清除定时器
if (timeout !== null) clearTimeout(timeout);
// 立即执行,此类情况一般用不到
if (immediate) {
timeout = setTimeout(() => {
timeout = null;
}, wait);
typeof func === "function" && func();
} else {
// 设置定时器当最后一次操作后timeout不会再被清除所以在延时wait毫秒后执行func回调方法
timeout = getUid(1);
timeout = setTimeout(() => {
typeof func === "function" && func();
}, wait);
}
}