year 1 месяц назад
Родитель
Сommit
64b3d53b8e

+ 7 - 0
src/app/[locale]/(TabBar)/profile/agent.module.scss

@@ -0,0 +1,7 @@
+.agent {
+    margin: 0.15rem 0.15rem;
+    background-color: #1f2830;
+    padding: 0.1rem;
+    border-radius: 0.1rem;
+    font-size: 0.13rem;
+}

+ 106 - 0
src/app/[locale]/(TabBar)/profile/agent.tsx

@@ -0,0 +1,106 @@
+import { getCommissionApi } from "@/api/summary";
+import { useUserInfoStore } from "@/stores/useUserInfoStore";
+import { getToken } from "@/utils/Cookies";
+import { flatPoint } from "@/utils/methods";
+import { useRequest } from "ahooks";
+import clsx from "clsx";
+import React from "react";
+import styles from "./agent.module.scss";
+
+const Agent = () => {
+    const { userInfo } = useUserInfoStore();
+    const token = getToken();
+    const [BASE_URL, setBaseUrl] = React.useState("");
+    const url = React.useMemo(() => {
+        const shareUrl = `${BASE_URL}?share_id=${userInfo ? userInfo.referrer_code : "xxxxxx"}`;
+        return encodeURIComponent(`${shareUrl}`);
+    }, [BASE_URL, userInfo]);
+    const TIME = 180000;
+
+    const getCommission = () => {
+        if (token) {
+            return getCommissionApi().then((res) => {
+                if (res.code === 200) return res.data;
+            });
+        }
+        return Promise.resolve({
+            commissar: 0,
+            level: 0,
+            withdrawal_commissions: 0,
+            enable_receive: false,
+            min_value: 0,
+            max_value: 0,
+        });
+    };
+    const { data: commissionData, run: commissionRun } = useRequest(getCommission, {
+        pollingInterval: TIME,
+        pollingErrorRetryCount: 3,
+        staleTime: 5000,
+    });
+
+    const SHARE_SOURCE = React.useMemo(() => {
+        return [
+            {
+                icon: "/summary/Facebook.png",
+                label: "Facebook",
+                shareUrl: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
+            },
+            {
+                icon: "/summary/WhatsApp.png",
+                label: "WhatsApp",
+                shareUrl: `https://api.whatsapp.com/send?text=${url}`,
+            },
+            {
+                icon: "/summary/Telegram.png",
+                label: "Telegram",
+                shareUrl: `https://t.me/share/url?url=${url}`,
+            },
+            {
+                icon: "/summary/Twitter.png",
+                label: "Twitter",
+                shareUrl: `https://twitter.com/intent/tweet?text=${url}`,
+            },
+            {
+                icon: "/summary/Email.png",
+                label: "Email",
+                shareUrl: `mailto: ?&subject=&cc=&bcc=&body=${url}`,
+            },
+        ];
+    }, [url]);
+
+    return (
+        <div className={styles.agent}>
+            <div className="flex items-center justify-between">
+                <div>Agente</div>
+                <div className="flex items-center">
+                    <span>Ver Mais</span>
+                    <i className="iconfont icon-xiangyou1"></i>
+                </div>
+            </div>
+            <div className="my-[.06rem] flex items-center justify-between rounded-[.1rem] bg-[#2b363f] p-[.06rem]">
+                <div className="text-[#5f7880]">Comissäo direto de hoje</div>
+                <div className="text-[0.15rem] text-[#f6cf1d]">
+                    R${flatPoint(commissionData?.commissar || 0)}
+                </div>
+            </div>
+            <div className="my-[.1rem] text-center">Compartilhamento Rapido</div>
+            <div className="flex items-center justify-between rounded-[.1rem] bg-[#2b363f] p-[.1rem]">
+                {SHARE_SOURCE.map((item) => {
+                    return (
+                        <a
+                            href={token ? item.shareUrl : ""}
+                            target={"_blank"}
+                            className={clsx("mr-[.1rem] block w-[.4rem] text-center")}
+                            key={item.label}
+                        >
+                            <img className={"w-[100%]"} src={item.icon} alt="" />
+                            <span className="text-[.1rem] text-[#5f7880]">{item.label}</span>
+                        </a>
+                    );
+                })}
+            </div>
+        </div>
+    );
+};
+
+export default Agent;

+ 2 - 0
src/app/[locale]/(TabBar)/profile/page.tsx

@@ -3,6 +3,7 @@ import { userInfoApi } from "@/api/login";
 import { getUserMoneyApi, UserVipInfo } from "@/api/user";
 import { server } from "@/utils/client";
 import { useRequest } from "ahooks";
+import Agent from "./agent";
 import ItemCom from "./component/ItemCom";
 import ModalCom from "./component/ModalCom";
 import "./page.scss";
@@ -41,6 +42,7 @@ const Profile = () => {
                 userMoney={userMoney?.data}
                 userVip={userVip}
             />
+            <Agent></Agent>
             <ItemCom />
             <ModalCom />
         </div>

+ 25 - 1
src/components/Layout/Sidebar.tsx

@@ -1,15 +1,29 @@
 "use client";
+import { GroupType } from "@/api/home";
 import Box from "@/components/Box";
 import dialogManage from "@/dialog/manager";
 import { Link, usePathname, useRouter } from "@/i18n/routing";
 import { useProviderStore } from "@/stores/useProvider";
 import { useSystemStore } from "@/stores/useSystemStore";
+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 styles from "./style.module.scss";
 
+const getGames = async () => {
+    return server
+        .request<GroupType[]>({
+            url: "/v1/api/front/game_list",
+            method: "POST",
+        })
+        .then((res) => {
+            if (res.code === 200) return res.data;
+            return [];
+        });
+};
+
 interface Props {}
 
 const tabs = [
@@ -29,7 +43,7 @@ enum PageEnum {
 }
 const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
     // const t = useTranslations("Sidebar");
-    const { providers } = useProviderStore();
+    const { providers, setProviders } = useProviderStore();
 
     const locale = useLocale();
     // const swiper = useSwiper();
@@ -44,6 +58,16 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
         service: state.service,
     }));
 
+    React.useEffect(() => {
+        if (!providers || providers.length === 0) {
+            getGames().then((res) => {
+                const providersData = res[0].category.filter((item) => item.type === 2);
+                if (providersData.length === 0) return [] as any;
+                setProviders(providersData[0].game_list);
+            });
+        }
+    }, [providers]);
+
     const tabHandler = (index: PageEnum, isAction = true) => {
         bgRef.current?.setAttribute(
             "style",