Selaa lähdekoodia

fix: update 更新红包雨领取

Before 6 kuukautta sitten
vanhempi
commit
b0c4ccf442

+ 6 - 3
.env.local

@@ -1,7 +1,11 @@
+# 环境
 #baseurl
-NEXT_PUBLIC_BASE_URL=https://3rd-api.tiktokjakjkl.icu
+# NEXT_PUBLIC_BASE_URL=http://192.168.0.71:8800
+NEXT_PUBLIC_BASE_URL=http://192.168.0.84:8800
+#NEXT_PUBLIC_BASE_URL=https://3rd-api.tiktokjakjkl.icu
 #share link
-NEXT_PUBLIC_SHARE_URL=https://3rd-site.tiktokjakjkl.icu
+NEXT_PUBLIC_SHARE_URL=http://192.168.0.84:3000
+
 #firebase
 NEXT_PUBLIC_FIREBASE_APIKEY=AIzaSyDAWORGKhdyzb5KeqTi535VmD5gN2Cdle8
 NEXT_PUBLIC_FIREBASE_AUTHDOMAIN=bcwin-a99b1.firebaseapp.com
@@ -11,4 +15,3 @@ NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID=1055413612814
 NEXT_PUBLIC_FIREBASE_APPID=1:1055413612814:web:7a563237de8e43849d275f
 NEXT_PUBLIC_FIREBASE_MEASUREMENTID=G-467M2BYJMS
 NEXT_PUBLIC_FIREBASE_KEYS=BAOsT7kii-ctLzGrgXe_wYhfuxlme1v4njnD0uPSKp3DpSnrUa2e709b9dRaeYVU7jF_qIx1y9tEv0CvilDCdnM
-

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

@@ -92,9 +92,9 @@ const ServiceWidget: FC<Props> = (props) => {
                 actList = redPacketInfo.data || [];
             }
 
-            // 是否有已开始但是没领过的红包
+            // 已开始
             return actList.filter((aItem: any) => {
-                return aItem.can_receive && aItem.is_start && !aItem.is_receive;
+                return aItem.is_start;
             });
         } catch (error) {}
     };

+ 27 - 25
src/app/[locale]/game/page.tsx

