Browse Source

fix: 增加币种类型

Before 8 months ago
parent
commit
536cbe6940

+ 3 - 1
src/api/user.ts

@@ -157,11 +157,13 @@ export interface Wallet {
     /**
      * 积分
      */
-    Score?: number;
+    score?: number;
     /**
      * 用户名
      */
     user_name?: string;
+    free_score?: number;
+    lose_score?: number;
 }
 // 前台用户获取金额信息
 export const getUserMoneyApi = () => {

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

@@ -45,6 +45,7 @@ const ServiceWidget: FC<Props> = (props) => {
                 redPacketInfo = await redPacketApi();
                 actList = redPacketInfo.data || [];
             }
+            console.log(`🚀🚀🚀🚀🚀-> in Service.tsx on 48`, actList);
 
             // 是否有已开始但是没领过的红包
             let isHasStartAct = actList.filter((aItem: any) => {

+ 5 - 4
src/app/[locale]/(TabBar)/profile/ProfileHeader.tsx

@@ -85,7 +85,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
                         <span>{t("Saldo")}</span>
                         <div className="num">
                             <span className="uppercase">brl </span>
-                            <span>{userMoney.Score || 0.0}</span>
+                            <span>{userMoney.score || 0.0}</span>
                         </div>
                     </div>
                     <div className={"wallet_right_content"}>
@@ -122,7 +122,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
                         </div>
                         <div className="num">
                             <span className="uppercase">brl </span>
-                            <span>{userMoney.point || 0.0}</span>
+                            <span>{userMoney.free_score || 0.0}</span>
                         </div>
                     </div>
                     <div className={"wallet_right_content"} onClick={() => walletHandler("replay")}>
@@ -142,7 +142,7 @@ const WalletCard = (props: { userMoney: Wallet }) => {
                         </div>
                         <div className="num">
                             <span className="uppercase">brl </span>
-                            <span>{userMoney.point || 0.0}</span>
+                            <span>{userMoney.lose_score || 0.0}</span>
                         </div>
                     </div>
                 </div>
@@ -155,8 +155,9 @@ export const ProfileHeader = (props: Props) => {
     const t = useTranslations("ProfilePage");
 
     const router = useRouter();
+
     const handler = () => {
-        if (!!userMoney.Score) {
+        if (!!userMoney.score) {
             router.push("/withdraw");
         } else {
             Toast.show("no monry");

+ 137 - 130
src/app/[locale]/(TabBar)/promo/PopupHby.tsx

@@ -1,18 +1,13 @@
 "use client";
 
+import { lredPacketApi, receiveRedPacketApi, redPacketApi } from "@/api/promo";
+import { getToken } from "@/utils/Cookies";
 import { Mask } from "antd-mobile";
 import clsx from "clsx";
 import Image from "next/image";
-import { redPacketApi, lredPacketApi,receiveRedPacketApi } from "@/api/promo";
 import { Fragment, useEffect, useRef, useState } from "react";
-import { getToken } from "@/utils/Cookies";
-import { getUserMoneyApi } from "@/api/user";
-import { useRequest } from "ahooks";
 import styles from "./style.module.scss";
 
-
-
-
 const randomX = (len: number) => {
     return Math.floor(Math.random() * len);
 };
@@ -226,8 +221,8 @@ const images = Array(10)
     .fill(0)
     .map(() => ({ src: `/9f/money${Math.floor(Math.random() * 3) + 1}.png` }));
 
-const FallAnimation = (props:any) => {
-    const {onClose} = props
+const FallAnimation = (props: any) => {
+    const { onClose } = props;
     const fallContentRef = useRef<HTMLDivElement>(null);
 
     const totalPackets = 200;
@@ -281,14 +276,16 @@ const FallAnimation = (props:any) => {
     );
 };
 
-const HbyInfoDetail = (props:any) => {
-  const { iconImg,onCloseHby } = props;
-  return ( 
-    <div className={`absolute left-1/2 top-[50%] -translate-x-1/2 -translate-y-1/2 w-[90%] ${styles.promoRules}`}>
-        {/* <Image src={"/hby/close.png"} alt={"close"} width={25} height={25} onClick={onCloseHby} className={styles.closeIcon}/> */}
-        <div onClick={onCloseHby} className={styles.closeIcon}></div>
-        <Image src={iconImg} alt={'detail'} width={672} height={1044} />
-      {/* <div className={`h-[0.15rem] text-[#ffd800] text-[0.20rem] text-center ${styles.promoTitle}`}>Dinheiro como chuva</div>
+const HbyInfoDetail = (props: any) => {
+    const { iconImg, onCloseHby } = props;
+    return (
+        <div
+            className={`absolute left-1/2 top-[50%] w-[90%] -translate-x-1/2 -translate-y-1/2 ${styles.promoRules}`}
+        >
+            {/* <Image src={"/hby/close.png"} alt={"close"} width={25} height={25} onClick={onCloseHby} className={styles.closeIcon}/> */}
+            <div onClick={onCloseHby} className={styles.closeIcon}></div>
+            <Image src={iconImg} alt={"detail"} width={672} height={1044} />
+            {/* <div className={`h-[0.15rem] text-[#ffd800] text-[0.20rem] text-center ${styles.promoTitle}`}>Dinheiro como chuva</div>
       <div className={styles.titleWrap}>
           <span>R$200.00</span>
           <span> por vez, </span>
@@ -322,18 +319,28 @@ const HbyInfoDetail = (props:any) => {
           Quanto maior o nivel de associacäo VP, maior o valor recebido
         </li>
       </ul> */}
-    </div>
-  )
-}
+        </div>
+    );
+};
 
-const HbyInfo = (props:any)=>{
-  const { iconImg,onCloseHby,onReciveRed } = props;
-  return (
-    <div className={`absolute left-1/2 top-[50%] -translate-x-1/2 -translate-y-1/2 ${styles.redclose}`}>
-      {/* <Image src={"/hby/close.png"} alt={"close"} width={20} height={20} onClick={onCloseHby} className={styles.closeIcon}/> */}
-      <div onClick={onCloseHby} className={styles.closeIcon}></div>
-      <Image src={iconImg} alt={"icon"} width={559} height={687} onClick={onReciveRed} className={styles.redIcon}/>
-      {/* <div className={styles.title}>Chuva de dinheiro</div>
+const HbyInfo = (props: any) => {
+    const { iconImg, onCloseHby, onReciveRed } = props;
+    if (!iconImg) return;
+    return (
+        <div
+            className={`absolute left-1/2 top-[50%] -translate-x-1/2 -translate-y-1/2 ${styles.redclose}`}
+        >
+            {/* <Image src={"/hby/close.png"} alt={"close"} width={20} height={20} onClick={onCloseHby} className={styles.closeIcon}/> */}
+            <div onClick={onCloseHby} className={styles.closeIcon}></div>
+            <img
+                src={iconImg}
+                alt={"icon"}
+                width={559}
+                height={687}
+                onClick={onReciveRed}
+                className={styles.redIcon}
+            />
+            {/* <div className={styles.title}>Chuva de dinheiro</div>
       <div className={styles.desc}>
         <ul className={styles.desclist}>
           <li className={styles.descitem}>  Membros recarregados podem reivindicar gratuitamente. </li>
@@ -342,143 +349,143 @@ const HbyInfo = (props:any)=>{
         </ul>
       </div>
       <div className={styles.openBtn} onClick={onReciveRed}>AGARRAR</div> */}
-    </div>
-    // <div data-v-f333135e="" className={`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${styles.redopen}`}>
-    //   <Image src={"/hby/close.png"} alt={"close"} width={20} height={20} onClick={onCloseHby} className={styles.closeIcon}/>
-    //   <div className={styles.title}>Chuva de dinheiro</div>
-    //   <div className={styles.cash}>1.96</div>
-    //   <div className={styles.tips}>Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é </div>
-    // </div>
-  )
-}
+        </div>
+        // <div data-v-f333135e="" className={`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${styles.redopen}`}>
+        //   <Image src={"/hby/close.png"} alt={"close"} width={20} height={20} onClick={onCloseHby} className={styles.closeIcon}/>
+        //   <div className={styles.title}>Chuva de dinheiro</div>
+        //   <div className={styles.cash}>1.96</div>
+        //   <div className={styles.tips}>Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é </div>
+        // </div>
+    );
+};
 
-const HbyInfo2 = (props:any)=>{
-  const { iconImg,onCloseHby,redAmount } = props;
-  return (
-    <div className={`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${styles.redopen}`}>
-      <Image src={"/hby/close.png"} alt={"close"} width={30} height={30} onClick={onCloseHby} className={styles.closeIcon}/>
-      {/* <div onClick={onCloseHby} className={styles.closeIcon}></div> */}
-      <Image src={iconImg} alt={"icon"} width={559} height={687}/>
-      <div className={styles.cash}>{redAmount}</div>
-      {/* <div className={styles.title}>Chuva de dinheiro</div>
+const HbyInfo2 = (props: any) => {
+    const { iconImg, onCloseHby, redAmount } = props;
+    console.log(`🚀🚀🚀🚀🚀-> in PopupHby.tsx on 364`, iconImg);
+    return (
+        <div
+            className={`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${styles.redopen}`}
+        >
+            <Image
+                src={"/hby/close.png"}
+                alt={"close"}
+                width={30}
+                height={30}
+                onClick={onCloseHby}
+                className={styles.closeIcon}
+            />
+            {/* <div onClick={onCloseHby} className={styles.closeIcon}></div> */}
+            <Image src={iconImg} alt={"icon"} width={559} height={687} />
+            <div className={styles.cash}>{redAmount}</div>
+            {/* <div className={styles.title}>Chuva de dinheiro</div>
       <div className={styles.cash}>{redAmount}</div>
       <div className={styles.tips}>Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é </div> */}
-    </div>
-  )
-}
-
-
-
-
+        </div>
+    );
+};
 
-const Popup = ( props:any) => {
+const Popup = (props: any) => {
     const { onClose } = props;
     const [maskVisible, setMaskVisible] = useState(true);
 
-    const [iconLists,setIconLists] = useState<any>([])
-    const [isShowRed,setIsShowRed] = useState(false)
-    const [isShowReciveRed,setIsShowReciveRed] = useState(false)
-    const [isShowRedDetail,setIsShowRedDetail] = useState(false)
-    const [redPacketInfo,setRedPacketInfo] = useState<any>({})
-    const [redAmount,setRedAmount] = useState<any>(0)
+    const [iconLists, setIconLists] = useState<any>([]);
+    const [isShowRed, setIsShowRed] = useState(false);
+    const [isShowReciveRed, setIsShowReciveRed] = useState(false);
+    const [isShowRedDetail, setIsShowRedDetail] = useState(false);
+    const [redPacketInfo, setRedPacketInfo] = useState<any>({});
+    const [redAmount, setRedAmount] = useState<any>(0);
     const token = getToken();
 
     useEffect(() => {
-      getRedPacketInfo()
-    },[])
-
-    const getRedPacketInfo =async()=>{
-      try{  
-        let actList:any=[]
-        if(token){
-          let redPacketInfo =await lredPacketApi()
-          actList = redPacketInfo.data?.red_packets || []
-        }else{
-          let redPacketInfo =await redPacketApi()
-          actList = redPacketInfo.data
-        }
-        // 是否有已开始但是没领过的红包
-        let isHasStartAct = actList.filter((aItem:any)=>{
-          return !!aItem.is_start && !aItem.is_receive
-        })
-
-        let isShowRed = isHasStartAct.length>0
-        let isShowRedDetail = isHasStartAct.length === 0
-        let redInfo = isShowRed ? isHasStartAct[0] : {}
-        let curAct = !!isShowRedDetail ? findCurrentActivity(actList) : actList[0]
-        let iconList = JSON.parse(curAct.icon)
-        
-        setIconLists(iconList)
-        setIsShowRed(isShowRed)
-        setIsShowRedDetail(isShowRedDetail)
-        setRedPacketInfo(redInfo)
-       
-      }catch(error){
-        console.log('redPacketInfo===>error:',error)
-      }
-     
-    } 
+        getRedPacketInfo();
+    }, []);
 
+    const getRedPacketInfo = async () => {
+        try {
+            let actList: any = [];
+            if (token) {
+                let redPacketInfo = await lredPacketApi();
+                actList = redPacketInfo.data?.red_packets || [];
+            } else {
+                let redPacketInfo = await redPacketApi();
+                actList = redPacketInfo.data;
+            }
+            // 是否有已开始但是没领过的红包
+            let isHasStartAct = actList.filter((aItem: any) => {
+                return !!aItem.is_start && !aItem.is_receive;
+            });
+
+            let isShowRed = isHasStartAct.length > 0;
+            let isShowRedDetail = isHasStartAct.length === 0;
+            let redInfo = isShowRed ? isHasStartAct[0] : {};
+            let curAct = !!isShowRedDetail ? findCurrentActivity(actList) : actList[0];
+            let iconList = JSON.parse(curAct.icon);
+
+            setIconLists(iconList);
+            setIsShowRed(isShowRed);
+            setIsShowRedDetail(isShowRedDetail);
+            setRedPacketInfo(redInfo);
+        } catch (error) {
+            console.log("redPacketInfo===>error:", error);
+        }
+    };
 
     // 筛选出离当前时间最近的活动
-    const findCurrentActivity=(activities:any)=> {
+    const findCurrentActivity = (activities: any) => {
         const now = Math.floor(Date.now() / 1000); // 获取当前时间的时间戳(单位:秒)
         let closestActivity = null;
         let isInRange = false;
-        
+
         // 遍历活动数据
         for (let i = 0; i < activities.length; i++) {
             const activity = activities[i];
-            
+
             // 检查当前时间是否在活动的时间范围内
             if (now >= activity.start_time && now <= activity.end_time) {
                 isInRange = true;
                 return activity; // 如果在范围内,直接返回当前活动
             }
-    
+
             // 如果不在范围内,记录离当前时间最近的活动
-            if (!closestActivity || 
-                Math.abs(now - activity.end_time) < Math.abs(now - closestActivity.end_time)) {
+            if (
+                !closestActivity ||
+                Math.abs(now - activity.end_time) < Math.abs(now - closestActivity.end_time)
+            ) {
                 closestActivity = activity;
             }
         }
-        
+
         // 如果不在任何活动范围内,返回离当前时间最近的活动
         return closestActivity;
-    }
-  
-
-
+    };
 
-    const onReciveRed = async()=>{
-      try{  
-        
-        let paramsData={
-          id:redPacketInfo?.id,
-          index:redPacketInfo?.index
+    const onReciveRed = async () => {
+        try {
+            let paramsData = {
+                id: redPacketInfo?.id,
+                index: redPacketInfo?.index,
+            };
+            let receiveRedPacketInfo = await receiveRedPacketApi(paramsData);
+            let redNum = receiveRedPacketInfo.data;
+            setIsShowRed(false);
+            setIsShowReciveRed(true);
+            setRedAmount(redNum?.amount);
+        } catch (error) {
+            console.log("redPacketInfo===>error:", error);
         }
-        let receiveRedPacketInfo = await receiveRedPacketApi(paramsData)
-        let redNum = receiveRedPacketInfo.data
-        setIsShowRed(false)
-        setIsShowReciveRed(true)
-        setRedAmount(redNum?.amount)
-      }catch(error){
-        console.log('redPacketInfo===>error:',error)
-      }
-    }
-
-
-
+    };
 
     return (
         <Mask>
-          <FallAnimation onClose={onClose} />
-          {/* <Desc onClose={() => setMaskVisible(false)} /> */}
-          {/* <ReceivePackage /> */}
-
-          {!!isShowRed && <HbyInfo onCloseHby={onClose} onReciveRed={onReciveRed} iconImg={iconLists[1]}/>}
-          {!!isShowReciveRed && <HbyInfo2 onCloseHby={onClose}  redAmount={redAmount} iconImg={iconLists[2]}/>}
-          {!!isShowRedDetail && <HbyInfoDetail onCloseHby={onClose} iconImg={iconLists[0]}/>}
+            <FallAnimation onClose={onClose} />
+
+            {!!isShowRed && (
+                <HbyInfo onCloseHby={onClose} onReciveRed={onReciveRed} iconImg={iconLists[1]} />
+            )}
+            {!!isShowReciveRed && (
+                <HbyInfo2 onCloseHby={onClose} redAmount={redAmount} iconImg={iconLists[2]} />
+            )}
+            {!!isShowRedDetail && <HbyInfoDetail onCloseHby={onClose} iconImg={iconLists[0]} />}
         </Mask>
     );
 };

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

@@ -3,7 +3,6 @@ import Empty from "@/components/Empty";
 import { server } from "@/utils/server";
 
 import Box from "@/components/Box";
-import Popup from "./Popup";
 const getPromotionApi = async () => {
     return server
         .request<BannerRep[]>({
@@ -31,7 +30,7 @@ const Promo = async () => {
                     />
                 </Box>
             ))}
-            <Popup />
+            {/*<Popup />*/}
         </>
     );
 };

+ 14 - 4
src/components/Box/index.tsx

@@ -38,6 +38,12 @@ const openWindow = (url: string) => {
         Toast.show("非法地址");
     }
 };
+/**
+ * @description 弹窗类型
+ */
+enum ModalEnum {
+    red_packet = "red_packet",
+}
 const Box: FC<PropsWithChildren<Props>> = (props) => {
     const router = useRouter();
     const {
@@ -76,7 +82,9 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
                 router.push(actionData as string);
                 break;
             case 4:
-                console.log(`🎯🎯🎯🎯🎯-> in index.tsx on 59`);
+                if (actionData === ModalEnum.red_packet) {
+                    console.log(`🎯🎯🎯🎯🎯-> in index.tsx on 59`, actionData);
+                }
                 break;
             case 5:
                 break;
@@ -92,9 +100,11 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
         }
     };
     return (
-        <Tag className={twMerge(cls)} style={style} onClick={handler}>
-            {children}
-        </Tag>
+        <>
+            <Tag className={twMerge(cls)} style={style} onClick={handler}>
+                {children}
+            </Tag>
+        </>
     );
 };
 

+ 2 - 2
src/components/Header/HeaderRight.tsx

@@ -28,8 +28,8 @@ const HeaderRight = () => {
         refreshDeps: [token],
         onError: (error) => {},
         onSuccess: (res) => {
-            if (res.data.Score) {
-                setScore(res.data.Score);
+            if (res.data.score) {
+                setScore(res.data.score);
             }
         },
     });

+ 2 - 2
src/stores/useWalletStore.ts

@@ -3,12 +3,12 @@ import { create } from "zustand";
 
 interface State {
     wallet: Wallet;
-    score: Wallet["Score"];
+    score: Wallet["score"];
 }
 
 interface Action {
     setWallet: (state: Wallet) => void;
-    setScore: (state: Wallet["Score"]) => void;
+    setScore: (state: Wallet["score"]) => void;
     reset: () => void;
 }
 const initialState: State = {