|
@@ -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>
|
|
|
);
|
|
|
};
|