|
@@ -1,6 +1,6 @@
|
|
|
"use client";
|
|
|
import { getGiveReceiveApi, SlotParams, SlotType } from "@/api/slots";
|
|
|
-import { debounce, flatPoint } from "@/utils/methods";
|
|
|
+import { flatPoint } from "@/utils/methods";
|
|
|
import { SlotMachine } from "@lucky-canvas/react";
|
|
|
import { Mask, Toast } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
@@ -195,7 +195,7 @@ const SlotsClient: FC<SlotsClientProps> = (props) => {
|
|
|
// getSlots();
|
|
|
}, []);
|
|
|
// 开始旋转
|
|
|
- const handler = debounce(() => {
|
|
|
+ const handler = () => {
|
|
|
// 按下动画
|
|
|
if (params && !params.activity_id && !params.start_time) return;
|
|
|
if (rotating.current) return;
|
|
@@ -218,27 +218,27 @@ const SlotsClient: FC<SlotsClientProps> = (props) => {
|
|
|
slotsRef.current?.play();
|
|
|
|
|
|
const Interval = setInterval(() => {
|
|
|
- const num = Math.floor(Math.random() * 99) + 1
|
|
|
- setRatio(() => (numberPadding(num, 2)))
|
|
|
- }, 500)
|
|
|
+ const num = Math.floor(Math.random() * 99) + 1;
|
|
|
+ setRatio(() => numberPadding(num, 2));
|
|
|
+ }, 500);
|
|
|
|
|
|
// 数据获取
|
|
|
getGiveReceiveApi(params as SlotParams)
|
|
|
.then((res) => {
|
|
|
setTimeout(() => {
|
|
|
- Interval && clearInterval(Interval)
|
|
|
+ Interval && clearInterval(Interval);
|
|
|
const rollover = flatPoint(res.data.rollover / 100);
|
|
|
slotsRef.current?.stop(numberPadding(res.data.amount));
|
|
|
setRatio(numberPadding(rollover > 100 ? 99 : rollover, 2));
|
|
|
}, 3000);
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
- Interval && clearInterval(Interval)
|
|
|
+ Interval && clearInterval(Interval);
|
|
|
slotsRef.current.init();
|
|
|
rotating.current = false;
|
|
|
Toast.show(t(`code.${error.data.code}`));
|
|
|
});
|
|
|
- }, 300);
|
|
|
+ };
|
|
|
// 结束旋转
|
|
|
const endHandler = (prize: any) => {
|
|
|
// rotating.current = false;
|