Browse Source

feat: 增加厂牌数据

Before 1 year ago
parent
commit
a19ef6d00a
4 changed files with 98 additions and 13 deletions
  1. 2 2
      .env.development
  2. 5 3
      src/app/[locale]/layout.tsx
  3. 13 8
      src/components/Card/Card.tsx
  4. 78 0
      src/utils/constant.ts

+ 2 - 2
.env.development

@@ -1,2 +1,2 @@
-NEXT_PUBLIC_BASE_URL=http://192.168.0.66:8800
-#NEXT_PUBLIC_BASE_URL=http://206.168.191.125:8800
+#NEXT_PUBLIC_BASE_URL=http://192.168.0.66:8800
+NEXT_PUBLIC_BASE_URL=http://206.168.191.125:8800

+ 5 - 3
src/app/[locale]/layout.tsx

@@ -23,7 +23,7 @@ export const viewport: Viewport = {
 
 export const metadata = {
     keywords: ["Next.js"],
-    description: ["Next.js"],
+    description: "Next.js",
     appleWebApp: {
         statusBarStyle: "black",
     },
@@ -33,9 +33,11 @@ export const metadata = {
         telephone: false,
     },
     other: {
-        viewport: ["width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"],
+        viewport: [
+            "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover",
+        ],
     },
-}
+};
 
 export default async function LocaleLayout({
     children,

+ 13 - 8
src/components/Card/Card.tsx

@@ -2,6 +2,7 @@
 import { GameListRep, getGameDetailApi } from "@/api/home";
 import { useRouter } from "@/i18n";
 import { useGlobalStore } from "@/stores";
+import { brandList } from "@/utils/constant";
 import { Button, Modal, ModalBody, ModalContent, useDisclosure } from "@nextui-org/react";
 import { Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
@@ -13,21 +14,20 @@ export interface CardProps {
 }
 const Card: FC<PropsWithChildren<CardProps>> = (props) => {
     const { render, item } = props;
-    const { isOpen, onOpen, onOpenChange } = useDisclosure();
+    const { isOpen, onOpen, onOpenChange, onClose } = useDisclosure();
     const app: HTMLElement = document.querySelector("#app")!;
     const t = useTranslations("Game");
     const urlRef = useRef<string>("");
+    const brandRef = useRef<string>("");
 
     const state = useGlobalStore();
     const router = useRouter();
-
+    const { token } = state;
     const handler = (game: GameListRep) => {
-        const { token } = state;
         onOpen();
-        if (!token) {
-            router.push("/login?redirect=/withdraw");
-            return;
-        }
+        brandRef.current = brandList.find((item) => item.gid === game.game_id)?.brand ?? "";
+
+        if (!token) return;
         const params = {
             id: game.id,
         };
@@ -36,11 +36,16 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
         });
     };
     const playGameHandler = () => {
+        if (!token) {
+            router.push("/login?redirect=/withdraw");
+            return;
+        }
         if (urlRef.current) {
-            window.open(urlRef.current);
+            window.open(`${urlRef.current}&brand=${brandRef.current}`);
         } else {
             Toast.show("数据错误");
         }
+        onClose();
     };
     return (
         <>

+ 78 - 0
src/utils/constant.ts

@@ -0,0 +1,78 @@
+export const brandList = [
+    {
+        gid: "0600003",
+        brand: "",
+    },
+    {
+        gid: "0600004",
+        brand: "",
+    },
+    {
+        gid: "0600005",
+        brand: "",
+    },
+    {
+        gid: "0610002",
+        brand: "",
+    },
+    {
+        gid: "0610003",
+        brand: "",
+    },
+    {
+        gid: "0610004",
+        brand: "",
+    },
+    {
+        gid: "2000003",
+        brand: "jili",
+    },
+    {
+        gid: "0600006",
+        brand: "jili",
+    },
+    {
+        gid: "0600007",
+        brand: "jili",
+    },
+    {
+        gid: "1610002",
+        brand: "",
+    },
+    {
+        gid: "1600001",
+        brand: "pg",
+    },
+    {
+        gid: "1600002",
+        brand: "pg",
+    },
+    {
+        gid: "1600003",
+        brand: "pg",
+    },
+    {
+        gid: "1600004",
+        brand: "pg",
+    },
+    {
+        gid: "1600005",
+        brand: "pg",
+    },
+    {
+        gid: "1600006",
+        brand: "pg",
+    },
+    {
+        gid: "1600007",
+        brand: "pg",
+    },
+    {
+        gid: "1600008",
+        brand: "pg",
+    },
+    {
+        gid: "1600009",
+        brand: "pg",
+    },
+];