Browse Source

fix:7152 【bcwin后台】运营活动-定时送免费币,打码倍数没有随机变化

Before 7 tháng trước cách đây
mục cha
commit
9da861d04c

+ 1 - 0
src/app/[locale]/(TabBar)/[[...share]]/@actionWidget/Service.tsx

@@ -125,6 +125,7 @@ const ServiceWidget: FC<Props> = (props) => {
     };
 
     const { data: slots, run: slotRun } = useRequest<any, any>(getSlots, {
+        pollingInterval: 5000,
         pollingErrorRetryCount: 1,
         pollingWhenHidden: false,
     });

+ 1 - 2
src/app/[locale]/(TabBar)/[[...share]]/_home/HomePromotion.tsx

@@ -5,7 +5,6 @@ import { Mask } from "antd-mobile";
 import { FC, MouseEvent, useEffect, useState } from "react";
 
 import dayjs from "dayjs";
-import Image from "next/image";
 import { Pagination } from "swiper/modules";
 import { Swiper, SwiperSlide } from "swiper/react";
 
@@ -126,7 +125,7 @@ const HomePromotion: FC<Props> = (props) => {
                                                 }
                                             ></i>
                                         </div>
-                                        <Image
+                                        <img
                                             width={400}
                                             height={400}
                                             className={"h-[100%] w-[100%] rounded-[0.1389rem]"}

+ 12 - 9
src/app/[locale]/(TabBar)/sports/SportsClient.tsx

@@ -1,5 +1,5 @@
 "use client";
-import { GameInfo, GameRequest } from "@/api/home";
+import { GameInfo } from "@/api/home";
 import { useRouter } from "@/i18n/routing";
 import { server } from "@/utils/client";
 import { useTranslations } from "next-intl";
