ソースを参照

feat: 增加是否严格注册cpf

Before 6 ヶ月 前
コミット
37df933f1d

+ 27 - 6
src/api/config.ts

@@ -1,8 +1,24 @@
-import { server } from "@/utils/server";
+import { server } from "@/utils/client";
+type SwitchType = 1 | 2; // 1开启 2关闭
 
 export interface ConfigType {
-    show_free_game: 1 | 2;
-    show_again_game: 1 | 2;
+    show_free_game: SwitchType;
+    show_again_game: SwitchType;
+    identity_verify: IdentityVerify;
+}
+export interface IdentityVerify {
+    /**
+     * 充值实名,1开启 2关闭
+     */
+    deposit: SwitchType;
+    /**
+     * 注册实名,1开启 2关闭
+     */
+    register: SwitchType;
+    /**
+     * 提现实名,1开启 2关闭
+     */
+    withdraw: SwitchType;
 }
 export const getConfigApi = async () => {
     return server
@@ -12,8 +28,13 @@ export const getConfigApi = async () => {
         })
         .then((res) => {
             return res.data;
-        })
-        .catch((err) => {
-            return { show_free_game: 1, show_again_game: 1 } as ConfigType;
         });
 };
+
+export const getShareApi = async (params: { channel_url: string }) => {
+    return server.request({
+        url: `/channel/add_click`,
+        method: "get",
+        params,
+    });
+};

+ 12 - 7
src/app/[locale]/(TabBar)/[[...share]]/_home/HomeTabs.tsx

@@ -1,8 +1,8 @@
 "use client";
-import { ConfigType } from "@/api/config";
 import { GroupType } from "@/api/home";
 import Box from "@/components/Box";
 import { useRouter } from "@/i18n/routing";
+import { useSystemStore } from "@/stores/useSystemStore";
 import { Toast } from "antd-mobile";
 import clsx from "clsx";
 import { useTranslations } from "next-intl";
