瀏覽代碼

fix: 增加游戏配置链接

Before 8 月之前
父節點
當前提交
fc69e572af

+ 1 - 0
.env.development

@@ -1,6 +1,7 @@
 # 环境
 #baseurl
 NEXT_PUBLIC_BASE_URL=http://192.168.0.84:8800
+#NEXT_PUBLIC_BASE_URL=http://192.168.0.67:8800
 #share link
 NEXT_PUBLIC_SHARE_URL=http://192.168.0.84:3000
 

+ 1 - 0
.env.local

@@ -1,6 +1,7 @@
 # 环境
 #baseurl
 NEXT_PUBLIC_BASE_URL=http://192.168.0.84:8800
+#NEXT_PUBLIC_BASE_URL=http://192.168.0.67:8800
 #share link
 NEXT_PUBLIC_SHARE_URL=http://192.168.0.84:3000
 

+ 44 - 0
src/api/cashWheel.ts

@@ -1,3 +1,5 @@
+import { server } from "@/utils/client";
+
 export interface Activity {
     /**
      * ID 编号
@@ -52,6 +54,7 @@ export interface Activate {
      */
     end_time: number;
     history: History[];
+    can: boolean;
 }
 
 export interface History {
@@ -75,3 +78,44 @@ export interface NotReceive {
      */
     unique_id: string;
 }
+
+/**
+ * 领取转盘奖励
+ *   POST /v1/api/user/turntable/receive
+ *   接口ID:237883491
+ *   接口地址:https://app.apifox.com/link/project/4790544/apis/api-237883491
+ */
+export const getWheelReceiveApi = (data: { unique_id: number }) => {
+    return server.post({
+        url: "/v1/api/user/turntable/receive",
+        data,
+    });
+};
+
+/**
+ * 启动转盘
+ *   POST /v1/api/user/turntable/run
+ *   接口ID:237904502
+ *   接口地址:https://app.apifox.com/link/project/4790544/apis/api-237904502
+ */
+export interface RunType {
+    index: number;
+    amount: number;
+}
+export const getWheelRunApi = (data: { activity_id: number }) => {
+    return server.post<RunType>({
+        url: "/v1/api/user/turntable/run",
+        data,
+    });
+};
+
+/**
+ * @description 获取转盘信息
+ */
+export const getWheelApi = () => {
+    return server.request<WheelsType>({
+        url: "/v1/api/user/turntable/info",
+        method: "post",
+        data: {},
+    });
+};

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

@@ -74,7 +74,7 @@ const ServiceWidget: FC<Props> = (props) => {
                 const result = await getPaysApi();
                 return result.data;
             } else {
-                return Promise.reject("not login");
+                return Promise.reject();
             }
         } catch (e) {
             return Promise.resolve({

+ 22 - 4
src/app/[locale]/(TabBar)/sports/SportsClient.tsx

@@ -1,4 +1,6 @@
 "use client";
+import { GameInfo, GameRequest } from "@/api/home";
+import { server } from "@/utils/client";
 import { useTranslations } from "next-intl";
 import Script from "next/script";
 import { FC, useEffect, useRef } from "react";
@@ -11,7 +13,22 @@ interface Props {
 const SportsClient: FC<Props> = (props) => {
     const t = useTranslations("ProfilePage");
     const btRef = useRef(null);
-    console.log(`🚀🚀🚀🚀🚀-> in SportsClient.tsx on 14`, props);
+    const getGameDetailApi = async (data: GameRequest) => {
+        return server
+            .request<GameInfo>({
+                url: "/v1/api/front/game_info_by_id",
+                method: "post",
+                data,
+            })
+            .then((res) => {
+                if (res.code === 200) {
+                    return res.data;
+                } else {
+                    return {};
+                }
+            });
+    };
+
     const { brand_id, token } = props;
     const onLoad = () => {
         // @ts-ignore
@@ -20,15 +37,16 @@ const SportsClient: FC<Props> = (props) => {
         bt.initialize({
             brand_id: brand_id,
             token: token,
-            onTokenExpired: function () {
-                console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 20`, "token 过期");
-            },
+            onTokenExpired: getGameDetailApi,
             themeName: "deloro-casino",
             lang: "pt-br",
             target: document.getElementById("betby"),
             betSlipOffsetBottom: 65,
             // betSlipOffsetRight: 750,
             betSlipZIndex: 0,
+            onRechage: function () {
+                console.log(`🚀🚀🚀🚀🚀-> in SportsClient.tsx on 33`, 1);
+            },
             onRouteChange: function () {},
             onLogin: function () {},
             onRegister: function () {},

+ 0 - 18
src/app/[locale]/(navbar)/cashWheel/page.tsx

@@ -1,18 +0,0 @@
-import { WheelsType } from "@/api/cashWheel"; // 引入客户端组件
-import { server } from "@/utils/server";
-import CashWheelClient from "./CashWheelClient";
-
-const getWheelApi = () => {
-    return server.request<WheelsType>({
-        url: "/v1/api/user/turntable/info",
-        method: "post",
-        data: {},
-    });
-};
-const CashWheel = async () => {
-    const result = await getWheelApi();
-    // 将数据传递给客户端组件
-    return <CashWheelClient wheel={result.data} />;
-};
-
-export default CashWheel;

+ 81 - 44
src/app/[locale]/(navbar)/cashWheel/CashWheelClient.tsx → src/app/[locale]/(wheel)/cashWheel/CashWheelClient.tsx

@@ -1,23 +1,28 @@
 "use client";
 
-import { WheelsType } from "@/api/cashWheel";
+import { getWheelApi, getWheelRunApi, WheelsType } from "@/api/cashWheel";
 import Box from "@/components/Box";
 import { Link } from "@/i18n/routing";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
-import { copyText } from "@/utils/methods";
+import { copyText, timeFormat } from "@/utils/methods";
 import { LuckyWheel } from "@lucky-canvas/react";
 import { useCountDown } from "ahooks";
 import { Popup, Toast } from "antd-mobile";
 import clsx from "clsx";
 import { useTranslations } from "next-intl";
 import Image from "next/image";
-import { createContext, FC, useContext, useRef, useState } from "react";
+import { createContext, FC, useContext, useEffect, useRef, useState } from "react";
 import LotteryWheel from "./LotteryWheel";
 import styles from "./style.module.scss";
 interface Props {
-    wheel: WheelsType;
+    // wheel: WheelsType;
+    allHistory: any[];
 }
-const WheelContext = createContext<Partial<WheelsType>>({});
+interface ContextType extends WheelsType {
+    allHistory: any[];
+    handler: () => void;
+}
+const WheelContext = createContext<Partial<ContextType>>({});
 
 const CashMainCom = () => {
     return (
@@ -84,24 +89,29 @@ const DrawContent = () => {
 };
 type Dtltype = "left" | "right";
 const LeftListClient = () => {
-    const winListData = Array(500).fill("1");
+    const wheel = useContext(WheelContext);
     return (
         <>
-            {winListData.length > 0 &&
-                winListData.map((item, index) => {
-                    return (
-                        <div className={styles.item} key={index}>
-                            <span className={`${styles.name} ${styles.omitWrap}`}>
-                                5533******412
-                            </span>
-                            <span className={styles.tipText}> Acabou de saca </span>
-                            <div className={styles.value}>
-                                <span className={styles.addCash}>+100</span>
-                                <span className={styles.unit}> R$</span>
+            <div className={`${styles.winList} ${styles.swipernoswiping} ${styles.type2}`}>
+                {wheel.allHistory &&
+                    wheel.allHistory.length > 0 &&
+                    wheel.allHistory?.map((item, index) => {
+                        return (
+                            <div className={styles.item} key={index}>
+                                <span className={`${styles.name} ${styles.omitWrap}`}>
+                                    55****{(Math.random() * 10000).toFixed(0)}
+                                </span>
+                                <span className={styles.tipText}>
+                                    {timeFormat(item.receive_time, "br", undefined, true)}
+                                </span>
+                                <div className={styles.value}>
+                                    <span className={styles.addCash}>+100</span>
+                                    <span className={styles.unit}> R$</span>
+                                </div>
                             </div>
-                        </div>
-                    );
-                })}
+                        );
+                    })}
+            </div>
         </>
     );
 };
@@ -142,11 +152,7 @@ const Report = () => {
                 <div className={styles.vanTabsContent}>
                     <div className={styles.vantabpane}>
                         <div className={styles.tabContent}>
-                            <div
-                                className={`${styles.winList} ${styles.swipernoswiping} ${styles.type2}`}
-                            >
-                                {activeTab === "left" ? <LeftListClient /> : null}
-                            </div>
+                            {activeTab === "left" ? <LeftListClient /> : null}
                         </div>
                     </div>
                 </div>
@@ -198,7 +204,7 @@ const WheelWallet = () => {
                 <div className={"mt-[0.2083rem] w-[100%] text-center text-[18px]"}>
                     <span className={"mr-[10px] text-[#008213]"}>Faltam para O saque</span>
                     <span className={"text-[yellow]"}>
-                        R${wheel.num! - wheel.activate?.amount! || 0}
+                        R${(wheel.num! - wheel.activate?.amount! || 0).toFixed(2)}
                     </span>
                 </div>
             </div>
@@ -267,8 +273,7 @@ const DrawMain = () => {
     const myLucky = useRef<any>();
     const desktopWheelRef = useRef<any>();
     const wheel = useContext(WheelContext);
-    console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 213`, wheel);
-    const [count, setCount] = useState(0);
+    console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 275`, wheel);
 
     const [buttons, setButtons] = useState([
         {
@@ -282,7 +287,7 @@ const DrawMain = () => {
             ],
             fonts: [
                 {
-                    text: count,
+                    text: wheel.activate?.can! ? 1 : 0,
                     top: -5,
                     fontColor: "#ffdb0e",
                     fontSize: "22px",
@@ -294,18 +299,32 @@ const DrawMain = () => {
         offsetDegree: 20,
     });
 
+    const currentIndex = useRef<undefined | number>(undefined);
+
     const startRotate = () => {
         // 点击抽奖按钮会触发star回调
         myLucky.current?.play();
-        setTimeout(() => {
-            const index = (Math.random() * 6) >> 0;
-            myLucky.current?.stop(index);
-            setButtons((value) => {
-                const newValue = [...value];
-                newValue[0].fonts[0].text = index;
-                return newValue;
-            });
-        }, 2500);
+        if (wheel.activities) {
+            getWheelRunApi({ activity_id: wheel.activities[0].id })
+                .then((res) => {
+                    setTimeout(() => {
+                        myLucky.current?.stop(res.data.index);
+
+                        setButtons((values) => {
+                            const newValues = [...values];
+                            newValues[0].fonts[0].text = res.data.amount;
+                            return newValues;
+                        });
+
+                        wheel.handler && wheel.handler();
+                    }, 2500);
+                })
+                .catch((error) => {
+                    myLucky.current?.init();
+                });
+        } else {
+            myLucky.current?.init();
+        }
     };
     const endRotate = (prize: any) => {
         console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 304`, prize);
@@ -319,7 +338,7 @@ const DrawMain = () => {
                 <img src={"/wheels/wheel-bg.png"} className={"w-[100%]"} />
                 <img
                     src={"/wheels/title.png"}
-                    className={"absolute left-[13%] top-[53%] z-10 w-[70%] object-cover"}
+                    className={"absolute left-[13.5%] top-[53%] z-10 w-[70%] object-cover"}
                 />
                 {/*定位到中心圆*/}
                 <div className={"absolute bottom-[0.0347rem] h-[2.6736rem] w-[100%]"}>
@@ -423,15 +442,15 @@ const CountdownClient = () => {
     const wheel = useContext(WheelContext);
 
     const [_, formattedRes] = useCountDown({
-        leftTime: wheel.activate?.end_time,
+        leftTime: wheel.activate?.end_time! * 1000 - Date.now(),
     });
     const { days, hours, minutes, seconds } = formattedRes;
     return (
         <div className={"relative flex justify-center"}>
             <img src="/wheels/countdown-bg.png" alt="" />
-            <span className={"absolute bottom-[50%] translate-y-1/2"}>
-                {String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}:
-                {String(seconds).padStart(2, "0")}
+            <span className={"absolute bottom-[50%] ml-[0.2083rem] translate-y-1/2"}>
+                {String(days).padStart(2, "0")}:{String(hours).padStart(2, "0")}:
+                {String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
             </span>
         </div>
     );
@@ -612,7 +631,25 @@ const ShareClient = () => {
 };
 
 const CashWheelClient: FC<Props> = (props) => {
-    const values = { ...props.wheel, num: 100 };
+    const getWheelData = () => {
+        getWheelApi().then((res) => {
+            if (res.code === 200) {
+                setValues((staticValue) => {
+                    return { ...staticValue, ...res.data };
+                });
+            }
+        });
+    };
+
+    const [values, setValues] = useState<Partial<ContextType>>({
+        num: 100,
+        allHistory: props.allHistory || [],
+        handler: getWheelData,
+    });
+    useEffect(() => {
+        getWheelData();
+    }, []);
+
     return (
         <>
             <WheelContext.Provider value={values}>

+ 0 - 0
src/app/[locale]/(navbar)/cashWheel/LotteryWheel copy 2.tsx → src/app/[locale]/(wheel)/cashWheel/LotteryWheel copy 2.tsx


+ 0 - 0
src/app/[locale]/(navbar)/cashWheel/LotteryWheel copy.tsx → src/app/[locale]/(wheel)/cashWheel/LotteryWheel copy.tsx


+ 0 - 0
src/app/[locale]/(navbar)/cashWheel/LotteryWheel.tsx → src/app/[locale]/(wheel)/cashWheel/LotteryWheel.tsx


+ 0 - 0
src/app/[locale]/(navbar)/cashWheel/layout.tsx → src/app/[locale]/(wheel)/cashWheel/layout.tsx


+ 16 - 0
src/app/[locale]/(wheel)/cashWheel/page.tsx

@@ -0,0 +1,16 @@
+import { server } from "@/utils/server";
+import CashWheelClient from "./CashWheelClient";
+
+const getAllHistoryApi = () => {
+    return server.request<any[]>({
+        url: "/v1/api/user/turntable/history_receive",
+        method: "POST",
+    });
+};
+const CashWheel = async () => {
+    const historyResult = await getAllHistoryApi();
+    // 将数据传递给客户端组件
+    return <CashWheelClient allHistory={historyResult.data} />;
+};
+
+export default CashWheel;

+ 1 - 1
src/app/[locale]/(navbar)/cashWheel/style.module.scss → src/app/[locale]/(wheel)/cashWheel/style.module.scss

@@ -557,7 +557,7 @@
   }
 
   100% {
-   transform: translateY(-7.14rem);
+   transform: translateY(-6.14rem);
   }
 }
 

+ 19 - 0
src/app/[locale]/(wheel)/sharecwbr/layout.tsx

@@ -0,0 +1,19 @@
+import HeaderBack from "@/components/HeaderBack";
+import { getTranslations } from "next-intl/server";
+import { ReactNode } from "react";
+
+export default async function Layout({
+    children,
+    params: { locale },
+}: {
+    children: ReactNode;
+    params: { locale: string };
+}) {
+    const t = await getTranslations("Header");
+    return (
+        <>
+            <HeaderBack showBack={true} title={t("cashWheel")} />
+            <main className={"main-header bg-[#24262b]"}>{children}</main>
+        </>
+    );
+}

+ 5 - 0
src/app/[locale]/(wheel)/sharecwbr/page.tsx

@@ -0,0 +1,5 @@
+const Page = () => {
+    return <div>123</div>;
+};
+
+export default Page;

+ 5 - 1
src/components/Card/Card.tsx

@@ -49,8 +49,12 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
             mode: groupType!,
         };
         getGameDetailApi(params).then((res) => {
+            const url =
+                process.env.NEXT_PUBLIC_BASE_URL?.indexOf("84") === -1
+                    ? `${res.data?.game_url}&brand=${brandRef.current}`
+                    : `${res.data?.game_url}&brand=${brandRef.current}&gameListIp=http://192.168.0.176:8000&gameResIp=http://192.168.0.2:8888&resServerIp=http://192.168.0.176:12580`;
             if (res.data && res.data.game_url) {
-                window.open(`${res.data?.game_url}&brand=${brandRef.current}`);
+                window.open(url);
             } else {
                 Toast.show("数据错误");
             }

+ 2 - 0
src/middleware.ts

@@ -21,6 +21,8 @@ function localMiddleware() {
 const whiteRouters = ["/"];
 function authMiddleware(next: Function) {
     return async (request: NextRequest, res: NextResponse) => {
+        const url = request.nextUrl;
+        console.log(`🚀🚀🚀🚀🚀-> in middleware.ts on 24`, url);
         return next(request, res);
     };
 }

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

@@ -38,7 +38,12 @@ function getLang(utc: string) {
     let n = i < 0 ? 0 : i;
     return language[n];
 }
-export const timeFormat = (time: number, lang = "en", delimiter?: undefined | string): string => {
+export const timeFormat = (
+    time: number,
+    lang = "en",
+    delimiter?: undefined | string,
+    day = false
+): string => {
     if (!time) return "";
     const len = (time + "").length;
     if (len === 10) {
@@ -49,6 +54,13 @@ export const timeFormat = (time: number, lang = "en", delimiter?: undefined | st
     if (delimiter) {
         return new Date(time).toLocaleString(lang).replaceAll("/", delimiter);
     }
+    if (day) {
+        return new Date(time).toLocaleString(lang, {
+            year: "2-digit",
+            month: "2-digit",
+            day: "2-digit",
+        });
+    }
     return new Date(time).toLocaleString(lang);
 };