Переглянути джерело

fix: 修改页面内打开游戏

Before 7 місяців тому
батько
коміт
e921772061

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

@@ -310,6 +310,7 @@ const DrawMain = () => {
         receiveTarget: state.receiveTarget,
     }));
     const shareRef = useRef<{ open: () => void } | null>(null);
+
     return (
         <>
             <WheelWallet />
@@ -325,7 +326,7 @@ const DrawMain = () => {
 
             {/*倒计时*/}
             <div className={"relative flex justify-center"}>
-                {!receiveTarget.unique_id ? <CountdownClient /> : <ReceiveClient />}
+                <CountdownClient />
             </div>
             {/*分享*/}
             {currentWheel.end_time && currentWheel.end_time > 0 ? (
@@ -337,6 +338,7 @@ const DrawMain = () => {
 
 const ReceiveClient = () => {
     const [visible, setVisible] = useState(false);
+    const wheel = useContext(WheelContext);
     const t = useTranslations();
     const { receiveTarget, setWheel } = useWheelStore((state) => ({
         statusWheel: state.status,
@@ -409,7 +411,9 @@ const ReceiveClient = () => {
     );
 };
 const CountdownClient = () => {
+    const [visible, setVisible] = useState(false);
     const wheel = useContext(WheelContext);
+    const t = useTranslations();
     const { setWheel, currentWheel, receiveTarget } = useWheelStore((state) => ({
         statusWheel: state.status,
         currentWheel: state.currentWheel,
@@ -420,13 +424,77 @@ const CountdownClient = () => {
         leftTime: currentWheel.end_time ? currentWheel.end_time * 1000 - Date.now() : 0,
     });
     const { days, hours, minutes, seconds } = formattedRes;
+
+    const receiveHandler = () => {
+        getWheelReceiveApi({ unique_id: receiveTarget.unique_id! })
+            .then(() => {
+                setVisible(true);
+                // setWheel();
+            })
+            .catch((error) => {
+                Toast.show(t(`code.${error.data.code || 500}`));
+            });
+    };
     return (
         <>
-            <img src="/wheels/countdown-bg.png" alt="" />
-            <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>
+            {!receiveTarget.unique_id ? (
+                <>
+                    <img src="/wheels/countdown-bg.png" alt="" />
+                    <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 className={"mt-[10px]"}>
+                    <Image
+                        src={"/wheels/receive-button.png"}
+                        alt={"receive"}
+                        height={80}
+                        width={160}
+                        onClick={receiveHandler}
+                    ></Image>
+                </div>
+            )}
+            <Mask visible={visible}>
+                <div className={"absolute top-[50%] w-[100%] -translate-y-1/2 p-[0.1389rem]"}>
+                    <div
+                        className={
+                            "h-[2.0833rem] rounded-[0.0694rem] bg-[#232327FF]" +
+                            " flex flex-col justify-between p-[0.1389rem]"
+                        }
+                    >
+                        <div className={"mb-[0.1389rem] text-center"}>
+                            Parabéns por conseguir 100 BRL
+                        </div>
+                        <div className={"flex justify-center"}>
+                            <img
+                                src="/wheel/cash.png"
+                                alt=""
+                                className={"w-[0.6rem] object-contain"}
+                            />
+                            <div
+                                className={
+                                    "ml-[0.1389rem] text-[0.2778rem] font-black" + " text-[#fb8b05]"
+                                }
+                            >
+                                <p>R$ 100</p>
+                            </div>
+                        </div>
+
+                        <Link href={"/"}>
+                            <div
+                                className={
+                                    "h-[0.34rem] w-[100%] rounded-[0.0694rem] bg-[#fb8b05] text-[#fff]" +
+                                    " flex items-center justify-center"
+                                }
+                            >
+                                Voltar à página inicial
+                            </div>
+                        </Link>
+                    </div>
+                </div>
+            </Mask>
         </>
     );
 };

+ 1 - 0
src/components/Box/WheelModal.tsx

@@ -494,6 +494,7 @@ const WheelModal = forwardRef<WheelModalProps, Props>(function RedPacketModal(pr
                     </div>
                 </div>
             </Mask>
+
             <Mask visible={visible} destroyOnClose={true} getContainer={null}>
                 <div
                     className={"absolute right-[0.2083rem] top-[18%] z-50"}

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

@@ -15,14 +15,14 @@ export interface CardProps {
     groupType?: Category["bet_type"];
 }
 
-const whiteUrls = ["site-front.tiktokjakjkl.icu", "192.168.0.84"];
+const whiteUrls = ["192.168.0.84", "localhost"];
 const Card: FC<PropsWithChildren<CardProps>> = (props) => {
     const { render, item, groupType } = props;
 
     const t = useTranslations("Game");
     const tcode = useTranslations();
     const brandRef = useRef<string>("");
-    const score = useWalletStore((state) => state.score);
+    const wallet = useWalletStore((state) => state.wallet);
 
     const [visible, setVisible] = useState(false);
 
@@ -31,14 +31,13 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
     const handler = (game: GameListRep) => {
         setVisible(true);
         brandRef.current = brandList.find((item) => item.gid === game.game_id)?.brand ?? "";
-        if (!token) return;
     };
     const playGameHandler = (game: GameListRep) => {
         if (!token) {
             router.push("/login?redirect=/");
             return;
         }
-        if (Number(score) <= 0) {
+        if (groupType === 1 && Number(wallet.score) <= 0) {
             router.push("/deposit");
             return;
         }
@@ -57,7 +56,7 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
                 if (res.data && res.data.game_url) {
                     const url = `${res.data?.game_url}&brand=${brandRef.current}&return_url=${process.env.NEXT_PUBLIC_SHARE_URL}`;
                     const protocol = new URL(url).protocol;
-                    if (protocol === "https:") {
+                    if (whiteUrls.indexOf(window.location.hostname) || protocol === "https:") {
                         router.push(`/game?${url}`);
                     } else {
                         window.open(url);