@@ -81,6 +81,7 @@ const TabItem = ({
 }) => {
     const t = useTranslations("ButtonGroup");
     const router = useRouter();
+
     const handler = (item: TabItemType) => {
         if (!item.locale) {
             onClick && onClick(item);
@@ -104,7 +105,7 @@ const TabItem = ({
     );
     return (
         <div className={rootCls} onClick={() => handler(item)}>
-            <span className={item.icon === 'qianbao3' ? cls2 : cls}></span>
+            <span className={item.icon === "qianbao3" ? cls2 : cls}></span>
             <span className={"ml-[0.03rem] truncate"}>
                 {item.locale ? t(item.category_name) : item.category_name}
             </span>
@@ -121,16 +122,20 @@ const TabItem = ({
 
 interface Props {
     tabs: GroupType[];
-    config: ConfigType;
 }
 const Tabs: FC<Props> = (props) => {
-    const { tabs, config = { show_free_game: 2, show_again_game: 2 } } = props;
-
+    const { tabs } = props;
+    const { show_again_game, show_free_game } = useSystemStore((state) => {
+        return {
+            show_again_game: state.show_again_game,
+            show_free_game: state.show_free_game,
+        };
+    });
     const newButtonGroup = buttonGroup.filter((item: any) => {
-        if (item.url === "/freeGames" && config.show_free_game !== 1) {
+        if (item.url === "/freeGames" && show_free_game !== 1) {
             return false;
         }
-        if (item.url === "/replayGames" && config.show_again_game !== 1) {
+        if (item.url === "/replayGames" && show_again_game !== 1) {
             return false;
         }
         return true;

+ 1 - 3
src/app/[locale]/(TabBar)/[[...share]]/page.tsx

@@ -1,5 +1,4 @@
 "use server";
-import { getConfigApi } from "@/api/config";
 import { GroupType } from "@/api/home";
 import { server } from "@/utils/server";
 import HomeTabs from "./_home/HomeTabs";
@@ -21,10 +20,9 @@ const getGames = async () => {
 export default async function Page() {
     const group = await getGames();
 
-    const config = await getConfigApi();
     return (
         <>
-            <HomeTabs tabs={group} config={config} />
+            <HomeTabs tabs={group} />
         </>
     );
 }

+ 4 - 2
src/app/[locale]/(TabBar)/deposit/DepositData.tsx

@@ -14,6 +14,7 @@ import { FC, Fragment, useLayoutEffect, useRef, useState } from "react";
 import actions from "@/app/[locale]/(TabBar)/deposit/actions";
 import Empty from "@/components/Empty";
 import { useRouter } from "@/i18n/routing";
+import { useSystemStore } from "@/stores/useSystemStore";
 import "@/styles/deposit.scss";
 import { server } from "@/utils/client";
 interface Props {}
@@ -78,6 +79,9 @@ const DepositData: FC<Props> = (props) => {
     const t = useTranslations();
     const router = useRouter();
     const userInfo = useUserInfoStore((state) => state.userInfo);
+
+    const isStrictMode = useSystemStore((state) => state.identity_verify.deposit === 1);
+
     const [depositState, setDepositState] = useState<DepositsTypes[]>([]);
 
     const [activeType, setActiveType] = useState<Partial<DepositsTypes>>({});
@@ -90,8 +94,6 @@ const DepositData: FC<Props> = (props) => {
         formInstanceRef.current?.resetFields();
     };
 
-    const isStrictMode = true;
-
     const tipModelRef = useRef<ModalProps>(null); // 充值清空打码量弹窗
     const [formData, setFormData] = useState<any>({}); // 存放表单数据
     const onFinish = async (values: any) => {

+ 3 - 2
src/app/[locale]/(enter)/components/Form/index.tsx

@@ -4,6 +4,7 @@ import Box from "@/components/Box";
 import ButtonOwn from "@/components/ButtonOwn";
 import MobileField from "@/components/Fields/MobileField";
 import { Link, useRouter } from "@/i18n/routing";
+import { useSystemStore } from "@/stores/useSystemStore";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { emailReg, neReg } from "@/utils";
 import { setCookies } from "@/utils/Cookies";
@@ -133,10 +134,10 @@ interface FormInitStateTypes extends FormProps {
 type FormType = "login" | "register";
 interface Props {
     type?: FormType;
-    isStrictMode?: boolean;
 }
 const FormComponent: FC<Props> = (props) => {
-    const { type = "register", isStrictMode = true } = props;
+    const { type = "register" } = props;
+    const isStrictMode = useSystemStore().identity_verify.register === 1;
     const { setUserInfo } = useUserInfoStore();
     const t = useTranslations();
     const searchParams = useSearchParams();

+ 2 - 1
src/app/[locale]/(navbar)/doings/discount/DepositData.tsx

@@ -11,6 +11,7 @@ import { FC, Fragment, useLayoutEffect, useRef, useState } from "react";
 
 import ButtonOwn from "@/components/ButtonOwn";
 import { useRouter } from "@/i18n/routing";
+import { useSystemStore } from "@/stores/useSystemStore";
 import "@/styles/deposit.scss";
 import { server } from "@/utils/client";
 import Image from "next/image";
@@ -93,7 +94,7 @@ const DepositData: FC<Props> = (props) => {
         formInstanceRef.current?.resetFields();
     };
 
-    const isStrictMode = true;
+    const isStrictMode = useSystemStore((state) => state.identity_verify.deposit === 1);
 
     const onFinish = (values: any) => {
         const params = { ...values, channel_id: activeType.id, amount: +values.amount };

+ 7 - 6
src/app/[locale]/(navbar)/download/page.tsx

@@ -63,6 +63,7 @@ function pow1024(num: number) {
 }
 const Page = async () => {
     const { data } = await getAppInfoApi();
+    console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 66`, data);
     return (
         <div
             className={"h-[100%] p-[20px]"}
@@ -85,17 +86,17 @@ const Page = async () => {
                 <p>Baixe o APP e jogue agora! </p>
             </div>
 
-            <div
+            <a
+                href={data.url}
                 className={
                     "relative h-[80px] bg-[url(/download/button.png)]" +
                     " mt-[0.0694rem] flex bg-contain bg-center bg-no-repeat" +
-                    " items-center justify-center"
+                    " items-center justify-center font-bold text-[#fff]"
                 }
+                download={data.name}
             >
-                <a href={data.url} className={"font-bold text-[#fff]"} download={data.name}>
-                    BAIXAR AGORA ({filterSize(data.size)})
-                </a>
-            </div>
+                BAIXAR AGORA ({filterSize(data.size)})
+            </a>
 
             <div className={"mt-[10px] text-center text-[#b1b1b1]"}>
                 <p className={"text-[0.12rem]"}>Requer Android 4.4 ou acimat</p>

+ 35 - 26
src/app/[locale]/(navbar)/withdraw/WithdrawWidget.tsx

@@ -10,6 +10,7 @@ import Empty from "@/components/Empty";
 import MobileField from "@/components/Fields/MobileField";
 import TipsModal, { ModalProps } from "@/components/TipsModal";
 import useGame from "@/hooks/useGame";
+import { useSystemStore } from "@/stores/useSystemStore";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { useWalletStore } from "@/stores/useWalletStore";
 import { isEmail } from "@/utils";
@@ -145,6 +146,8 @@ const WithdrawWidget: FC<Props> = (props) => {
     const { channels, wallet } = props;
     const { getGameUrl } = useGame();
 
+    const isStrictMode = useSystemStore((state) => state.identity_verify.withdraw === 1);
+
     const score = useWalletStore((state) => state.score)!;
 
     // 彩金
@@ -325,32 +328,38 @@ const WithdrawWidget: FC<Props> = (props) => {
                         className={"mt-[0.1rem]"}
                         footer={<ButtonOwn active>{t("WithdrawPage.Saque")}</ButtonOwn>}
                     >
-                        <Form.Item
-                            name="user_name"
-                            label=""
-                            rules={[{ required: true, message: t("WithdrawPage.usernameReg") }]}
-                        >
-                            <Input placeholder={t("WithdrawPage.username")} />
-                        </Form.Item>
-
-                        <Form.Item
-                            name="passport"
-                            label=""
-                            rules={[
-                                {
-                                    required: true,
-                                    message: t("WithdrawPage.cpfReg"),
-                                    min: 6,
-                                    max: 20,
-                                },
-                            ]}
-                        >
-                            <Input
-                                placeholder={t("WithdrawPage.cpf")}
-                                maxLength={20}
-                                type={"text"}
-                            />
-                        </Form.Item>
+                        {isStrictMode ? (
+                            <>
+                                <Form.Item
+                                    name="user_name"
+                                    label=""
+                                    rules={[
+                                        { required: true, message: t("WithdrawPage.usernameReg") },
+                                    ]}
+                                >
+                                    <Input placeholder={t("WithdrawPage.username")} />
+                                </Form.Item>
+
+                                <Form.Item
+                                    name="passport"
+                                    label=""
+                                    rules={[
+                                        {
+                                            required: true,
+                                            message: t("WithdrawPage.cpfReg"),
+                                            min: 6,
+                                            max: 20,
+                                        },
+                                    ]}
+                                >
+                                    <Input
+                                        placeholder={t("WithdrawPage.cpf")}
+                                        maxLength={20}
+                                        type={"text"}
+                                    />
+                                </Form.Item>
+                            </>
+                        ) : null}
 
                         <p className={"my-[0.1rem]"}>{t("WithdrawPage.Tipo")}</p>
 

+ 15 - 22
src/app/[locale]/providers.tsx

@@ -5,10 +5,11 @@ import { useSystemStore } from "@/stores/useSystemStore";
 import { ConfigProvider } from "antd-mobile";
 import enUS from "antd-mobile/es/locales/en-US";
 import { ThemeProviderProps } from "next-themes/dist/types";
-import { ReactNode, useLayoutEffect, useRef } from "react";
+import { ReactNode, useRef } from "react";
 import { Swiper, SwiperClass, SwiperSlide } from "swiper/react";
 
-import { setHtmlFontSize } from "@/utils";
+import { getShareApi } from "@/api/config";
+import { setupFontSize } from "@/utils";
 import { useDebounceEffect } from "ahooks";
 import { initializeApp } from "firebase/app";
 import { getMessaging, getToken, onMessage } from "firebase/messaging";
@@ -16,26 +17,12 @@ export interface ProvidersProps {
     children: ReactNode;
     themeProps?: Omit<ThemeProviderProps, "children">;
 }
-
+// 初始化 fireBase
 const initFirebase = () => {
     // 是否是https
     if (document.location.protocol.indexOf("https") === -1) return;
     //  浏览器是否支持 且是 pwa
     if (!window.Notification) {
-        // Dialog.alert({
-        //     getContainer: null,
-        //     bodyStyle: { background: "#fff" },
-        //     title: "提示",
-        //     confirmText: "我知道了",
-        //     content: (
-        //         <>
-        //             <div className={"text-center"}>
-        //                 <p>当前版本浏览器不支持通知</p>
-        //                 <p>请更换或升级浏览器获得更好使用体验</p>
-        //             </div>
-        //         </>
-        //     ),
-        // });
         return;
     }
     //  是否开启通知
@@ -96,11 +83,6 @@ const Layout = ({ children, themeProps }: ProvidersProps) => {
         setCollapse(false);
     };
 
-    useLayoutEffect(() => {
-        // 调用响应式方法
-        setHtmlFontSize();
-    }, []);
-
     return (
         <div id="app" className="bg-black">
             <Swiper
@@ -138,11 +120,22 @@ const Layout = ({ children, themeProps }: ProvidersProps) => {
         </div>
     );
 };
+
 export const Providers = ({ children, themeProps }: ProvidersProps) => {
+    const setupConfig = useSystemStore((state) => state.setupConfig);
+
     useDebounceEffect(() => {
         if ("serviceWorker" in navigator) {
             initFirebase();
         }
+
+        // 初始化配置
+        setupConfig();
+        // 初始化字体
+        setupFontSize();
+        // 初始化参数地址
+
+        getShareApi({ channel_url: window.location.href });
     }, []);
 
     return (

+ 0 - 1
src/components/Fields/MobileField.tsx

@@ -30,7 +30,6 @@ const MobileField: FC<MobileFieldProps> = ({
     const onRealValueChange = (value: string) => {
         triggerValue({ realValue: value.replace(/[^0-9]/g, "") });
     };
-    console.log(`🚀🚀🚀🚀🚀-> in MobileField.tsx on 32`, value);
 
     // const onPreValueChange = (value: PickerValue[]) => {
     //     const v = value[0];

+ 25 - 1
src/stores/useSystemStore.ts

@@ -1,6 +1,7 @@
+import { ConfigType, getConfigApi } from "@/api/config";
 import { create } from "zustand";
 
-interface State {
+interface State extends ConfigType {
     isCollapse: boolean;
     isHasDesktop: boolean | undefined;
 }
@@ -8,6 +9,7 @@ interface State {
 interface Action {
     setCollapse: (value: boolean) => void;
     setHasDesktop: (value: boolean) => void;
+    setupConfig: () => void;
 }
 
 const initialState: State = {
@@ -15,6 +17,19 @@ const initialState: State = {
     isCollapse: false,
     // 是否含有快应用
     isHasDesktop: undefined,
+    show_free_game: 2,
+    show_again_game: 2,
+    identity_verify: {
+        deposit: 2,
+        /**
+         * 注册实名,
+         */
+        register: 2,
+        /**
+         * 提现实名
+         */
+        withdraw: 2,
+    },
 };
 
 /**
@@ -25,6 +40,15 @@ export const useSystemStore = create<State & Action>()((set, get) => {
         ...initialState,
         setCollapse: (value) => set((state) => ({ ...state, isCollapse: value })),
         setHasDesktop: (value) => set((state) => ({ ...state, isHasDesktop: value })),
+
+        setupConfig: () => {
+            try {
+                getConfigApi().then((config) => {
+                    console.log(`🚀🚀🚀🚀🚀-> in useSystemStore.ts on 47`, config);
+                    set((state) => ({ ...state, ...config }));
+                });
+            } catch (e) {}
+        },
         reset: () => set(initialState),
     };
 });

+ 2 - 2
src/utils/index.ts

@@ -1,6 +1,6 @@
 // 设置根节点html的字体大小用于移动端适配使用
-export const setHtmlFontSize = () => {
-    console.count("setHtmlFontSize");
+export const setupFontSize = () => {
+    console.count("setupFontSize");
     (function (doc, win) {
         let resizeEvt = "orientationchange" in win ? "orientationchange" : "resize",
             recalc = function () {