|
@@ -1,5 +1,9 @@
|
|
|
"use client";
|
|
|
-import { GroupType } from "@/api/home";
|
|
|
+import {
|
|
|
+ // ContactType, getContactsApi,
|
|
|
+ getSidebarActivitiesApi,
|
|
|
+} from "@/api/config";
|
|
|
+import { BannerRep, GroupType } from "@/api/home";
|
|
|
import Box from "@/components/Box";
|
|
|
import dialogManage from "@/dialog/manager";
|
|
|
import { Link, usePathname, useRouter } from "@/i18n/routing";
|
|
@@ -9,7 +13,7 @@ import { server } from "@/utils/client";
|
|
|
import clsx from "clsx";
|
|
|
import { useLocale } from "next-intl";
|
|
|
import Image from "next/image";
|
|
|
-import React, { FC, PropsWithChildren, useEffect, useMemo, useRef } from "react";
|
|
|
+import React, { FC, PropsWithChildren, useEffect, useMemo, useRef, useState } from "react";
|
|
|
import styles from "./style.module.scss";
|
|
|
|
|
|
const getGames = async () => {
|
|
@@ -24,6 +28,19 @@ const getGames = async () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const registePromoClick = (activity_id: number) => {
|
|
|
+ return server
|
|
|
+ .request({
|
|
|
+ url: "/v1/api/front/activity_promotion_click",
|
|
|
+ method: "post",
|
|
|
+ data: { activity_id },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code === 200) return res.data;
|
|
|
+ return [];
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
interface Props {}
|
|
|
|
|
|
const tabs = [
|
|
@@ -106,7 +123,10 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
|
|
|
return index;
|
|
|
};
|
|
|
-
|
|
|
+ const registePromo = (id?: number) => {
|
|
|
+ if (!id) return;
|
|
|
+ registePromoClick(id);
|
|
|
+ };
|
|
|
useEffect(() => {
|
|
|
if (pathname === "/") {
|
|
|
tabHandler(PageEnum.home, false);
|
|
@@ -117,16 +137,18 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
|
|
|
// const [contacts, setContacts] = useState<ContactType[]>();
|
|
|
|
|
|
- // const [cardData, setCardData] = useState<BannerRep[]>([]);
|
|
|
- // useEffect(() => {
|
|
|
- // getContactsApi().then((res) => {
|
|
|
- // setContacts(res.data.filter((item) => item.show_bar === 1));
|
|
|
- // });
|
|
|
+ const [cardData, setCardData] = useState<BannerRep[]>([]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // getContactsApi().then((res) => {
|
|
|
+ // setContacts(res.data.filter((item) => item.show_bar === 1));
|
|
|
+ // });
|
|
|
|
|
|
- // getSidebarActivitiesApi().then((res) => {
|
|
|
- // setCardData(res.data);
|
|
|
- // });
|
|
|
- // }, []);
|
|
|
+ getSidebarActivitiesApi().then((res) => {
|
|
|
+ console.log(33, res.data);
|
|
|
+ setCardData(res.data);
|
|
|
+ });
|
|
|
+ }, []);
|
|
|
|
|
|
const serviceUrl: string = useMemo(() => {
|
|
|
if (!service) return "";
|
|
@@ -168,6 +190,7 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
handle: () => tabHandler(PageEnum.help),
|
|
|
},
|
|
|
];
|
|
|
+ // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
}, [serviceUrl, locale]);
|
|
|
|
|
|
const walletCfg = useMemo(() => {
|
|
@@ -199,6 +222,12 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
pathname: `/gameList2?provider_id=${item.id}`,
|
|
|
});
|
|
|
};
|
|
|
+ const promotionHandle = (item: any) => {
|
|
|
+ setCollapse(false);
|
|
|
+ // router.push({
|
|
|
+ // pathname: `/gameList2?provider_id=${item.id}`,
|
|
|
+ // });
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<Box pt={false} className={"h-[100%] bg-[#1e252b] px-[0px]"}>
|
|
@@ -264,7 +293,26 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
</div>
|
|
|
|
|
|
<div className={styles.promotionBox}>
|
|
|
- <div className={styles.promotionItem}>
|
|
|
+ {cardData.map((item) => {
|
|
|
+ return (
|
|
|
+ <Box
|
|
|
+ key={item.id}
|
|
|
+ action={item.action_type}
|
|
|
+ actionData={item.action_params}
|
|
|
+ className={styles.promoItem}
|
|
|
+ onBeforeHandler={() => registePromo(item.id)}
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ key={item.id}
|
|
|
+ className={styles.promotionItem}
|
|
|
+ onClick={() => promotionHandle(item)}
|
|
|
+ >
|
|
|
+ <img src={item.content} alt="" />
|
|
|
+ </div>
|
|
|
+ </Box>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ {/* <div className={styles.promotionItem}>
|
|
|
<img src="/sidebar/promotion.png" alt="" />
|
|
|
</div>
|
|
|
<div className={styles.promotionItem}>
|
|
@@ -275,7 +323,7 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
|
|
|
</div>
|
|
|
<div className={styles.promotionItem}>
|
|
|
<img src="/sidebar/promotion.png" alt="" />
|
|
|
- </div>
|
|
|
+ </div> */}
|
|
|
</div>
|
|
|
|
|
|
{listCfg.map((item) => {
|