@@ -13,25 +13,27 @@ interface Props {
 //  dedprz | deepwin365 | damslots | chips |   deloro-casino
 const SportsClient: FC<Props> = (props) => {
     const t = useTranslations("ProfilePage");
+    const { brand_id, token } = props;
+
     const btRef = useRef(null);
     const router = useRouter();
-    const getGameDetailApi = async (data: GameRequest) => {
-        return server
+    const getGameDetailApi = async () => {
+        const data = await server
             .request<GameInfo>({
                 url: "/v1/api/front/game_info_by_id",
                 method: "post",
-                data,
+                data: { id: "sportsBet", mode: 1 },
             })
             .then((res) => {
                 if (res.code === 200) {
-                    return { token: res.data.game_url };
+                    return res.data.game_url;
                 } else {
-                    return { token: "" };
+                    return "";
                 }
             });
+        return data;
     };
 
-    const { brand_id, token } = props;
     const onLoad = () => {
         // @ts-ignore
         const bt = new BTRenderer();
@@ -40,15 +42,16 @@ const SportsClient: FC<Props> = (props) => {
             brand_id: brand_id,
             token: token,
             onTokenExpired: getGameDetailApi,
-            onSessionRefresh: getGameDetailApi,
+            onSessionRefresh: () => router.refresh(),
             themeName: "default",
             lang: "pt-br",
             target: document.getElementById("betby"),
             betSlipOffsetBottom: 80,
             // betSlipOffsetRight: 750,
+
             betSlipZIndex: 1000,
             stickyTop: 0,
-            betSlipOffsetTop: 0,
+            betSlipOffsetTop: 50,
             onRecharge: function () {
                 router.push("/deposit");
             },

+ 1 - 1
src/app/[locale]/(wheel)/cashWheel/CashWheelClient.tsx

@@ -632,7 +632,7 @@ const Wheel: FC<Props> = (props) => {
     }));
 
     const { run, cancel } = useRequest<any, any>(setWheel, {
-        pollingInterval: 5000,
+        // pollingInterval: 5000,
         pollingErrorRetryCount: 1,
         pollingWhenHidden: false,
     });

+ 20 - 18
src/components/ModalPopup/SlotsModal/index.tsx

@@ -1,9 +1,10 @@
 "use client";
 import { getGiveReceiveApi, SlotParams, SlotType } from "@/api/slots";
-import { flatPoint } from "@/utils/methods";
+import { debounce, flatPoint } from "@/utils/methods";
 import { SlotMachine } from "@lucky-canvas/react";
-import { Mask } from "antd-mobile";
+import { Mask, Toast } from "antd-mobile";
 import clsx from "clsx";
+import { useTranslations } from "next-intl";
 import { FC, forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from "react";
 import animation from "../animations.module.scss";
 
@@ -171,6 +172,7 @@ interface SlotsClientProps {
 const SlotsClient: FC<SlotsClientProps> = (props) => {
     const { slotSource, onRotateAfter } = props;
     const slotsRef = useRef<any>(null);
+    const t = useTranslations();
 
     const rotating = useRef<boolean>(false);
 
@@ -193,43 +195,43 @@ const SlotsClient: FC<SlotsClientProps> = (props) => {
         // getSlots();
     }, []);
     // 开始旋转
-    const handler = () => {
+    const handler = debounce(() => {
         // 按下动画
         if (params && !params.activity_id && !params.start_time) return;
         if (rotating.current) return;
-        let height = buttonRef.current!.clientHeight;
-        buttonRef.current!.style.transition = "height 0.3s";
-        buttonRef.current!.style.height = `${height * 0.8}px`;
 
-        setTimeout(() => {
-            buttonRef.current!.style.height = `${height}px`;
-        }, 200);
         // slotsRef.current?.play();
         // setTimeout(() => {
         //     slotsRef.current?.stop(numberPadding(Math.floor(Math.random() * 9999)));
         // }, 2500);
         // return;
 
-        slotsRef.current?.play();
+        // 图片按下修改高度
+
+        let height = buttonRef.current!.clientHeight;
+        buttonRef.current!.style.transition = "height 0.3s";
+        buttonRef.current!.style.height = `${height * 0.8}px`;
         rotating.current = true;
+        setTimeout(() => {
+            buttonRef.current!.style.height = `${height}px`;
+        }, 200);
+        slotsRef.current?.play();
 
         // 数据获取
         getGiveReceiveApi(params as SlotParams)
             .then((res) => {
                 setTimeout(() => {
-                    if (res.code === 200) {
-                        const rollover = flatPoint(res.data.rollover / 100);
-                        slotsRef.current?.stop(numberPadding(res.data.amount));
-                        setRatio(numberPadding(rollover > 100 ? 99 : rollover, 2));
-                    } else {
-                        slotsRef.current.init();
-                    }
+                    const rollover = flatPoint(res.data.rollover / 100);
+                    slotsRef.current?.stop(numberPadding(res.data.amount));
+                    setRatio(numberPadding(rollover > 100 ? 99 : rollover, 2));
                 }, 2500);
             })
             .catch((error) => {
                 slotsRef.current.init();
+                rotating.current = false;
+                Toast.show(t(`code.${error.data.code}`));
             });
-    };
+    }, 300);
     // 结束旋转
     const endHandler = (prize: any) => {
         rotating.current = false;

+ 1 - 0
src/hooks/useCountdown.tsx

@@ -40,6 +40,7 @@ const useCountdown = (options: Options = {}) => {
         setTimeLeft(leftTime);
 
         if (leftTime <= 0) {
+            // onEndRef.current?.();
             return;
         }
 

+ 0 - 1
src/stores/useWheelStore.ts

@@ -56,7 +56,6 @@ export const useWheelStore = create<State & Action>()((set, get) => {
                         currentWheel: source,
                         receiveTarget: {},
                     }));
-
                     return data;
                 }
                 set((state) => ({ ...state, status: 3, currentWheel: source }));

+ 32 - 13
src/utils/methods/index.ts

@@ -1,20 +1,39 @@
-export function debounce(fn: Function, delay = 200, immediate = false) {
-    let timer: ReturnType<typeof setTimeout>;
-    return function (...args: any) {
-        const context = globalThis;
-        let result: unknown;
-        args = arguments;
+/**
+ * @description 函数防抖
+ * @param fn 需要防抖的函数
+ * @param delay 延迟时间(毫秒)
+ * @param immediate 是否立即执行
+ * @returns 防抖后的函数
+ */
+export function debounce<T extends (...args: any[]) => any>(
+    fn: T,
+    delay = 200,
+    immediate = false
+): (...args: Parameters<T>) => ReturnType<T> | undefined {
+    let timer: NodeJS.Timeout | null = null;
+    let isInvoked = false;
+
+    return function(this: ThisParameterType<T>, ...args: Parameters<T>) {
+        const context = this;
+
+        // 如果需要立即执行且未调用过
+        if (immediate && !isInvoked) {
+            isInvoked = true;
+            return fn.apply(context, args);
+        }
+
+        // 清除之前的定时器
         if (timer) {
             clearTimeout(timer);
         }
-        if (immediate && !timer) {
-            result = fn.apply(context, args);
-        }
-        timer = setTimeout(() => {
-            result = fn.apply(context, args);
-        }, delay);
 
-        return result;
+        return new Promise<ReturnType<T>>((resolve) => {
+            timer = setTimeout(() => {
+                const result = fn.apply(context, args);
+                isInvoked = false;
+                resolve(result);
+            }, delay);
+        });
     };
 }