Ver Fonte

fix: 登录页面优化

ansoni há 2 meses atrás
pai
commit
d8dc701d9d

+ 2 - 5
.env.local

@@ -1,8 +1,7 @@
 #baseurl
-NEXT_PUBLIC_BASE_URL=https://api.bcwin777.com
+NEXT_PUBLIC_BASE_URL=https://hk-api.tiktokjakjkl.icu
 #share link
-NEXT_PUBLIC_SHARE_URL=https://bcwin777.com
-
+NEXT_PUBLIC_SHARE_URL=https://hk-site.tiktokjakjkl.icu
 #firebase
 NEXT_PUBLIC_FIREBASE_APIKEY=AIzaSyCIE8xtySsYztsSgmQJx_aqPrrpHEuvgvw
 NEXT_PUBLIC_FIREBASE_AUTHDOMAIN=bcwin777-1bdda.firebaseapp.com
@@ -12,5 +11,3 @@ NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID=542456379513
 NEXT_PUBLIC_FIREBASE_APPID=1:542456379513:web:851a46fc639085170bfca8
 NEXT_PUBLIC_FIREBASE_MEASUREMENTID=G-GV6Y8DXHHD
 NEXT_PUBLIC_FIREBASE_KEYS=BOCfpA08vK6uxhMdRblnx9gPVBLx9WpTn9AutVNhHQQpVtXzDIKW0X6cmsNRaFDhyFDJfMqWjqC7mq6uDFIKU_M
-
-

+ 1 - 2
next.config.mjs

@@ -1,10 +1,9 @@
 /** @type {import('next').NextConfig} */
 import createNextIntlPlugin from "next-intl/plugin";
 const withNextIntl = createNextIntlPlugin();
-
 /** @type {import('next').NextConfig} */
 const nextConfig = {
-    output: "standalone",
+    // output: process.env.NODE_ENV === "develop" ? undefined : "standalone",
     reactStrictMode: false,
     env: {
         BUILD_ENV: process.env.BUILD_ENV,

+ 36 - 2
src/app/[locale]/(TabBar)/profile/component/ItemCom/index.tsx

@@ -1,7 +1,10 @@
 "use client";
+import { CashbackTypes } from "@/api/cashback";
 import { getWheelApi } from "@/api/cashWheel";
 import { useRouter } from "@/i18n/routing";
 import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
+import { server } from "@/utils/client";
+import { useRequest } from "ahooks";
 import { Badge, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import { FC } from "react";
@@ -14,10 +17,32 @@ import "./style.scss";
  */
 export interface ItemComProps {
     type?: string;
-    max: number;
 }
+const getCashBackApi = async () => {
+    return server
+        .request<CashbackTypes>({
+            url: "/v1/api/front/activity_cash",
+            method: "post",
+        })
+        .then((res) => {
+            return res.data;
+        })
+        .catch((error) => {
+            return {
+                rules: [],
+                last_period: { end_time: 0, start_time: 0 },
+                next_period: {
+                    end_time: 0,
+                    start_time: 0,
+                },
+                amount: 0,
+                bet: 0,
+                status: "expired",
+            };
+        });
+};
 
-const ItemCom: FC<ItemComProps> = ({ max, type = "login" }) => {
+const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
     const t = useTranslations("ProfilePage");
     const tall = useTranslations();
     const router = useRouter();
@@ -25,6 +50,15 @@ const ItemCom: FC<ItemComProps> = ({ max, type = "login" }) => {
         unread: state.unread,
         userUnread: state.userUnred,
     }));
+    const { data: cashback } = useRequest<any, any>(getCashBackApi, {
+        pollingErrorRetryCount: 1,
+        pollingWhenHidden: false,
+    });
+
+    const max = cashback?.rules.reduce(
+        (acc: any, item: any) => (acc > item.cashback ? acc : item.cashback),
+        0
+    );
     const links = [
         // { label: "gratis", desc: "gratisDesc", icon: "", url: "/", content: null },
         {

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

@@ -0,0 +1,82 @@
+import { CashbackTypes } from "@/api/cashback";
+import { UserInfoRep, UserVipInfo } from "@/api/user";
+import { getMoneyApi } from "@/api/userWallt";
+import { server } from "@/utils/server";
+import ItemCom from "./component/ItemCom";
+import ModalCom from "./component/ModalCom";
+import "./page.scss";
+import { ProfileHeader } from "./ProfileHeader";
+
+const getUserInfo = async () => {
+    return server
+        .request<UserInfoRep>({
+            url: "/v1/api/user/user_info",
+            method: "POST",
+            next: { revalidate: 0 },
+        })
+        .then((res) => {
+            if (res.code === 200) return res.data;
+            return {};
+        });
+};
+
+/**
+ * @description  前台用户VIP信息 接口地址:https://app.apifox.com/link/project/4790544/apis/api-201160713
+ */
+const getVipApi = async () => {
+    return server
+        .request<UserVipInfo>({
+            url: "/v1/api/user/user_vip_info",
+            method: "POST",
+            cache: "no-cache",
+        })
+        .then((res) => {
+            if (res.code === 200) return res.data;
+        });
+};
+
+const getCashBackApi = async () => {
+    return server
+        .request<CashbackTypes>({
+            url: "/v1/api/front/activity_cash",
+            method: "post",
+        })
+        .then((res) => {
+            return res.data;
+        })
+        .catch((error) => {
+            return {
+                rules: [],
+                last_period: { end_time: 0, start_time: 0 },
+                next_period: {
+                    end_time: 0,
+                    start_time: 0,
+                },
+                amount: 0,
+                bet: 0,
+                status: "expired",
+            };
+        });
+};
+export const dynamic = "force-dynamic";
+export const revalidate = 0;
+const Profile = async () => {
+    const userInfo = await getUserInfo();
+    const userMoney = await getMoneyApi();
+    const userVip = await getVipApi();
+    const cashback = await getCashBackApi();
+    const max = cashback?.rules.reduce(
+        (acc, item) => (acc > item.cashback ? acc : item.cashback),
+        0
+    );
+
+    return (
+        <div className="profile-box">
+            <ProfileHeader userInfo={userInfo} userMoney={userMoney} userVip={userVip!} />
+            <ItemCom />
+            <ModalCom />
+        </div>
+    );
+};
+
+export default Profile;

+ 19 - 53
src/app/[locale]/(TabBar)/profile/page.tsx

@@ -1,25 +1,13 @@
-import { CashbackTypes } from "@/api/cashback";
-import { UserInfoRep, UserVipInfo } from "@/api/user";
-import { getMoneyApi } from "@/api/userWallt";
-import { server } from "@/utils/server";
+"use client";
+import { userInfoApi } from "@/api/login";
+import { getUserMoneyApi, UserVipInfo } from "@/api/user";
+import { server } from "@/utils/client";
+import { useRequest } from "ahooks";
 import ItemCom from "./component/ItemCom";
 import ModalCom from "./component/ModalCom";
 import "./page.scss";
 import { ProfileHeader } from "./ProfileHeader";
 
-const getUserInfo = async () => {
-    return server
-        .request<UserInfoRep>({
-            url: "/v1/api/user/user_info",
-            method: "POST",
-            next: { revalidate: 0 },
-        })
-        .then((res) => {
-            if (res.code === 200) return res.data;
-            return {};
-        });
-};
-
 /**
  * @description  前台用户VIP信息 接口地址:https://app.apifox.com/link/project/4790544/apis/api-201160713
  */
@@ -28,52 +16,30 @@ const getVipApi = async () => {
         .request<UserVipInfo>({
             url: "/v1/api/user/user_vip_info",
             method: "POST",
-            cache: "no-cache",
         })
         .then((res) => {
             if (res.code === 200) return res.data;
         });
 };
 
-const getCashBackApi = async () => {
-    return server
-        .request<CashbackTypes>({
-            url: "/v1/api/front/activity_cash",
-            method: "post",
-        })
-        .then((res) => {
-            return res.data;
-        })
-        .catch((error) => {
-            return {
-                rules: [],
-                last_period: { end_time: 0, start_time: 0 },
-                next_period: {
-                    end_time: 0,
-                    start_time: 0,
-                },
-                amount: 0,
-                bet: 0,
-                status: "expired",
-            };
-        });
-};
-export const dynamic = "force-dynamic";
-export const revalidate = 0;
-const Profile = async () => {
-    const userInfo = await getUserInfo();
-    const userMoney = await getMoneyApi();
-    const userVip = await getVipApi();
-    const cashback = await getCashBackApi();
-    const max = cashback?.rules.reduce(
-        (acc, item) => (acc > item.cashback ? acc : item.cashback),
-        0
-    );
+const Profile = () => {
+    const { data: userInfo } = useRequest<any, any>(userInfoApi, {
+        pollingErrorRetryCount: 1,
+        pollingWhenHidden: false,
+    });
+    const { data: userMoney } = useRequest<any, any>(getUserMoneyApi, {
+        pollingErrorRetryCount: 1,
+        pollingWhenHidden: false,
+    });
+    const { data: userVip } = useRequest<any, any>(getVipApi, {
+        pollingErrorRetryCount: 1,
+        pollingWhenHidden: false,
+    });
 
     return (
         <div className="profile-box">
             <ProfileHeader userInfo={userInfo} userMoney={userMoney} userVip={userVip!} />
-            <ItemCom max={max} />
+            <ItemCom />
             <ModalCom />
         </div>
     );

+ 6 - 8
src/app/[locale]/(TabBar)/promo/layout.tsx

@@ -1,6 +1,4 @@
-"use client";
 import HeaderBack from "@/components/HeaderBack";
-import { useRouter } from "@/i18n/routing";
 import { useTranslations } from "next-intl";
 import { ReactNode } from "react";
 
@@ -12,13 +10,13 @@ export default function Layout({
     params: { locale: string };
 }) {
     const t = useTranslations("Sidebar");
-    const router = useRouter();
+    // const router = useRouter();
 
-    const goRecord = () => {
-        router.push({
-            pathname: "/promo/record",
-        });
-    };
+    // const goRecord = () => {
+    //     router.push({
+    //         pathname: "/promo/record",
+    //     });
+    // };
 
     return (
         <div className="h-[100%] overflow-auto bg-[url('/home/bg.jpg')]">

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

@@ -210,6 +210,7 @@ const FormComponent: FC<Props> = (props) => {
             if (loginResult?.code === 200) {
                 eventLogin();
                 setCookies("Token", loginResult.data.token as string);
+                // loginAction(loginResult.data.token)
                 const result = await userInfoApi();
                 if (result.code === 200) {
                     setUserInfo(result.data);

+ 33 - 0
src/app/[locale]/(enter)/login/LoginService.tsx

@@ -0,0 +1,33 @@
+import { getServicesApi } from "@/api/customservice";
+import Link from "next/link";
+
+const LoginService = async () => {
+    const services = await getServicesApi();
+    const defaultService = services?.filter((item) => item.register_show === 1);
+    return (
+        <div
+            className={`absolute bottom-[0.84rem] right-[0.12rem] z-50 flex w-[0.6944rem] flex-col items-center justify-center`}
+        >
+            {defaultService &&
+                defaultService.map((item, index) => (
+                    <Link
+                        key={index}
+                        href={item.url}
+                        className={
+                            "flex h-[0.54rem] w-[0.54rem] items-center justify-center rounded-[50%]" +
+                            " mb-[0.2778rem] bg-gradient-to-t from-[#ff611b] to-[#ffcf35]"
+                        }
+                        target={"_blank"}
+                    >
+                        <img
+                            className={"h-[0.3889rem] w-[0.3889rem] object-contain"}
+                            src={item.icon_url}
+                            alt={""}
+                        ></img>
+                    </Link>
+                ))}
+        </div>
+    );
+};
+
+export default LoginService;

+ 19 - 2
src/app/[locale]/(enter)/login/adbox.tsx

@@ -1,16 +1,33 @@
 "use client";
 import { AdItem } from "@/api/customservice";
 import { useRouter } from "@/i18n/routing";
+import { server } from "@/utils/client";
+import { useRequest } from "ahooks";
 import React from "react";
 import { Autoplay, Pagination } from "swiper/modules";
 import { Swiper, SwiperSlide } from "swiper/react";
+export const getLoginAdApi = async () => {
+    return server
+        .request<AdItem[]>({
+            url: "/v1/api/front/activity_promotion_guests",
+            method: "POST",
+        })
+        .then((res) => {
+            return res.data;
+        })
+        .catch((err) => {
+            return [];
+        });
+};
 
 interface AdboxProps {
-    data: AdItem[];
+    // data: AdItem[];
 }
 
-const Adbox: React.FC<AdboxProps> = ({ data }) => {
+const Adbox: React.FC<AdboxProps> = () => {
     const router = useRouter();
+
+    const { data } = useRequest(getLoginAdApi);
     const doClick = async (data: AdItem) => {
         switch (data.action_type) {
             case 2:

+ 8 - 29
src/app/[locale]/(enter)/login/page.tsx

@@ -1,18 +1,15 @@
 "use server";
-import { getLoginAdApi, getServicesApi } from "@/api/customservice";
-import { Link } from "@/i18n/routing";
 import { getTranslations } from "next-intl/server";
+import { Suspense } from "react";
 import Form from "../components/Form";
 import GoogleCom from "../components/GoogleCom";
 import Adbox from "./adbox";
 import "./index.scss";
+import LoginService from "./LoginService";
 
 const Login = async () => {
     const t = await getTranslations("LoginPage");
-    const services = await getServicesApi();
-    const adInfo = await getLoginAdApi();
-    const defaultService = services?.filter((item) => item.register_show === 1);
-    console.log(1122, adInfo);
+
     return (
         <>
             <GoogleCom />
@@ -22,29 +19,11 @@ const Login = async () => {
                 <span className={"iconfont icon-a-18 text-[red]"}></span>
             </div>
 
-            <Adbox data={adInfo}></Adbox>
-            <div
-                className={`absolute bottom-[0.84rem] right-[0.12rem] z-50 flex w-[0.6944rem] flex-col items-center justify-center`}
-            >
-                {defaultService &&
-                    defaultService.map((item, index) => (
-                        <Link
-                            key={index}
-                            href={item.url}
-                            className={
-                                "flex h-[0.54rem] w-[0.54rem] items-center justify-center rounded-[50%]" +
-                                " mb-[0.2778rem] bg-gradient-to-t from-[#ff611b] to-[#ffcf35]"
-                            }
-                            target={"_blank"}
-                        >
-                            <img
-                                className={"h-[0.3889rem] w-[0.3889rem] object-contain"}
-                                src={item.icon_url}
-                                alt={""}
-                            ></img>
-                        </Link>
-                    ))}
-            </div>
+            <Adbox></Adbox>
+
+            <Suspense fallback={<div></div>}>
+                <LoginService />
+            </Suspense>
         </>
     );
 };