Explorar el Código

fix: 修改pixel 加载方式

ansoni hace 4 meses
padre
commit
30658d5eb0

+ 3 - 2
messages/br.json

@@ -429,7 +429,7 @@
     "phone":"Número de Celular",
     "phoneReg": "O número de telefone não pode estar vazio",
     "phoneMinReg": "Digite o número de telefone correto",
-    "phoneRules": "Número errado",
+    "phoneRules": "Número d e telefone errado",
     "password": "Senha",
     "passwordReg": "A senha não pode estar vazia",
     "newPwd": "Por favor, digite uma nova senha",
@@ -1198,6 +1198,7 @@
     "4":"Pagante",
     "5":"Falhou",
     "6":"Pendente",
-    "7":"Indeferido"
+    "7":"Indeferido",
+    "8":"Cancelado"
   }
 }

+ 3 - 2
messages/en.json

@@ -429,7 +429,7 @@
     "phone":"Phone Number",
     "phoneReg": "The phone number cannot be empty",
     "phoneMinReg": "Please enter the correct phone number",
-    "phoneRules": "Code Error",
+    "phoneRules": "Wrong phone number",
     "password": "Password",
     "passwordReg": "The password cannot be empty",
     "newPwd": "Please enter a new password",
@@ -1183,6 +1183,7 @@
     "4":"Paying",
     "5":"Failed",
     "6":"Pending",
-    "7":"Rejected"
+    "7":"Rejected",
+    "8":"Cancelado"
   }
 }

+ 2 - 1
src/api/user.ts

@@ -1,5 +1,6 @@
 import { GameListRep } from "@/api/home";
 import { server } from "@/utils/client";
