Browse Source

fix: 个人中心-轮盘优化

Before 7 months ago
parent
commit
8f7c4829fd
2 changed files with 21 additions and 7 deletions
  1. 1 1
      .env.local
  2. 20 6
      src/app/[locale]/(TabBar)/profile/component/ItemCom/index.tsx

+ 1 - 1
.env.local

@@ -1,6 +1,6 @@
 # 环境
 #baseurl
-NEXT_PUBLIC_BASE_URL=https://api.bcwin777.com
+NEXT_PUBLIC_BASE_URL=http://192.168.0.84:8800
 #NEXT_PUBLIC_BASE_URL=http://192.168.0.67:8800
 #share link
 NEXT_PUBLIC_SHARE_URL=http://192.168.0.84:3000

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

@@ -1,7 +1,8 @@
 "use client";
-import { Link } from "@/i18n/routing";
+import { getWheelApi } from "@/api/cashWheel";
+import { useRouter } from "@/i18n/routing";
 import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
-import { Badge } from "antd-mobile";
+import { Badge, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import { FC } from "react";
 import "./style.scss";
@@ -17,7 +18,7 @@ export interface ItemComProps {
 
 const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
     const t = useTranslations("ProfilePage");
-
+    const router = useRouter();
     const { unread, userUnread } = useGlobalNoticeStore((state) => ({
         unread: state.unread,
         userUnread: state.userUnred,
@@ -61,12 +62,25 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
         },
         { label: "initial", desc: "", icon: "", url: "/", content: null },
     ];
+    const routerHandler = (item: any) => {
+        if (item.url === "/cashWheel") {
+            getWheelApi().then((res) => {
+                if (!Array.isArray(res.data) && !!res.data.activities) {
+                    router.push(item.url);
+                } else {
+                    Toast.show("The event is not open");
+                }
+            });
+        } else {
+            router.push(item.url);
+        }
+    };
     return (
         <div className="itemCom-box">
             {links.map((item, index) => (
-                <Link
+                <div
                     className={`${index == 0 ? "free" : ""} box-item`}
-                    href={item.url}
+                    onClick={() => routerHandler(item)}
                     key={index}
                 >
                     <div className={`${item.desc ? "box-item__left" : ""}`}>
@@ -85,7 +99,7 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
                     <div>
                         <span className="iconfont icon-xiangyou1"></span>
                     </div>
-                </Link>
+                </div>
             ))}
         </div>
     );