@@ -7,7 +7,9 @@ import { useEffect, useState } from "react";
 
 const Page = () => {
     const searchParams = useSearchParams();
+
     const url = decodeURIComponent(`${searchParams}`);
+
     const router = useRouter();
     const handler = (event: MessageEvent) => {
         if (event.data === "closeMessage") {
@@ -15,38 +17,38 @@ const Page = () => {
         }
     };
     const [game_url, setGameUrl] = useState<string | null>();
-    console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 18`, game_url);
+
+    // 关闭iframe弹窗
+    const categoryName = searchParams.get("category_name")!;
+
+    const goBlack = () => {
+        router.push("/");
+    };
+    // 显示关闭按钮
+    // const [showClose, setShowClose] = useState<boolean>(false);
     useEffect(() => {
-        // @ts-ignore
+        // @ts-ignore // 自定义退出事件
         window.quit = () => {
             router.push("/");
         };
 
+        // 监听游戏内返回事件
         window.addEventListener("message", handler);
-        return () => window.removeEventListener("message", handler);
-    }, []);
-
-    // 关闭iframe弹窗
-    const [categoryName, setCategoryName] = useState<string>("");
-    useEffect(() => {
-        const parmas: any = new URLSearchParams(url);
-        setCategoryName(parmas.get("category_name"));
 
+        // 设置document
         setGameUrl(sessionStorage.getItem("game_url"));
-    }, [url]);
-    const goBlack = () => {
-        router.push("/");
-    };
-    const [showClose, setShowClose] = useState<boolean>(false);
-    useEffect(() => {
-        const iframe_game: any = document.getElementById("iframe_game");
-        iframe_game.addEventListener("load", () => {
-            setShowClose(true);
-        });
-        return () =>
-            iframe_game.removeEventListener("load", () => {
-                setShowClose(true);
-            });
+        // 设置关闭按钮
+        // const iframe_game: any = document.getElementById("iframe_game");
+        // iframe_game.addEventListener("load", () => {
+        //     setShowClose(true);
+        // });
+        return () => {
+            window.removeEventListener("message", handler);
+
+            // iframe_game.removeEventListener("load", () => {
+            //     setShowClose(true);
+            // });
+        };
     }, []);
 
     return (
@@ -74,7 +76,7 @@ const Page = () => {
                 )}
 
                 {/* 真人游戏添加关闭按钮 */}
-                {showClose && ["evolution", "PG"].includes(categoryName) && (
+                {["evolution", "PG"].includes(categoryName) && (
                     <div
                         style={{
                             position: "fixed",

+ 2 - 2
src/components/Box/index.tsx

@@ -52,10 +52,10 @@ const isStartPacketsHandler = async () => {
     let packets = [];
     if (getToken()) {
         let redPacketInfo = await lredPacketApi();
-        packets = redPacketInfo.data?.red_packets || [];
+        packets = redPacketInfo.data?.red_packets.filter((item: any) => item.is_start) || [];
     } else {
         let redPacketInfo = await redPacketApi();
-        packets = redPacketInfo.data || [];
+        packets = redPacketInfo.data.filter((item: any) => item.is_start) || [];
     }
     return packets;
 };

+ 15 - 13
src/components/ModalPopup/RedPacketModal/index.tsx

@@ -3,7 +3,7 @@
 import { receiveRedPacketApi } from "@/api/promo";
 import { useRouter } from "@/i18n/routing";
 import { getToken } from "@/utils/Cookies";
-import { Mask } from "antd-mobile";
+import { Mask, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import { FC, forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from "react";
 const randomX = (len: number) => {
@@ -412,13 +412,13 @@ const RedPacketModal = forwardRef<RedPacketModalProps, Props>(function RedPacket
         try {
             let actList = packets.current;
             // 是否有已开始但是没领过的红包
-            let packetsFilter = actList
-                .filter((aItem) => {
-                    return aItem.can_receive && aItem.is_start && !aItem.is_receive;
-                })
-                .sort((pre, next) => pre.end_time - next.end_time);
+            let packetsFilter = actList;
+            // .filter((aItem) => {
+            //     return aItem.is_start && aItem.can_receive && !aItem.is_receive;
+            // })
+            // .sort((pre, next) => pre.end_time - next.end_time);
 
-            // 有可领取红包
+            // 有可领取红包 - is_start  = true -> all
             if (packetsFilter.length > 0) {
                 let current = packetsFilter[activeIndex.current];
                 let iconList = JSON.parse(current.icon);
@@ -429,16 +429,18 @@ const RedPacketModal = forwardRef<RedPacketModalProps, Props>(function RedPacket
                 if (!token) {
                     setStatus(Status.is_end);
                 } else {
-                    setStatus(Status.is_start);
+                    setStatus(current.can_receive ? Status.is_start : Status.is_end);
                 }
             } else {
                 // 无可领取红包
                 // 展示最近可领红包详情
-                let packets = actList.sort((pre, next) => pre.end_time - next.end_time);
-                packetCurrent.current = packets[0];
-                setIconLists(JSON.parse(packets[0].icon));
-                // 无可领取红包展示详情
-                setStatus(Status.is_end);
+                // let packets = actList.sort((pre, next) => pre.end_time - next.end_time);
+                // packetCurrent.current = packets[0];
+                // setIconLists(JSON.parse(packets[0].icon));
+                // // 无可领取红包展示详情
+                // setStatus(Status.is_end);
+
+                Toast.show("The event is not open");
             }
         } catch (error) {
             console.log("redPacketInfo===>error:", error);

+ 9 - 19
src/hooks/useGame.tsx

@@ -23,31 +23,21 @@ const useGame = () => {
                 Toast.clear();
                 if (res.data && res.data.game_url) {
                     const game_url = res.data.game_url;
-                    const url = `${encodeURI(res.data.game_url)}&brand=${brand}&return_url=${window.location.href.replace(pathname, "")}&category_name=${game.provider}`;
-                    console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 26`, url);
                     //
                     console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 28`);
                     // 然后是文档对象
-                    if (game_url.indexOf("!doctype")) {
-                        // sessionStorage.setItem("game_url", res.data.game_url);
-                        // router.push(`/game`);
-                        console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 34`, "文档对象");
-                    } else if (game_url.indexOf("https")) {
-                        // 如果是https
-                        console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 38 https`, game_url);
-                    } else {
-                        console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 40 http`, game_url);
+                    if (game_url.indexOf("!doctype") !== -1) {
+                        sessionStorage.setItem("game_url", res.data.game_url);
+                        const url = `${encodeURI(window.location.href)}&brand=${brand}&return_url=${window.location.href.replace(pathname, "")}&category_name=${game.provider}`;
+                        router.push(`/game?${url}`);
+                        return;
                     }
-
-                    const protocol = new URL(url).protocol;
-                    if (
-                        whiteUrls.indexOf(window.location.hostname) !== -1 ||
-                        protocol === "https:"
-                    ) {
-                        console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 31`, url);
+                    const url = `${encodeURI(res.data.game_url)}&brand=${brand}&return_url=${window.location.href.replace(pathname, "")}&category_name=${game.provider}`;
+                    if (new RegExp("https").test(game_url)) {
+                        // 如果是https
                         router.push(`/game?${url}`);
+                        return;
                     } else {
-                        console.log(`🚀🚀🚀🚀🚀-> in useGame.tsx on 33`, res.data);
                         window.open(url);
                     }
                 } else {