+import { Local } from "@/utils/storage";
 
 // 前台用户绑定手机号
 export const getBindPhoneApi = () => {
@@ -267,7 +268,7 @@ export const getUserMoneyApi = () => {
 export const getUserRechargeApi = (data: any) => {
     return server.post<{ pay_url?: string }>({
         url: "/v1/api/user/user_recharge",
-        data: { ...data, click_id: localStorage.getItem("click_id") ?? undefined },
+        data: { ...data, click_id: Local.getKey("ban_click_id") ?? undefined },
         toast: true,
     });
 };

+ 4 - 0
src/app/[locale]/(TabBar)/[[...share]]/@actionWidget/Service.tsx

@@ -8,6 +8,7 @@ import WheelModal, { WheelModalProps } from "@/components/ModalPopup/WheelModal"
 
 import { getWheelApi } from "@/api/cashWheel";
 import { getGiveInfoApi } from "@/api/slots";
+import { useEventPoint } from "@/hooks/useEventPoint";
 import { Link } from "@/i18n/routing";
 import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
 import useWheelStore from "@/stores/useWheelStore";
@@ -272,6 +273,7 @@ const CustomerSection: FC<Omit<Props, "socials">> = (props) => {
 const ServiceWidget: FC<Props> = (props) => {
     const { services } = props;
 
+    const { eventView } = useEventPoint();
     const newServices = services?.filter((item) => item.status === 1) || [];
 
     const getWheel = () => {
@@ -284,6 +286,8 @@ const ServiceWidget: FC<Props> = (props) => {
     useEffect(() => {
         // 数据存储,侧边栏使用
         // setSocials(socials);
+        // pixel 埋点
+        // eventView();
     }, []);
 
     const t = useTranslations("HomePage");

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

@@ -1,6 +1,7 @@
 "use client";
 import { BannerRep } from "@/api/home";
 import { server } from "@/utils/client";
+import { Local } from "@/utils/storage";
 import { useEffect, useState } from "react";
 import HomeCard from "../_home/HomeCard";
 const getActivities = async () => {
@@ -8,7 +9,7 @@ const getActivities = async () => {
         .request<BannerRep[]>({
             url: "/v1/api/front/activity_home",
             method: "POST",
-            data: { click_id: localStorage.getItem("click_id") ?? undefined },
+            data: { click_id: Local.getKey("ban_click_id") ?? undefined },
         })
         .then((res) => {
             if (res.code === 200) {

+ 5 - 5
src/app/[locale]/(TabBar)/[[...share]]/@clientWidget/page.tsx

@@ -2,6 +2,7 @@
 import { getShareApi } from "@/api/config";
 import { useEventPoint } from "@/hooks/useEventPoint";
 import { usePathname } from "@/i18n/routing";
+import { Local } from "@/utils/storage";
 import { useEffect } from "react";
 
 /**
@@ -13,14 +14,13 @@ const Page = () => {
     // 获取分享id
     const pathname = usePathname();
     useEffect(() => {
-        localStorage.setItem("channel_code", window.location.href);
-        // 统计访问
-        getShareApi({ channel_url: window.location.href }).then((res) => {
-            console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 28`, res);
-        });
         // pixel 埋点
         eventView();
 
+        Local.setKey("channel_code", window.location.href);
+        // 统计访问
+        getShareApi({ channel_url: window.location.href });
+
         const [, shareId] = pathname.split("/");
         if (!shareId || shareId === "xxxxxx") return;
         if (shareId.length !== 8) {

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

@@ -9,6 +9,7 @@ import { useSystemStore } from "@/stores/useSystemStore";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { emailReg, neReg } from "@/utils";
 import { setCookies } from "@/utils/Cookies";
+import { Local } from "@/utils/storage";
 import {
     Checkbox,
     DatePicker,
@@ -207,6 +208,7 @@ const FormComponent: FC<Props> = (props) => {
                 });
             });
             if (loginResult?.code === 200) {
+                eventLogin();
                 setCookies("Token", loginResult.data.token as string);
                 const result = await userInfoApi();
                 if (result.code === 200) {
@@ -231,18 +233,19 @@ const FormComponent: FC<Props> = (props) => {
             const newValues = {
                 ...values,
                 referrer_code: sessionStorage.getItem("shareId") ?? undefined,
-                channel_code: localStorage.getItem("channel_code") ?? undefined,
+                channel_code: Local.getKey("channel_code") ?? undefined,
 
                 //  轮盘邀请
                 turntable_id: Number(sessionStorage.getItem("turntable_id")) ?? undefined,
                 turntable_user_id: Number(sessionStorage.getItem("turntable_user_id")) ?? undefined,
                 turntable_time: Number(sessionStorage.getItem("turntable_time")) ?? undefined,
                 // 快玩id
-                click_id: localStorage.getItem("click_id") ?? undefined,
+                click_id: Local.getKey("ban_click_id") ?? undefined,
             };
             registerApi(newValues)
                 .then(async (res) => {
                     if (res.code === 200) {
+                        eventRegister();
                         loginHandler({
                             pwd: values.pwd,
                             user_phone: values.user_phone,
@@ -251,8 +254,6 @@ const FormComponent: FC<Props> = (props) => {
                             router.replace("/recharge");
                             Toast.clear();
                         });
-
-                        eventRegister();
                     }
                 })
                 .catch((error) => {
@@ -273,8 +274,6 @@ const FormComponent: FC<Props> = (props) => {
                     ? `/${searchParams.get("redirect")}`
                     : "/";
                 router.replace(redirect);
-
-                eventLogin();
             });
         }
     };

+ 16 - 10
src/app/[locale]/affiliate/summary/page.tsx

@@ -354,24 +354,26 @@ const App: FC<Props> = (props) => {
                     <div className="cardMian">
                         <ul className="statistics-card">
                             <li>
-                                <p className="num">{todayData?.reg_count}</p>
+                                <p className="num">{flatPoint(todayData?.reg_count ?? 0)}</p>
                                 <p> {t("Inscrições")} </p>
                             </li>
                             <li>
-                                <p className="num">{todayData?.recharge_user_count}</p>
+                                <p className="num">
+                                    {flatPoint(todayData?.recharge_user_count ?? 0)}
+                                </p>
                                 <p> {t("Novos")} </p>
                             </li>
                             <li>
                                 <p className="num">
                                     <span className={"mr-[5px]"}>{t("R$")}</span>
-                                    {todayData?.effective_amount}
+                                    {flatPoint(todayData?.effective_amount ?? 0)}
                                 </p>
                                 <p> {t("Aposta")} </p>
                             </li>
                             <li>
                                 <p className="num">
                                     <span className={"mr-[5px]"}>{t("R$")}</span>
-                                    {todayData?.commissar}
+                                    {flatPoint(todayData?.commissar ?? 0)}
                                 </p>
                                 <p> {t("Comissão")} </p>
                             </li>
@@ -391,24 +393,26 @@ const App: FC<Props> = (props) => {
                     <div className="cardMian">
                         <ul className="statistics-card">
                             <li>
-                                <p className="num">{totalData?.reg_count}</p>
+                                <p className="num">{flatPoint(totalData?.reg_count ?? 0)}</p>
                                 <p> {t("Inscrições")} </p>
                             </li>
                             <li>
-                                <p className="num">{totalData?.recharge_user_count}</p>
+                                <p className="num">
+                                    {flatPoint(totalData?.recharge_user_count ?? 0)}
+                                </p>
                                 <p> {t("Jogadores")} </p>
                             </li>
                             <li>
                                 <p className="num">
                                     <span className={"mr-[5px]"}>{t("R$")}</span>
-                                    {totalData?.effective_amount}
+                                    {flatPoint(totalData?.effective_amount ?? 0)}
                                 </p>
                                 <p> {t("ApostaTotal")} </p>
                             </li>
                             <li>
                                 <p className="num">
                                     <span className={"mr-[5px]"}>{t("R$")}</span>
-                                    {totalData?.commissar}
+                                    {flatPoint(totalData?.commissar ?? 0)}
                                 </p>
                                 <p>RS {t("Comissão")} </p>
                             </li>
@@ -451,7 +455,7 @@ const App: FC<Props> = (props) => {
                                     <p className="num">
                                         <span>{t("R$")}</span>
                                         <span className="cash">
-                                            {commissionData?.withdrawal_commissions}
+                                            {flatPoint(commissionData?.withdrawal_commissions ?? 0)}
                                         </span>
                                     </p>
                                     <p> {t("TotalPago")} </p>
@@ -459,7 +463,9 @@ const App: FC<Props> = (props) => {
                                 <li>
                                     <p className="num">
                                         <span>{t("R$")}</span>
-                                        <span className="cash">{commissionData?.commissar}</span>
+                                        <span className="cash">
+                                            {flatPoint(commissionData?.commissar ?? 0)}
+                                        </span>
                                     </p>
                                     <p> {t("Não")} </p>
                                 </li>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 11 - 19
src/app/[locale]/providers.tsx


+ 3 - 3
src/components/Footer/index.tsx

@@ -110,7 +110,7 @@ const Footer: FC = () => {
         },
     });
     const { run: depositRun } = useRequest(getUserDepositApi, {
-        pollingInterval: 5000,
+        pollingInterval: 10000,
         pollingWhenHidden: true,
         pollingErrorRetryCount: 3,
         staleTime: 5000,
@@ -120,11 +120,11 @@ const Footer: FC = () => {
         onSuccess: (res) => {
             if (Object.keys(res.data).length < 0) return;
 
-            if (res.data.is_first_pay) {
+            if (res.data.is_first_pay === 1) {
                 eventFirstDeposit();
                 return;
             }
-            if (res.data.is_success) {
+            if (res.data.is_success === 1) {
                 eventPurchase();
             }
         },

+ 7 - 6
src/hooks/useEventPoint.tsx

@@ -1,3 +1,4 @@
+import { Local } from "@/utils/storage";
 import { useEffect, useState } from "react";
 
 /**
@@ -16,13 +17,13 @@ type PixelType = "kwai_pixel" | "facebook_pixel";
 const useEventPoint = () => {
     const [source, setSource] = useState<PixelType | null>(null);
     useEffect(() => {
-        setSource(localStorage.getItem("pixel_type") as PixelType | null);
+        setSource(Local.getKey("ban_pixel_type"));
     }, []);
 
     // 查看内容 | null
     const eventView = () => {
         if (source === "kwai_pixel") {
-            window.kwaiq.instance(localStorage.getItem("pixel_id")!).track("contentView");
+            window.kwaiq.track("contentView");
         }
         if (source === "facebook_pixel") {
             window.fbq("track", "ViewContent");
@@ -31,7 +32,7 @@ const useEventPoint = () => {
     // 注册
     const eventRegister = () => {
         if (source === "kwai_pixel") {
-            window.kwaiq.instance(localStorage.getItem("pixel_id")!).track("completeRegistration");
+            window.kwaiq.instance(Local.getKey("ban_pixel_id")).track("completeRegistration");
         }
         if (source === "facebook_pixel") {
             window.fbq("track", "CompleteRegistration");
@@ -52,10 +53,10 @@ const useEventPoint = () => {
         }
     };
 
-    // 加入购物车
+    // 充值
     const eventPurchase = () => {
         if (source === "kwai_pixel") {
-            window.kwaiq.instance(localStorage.getItem("pixel_id")!).track("purchase");
+            window.kwaiq.instance(Local.getKey("ban_pixel_id")).track("purchase");
         }
         if (source === "facebook_pixel") {
             window.fbq("track", "AddToCart");
@@ -72,7 +73,7 @@ const useEventPoint = () => {
     //首充事件
     const eventFirstDeposit = () => {
         if (source === "kwai_pixel") {
-            window.kwaiq.instance(localStorage.getItem("pixel_id")!).track("firstDeposit");
+            window.kwaiq.instance(Local.getKey("ban_pixel_id")).track("firstDeposit");
         }
         if (source === "facebook_pixel") {
             window.fbq("track", "Purchase");

+ 8 - 1
src/hooks/useLogout.ts

@@ -3,6 +3,7 @@ import { useRouter } from "@/i18n/routing";
 import { useSearchStore } from "@/stores/useSearchStore";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { useWalletStore } from "@/stores/useWalletStore";
+import { Local } from "@/utils/storage";
 import dayjs from "dayjs";
 import Cookies from "js-cookie";
 
@@ -18,13 +19,19 @@ export const useLogout = () => {
             restGlobal();
             resetSearch();
             restWalletStore();
-            localStorage.clear();
+            for (let i = 0; i < Local.length; i++) {
+                const key = Local.key(i)!;
+                if (key.indexOf("ban") === -1) {
+                    Local.removeKey(key);
+                }
+            }
             Cookies.remove("Token");
             router.replace("/login");
         }
         if (!isClearPromotion) {
             sessionStorage.clear();
         }
+
         return Promise.resolve(res);
     };
     return {

+ 68 - 0
src/utils/storage/index.ts

@@ -0,0 +1,68 @@
+type StorageType = "localStorage" | "sessionStorage";
+interface StorageKey {
+    ban_pixel_type: "kwai_pixel" | "facebook_pixel";
+    ban_pixel_id: string;
+    ban_click_id: string;
+    channel_code: string;
+}
+type Key = Extract<keyof StorageKey, string>;
+class CustomStorage {
+    private type: StorageType;
+    constructor(type: StorageType) {
+        this.type = type;
+    }
+
+    /**
+     * 设置
+     */
+    setKey<D extends StorageKey, V extends keyof StorageKey>(key: V, value: D[V]): void {
+        const val = typeof value === "string" ? value : JSON.stringify(value);
+        window[this.type]?.setItem(key, val);
+    }
+
+    /**
+     * 获取
+     */
+    getKey<U extends Key>(key: U): StorageKey[U] {
+        const result: any = window[this.type]?.getItem(key);
+        try {
+            return JSON.parse(result);
+        } catch (e) {
+            return result;
+        }
+    }
+
+    /**
+     * 移除
+     */
+    removeKey(key: Key): void {
+        window[this.type]?.removeItem(key);
+    }
+
+    /**
+     * key
+     */
+    key(index: number): Key | null {
+        const k: any = window[this.type]?.key(index);
+        return k;
+    }
+
+    /**
+     * 清除
+     */
+    clear() {
+        window[this.type]?.clear();
+    }
+
+    /**
+     * 长度
+     */
+    get length() {
+        return window[this.type]?.length;
+    }
+}
+
+const Local = new CustomStorage("localStorage");
+const Session = new CustomStorage("sessionStorage");
+
+export { Local, Session };

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio