"use client"; import { lredPacketApi, receiveRedPacketApi, redPacketApi } from "@/api/promo"; import { getToken } from "@/utils/Cookies"; import { Mask } from "antd-mobile"; import Image from "next/image"; import { forwardRef, Fragment, useEffect, useImperativeHandle, useRef, useState } from "react"; import styles from "./redpacked.module.scss"; const randomX = (len: number) => { return Math.floor(Math.random() * len); }; const mockData = Array(500) .fill(0) .map((item) => { return { phone: `55****${(randomX(99) + "").padEnd(2, "0")}`, num: `${(Math.random() * 20).toFixed(2)}`, time: "11:00", }; }); function getRandom(min: number, max: number) { const floatRandom = Math.random(); const difference = max - min; // 介于 0 和差值之间的随机数 const random = Math.round(difference * floatRandom); return random + min; } /** * @description 描述 */ type DescProps = { onClose: () => void; }; const Desc = (props: DescProps) => { const { onClose } = props; const [activeTab, setActiveTab] = useState(0); const tabs = [{ text: "Vezes de evento participado" }, { text: "Consulta de registo levado" }]; return (
{"close"}
{tabs.map((item, index) => { return ( setActiveTab(index)} className={`flex h-[100%] items-center ${index === activeTab ? "bg-[#8b3500] text-[#5f2600]" : ""}`} > {item.text} ); })}
{/* 动态内容 */}

Tempo regressivo

Começa amanhã às 11:00

{!activeTab ? ( <> {"time"} {"time"} ) : ( <>

Registro persoal

Nome do jogo Coleta cumulativa Participação total
55****26 R$ 100.00 1

Lista dos vencedores

ID do papel Valor obtido Hora obtida
{mockData.map((item, index) => { return (
{item.phone} R$ {item.num} {item.time}
); })}
)}
  • ·Cada sessão de chuva de dinheiro é distribuída gratuitamente por R$100.000.
  • ·Valor máximo de queda em dinheiro: Cada sessão de chuva de dinheiro é distribuída gratuitamente.
  • ·Membros recarregados podem reivindicar gratuitamente.
  • ·O dinheiro recebido pode ser utilizado para jogar ou sacar diretamente.
  • ·Quanto for maior o nível de associação VIP, será maior o valor recebido.
); }; const FallAnimation = (props: any) => { const { onClose } = props; const fallContentRef = useRef(null); const totalPackets = 200; const timer = useRef(null); const total = useRef(0); const createPacket = (xPoint: number) => { const packetWrapperEl = document.createElement("div"); packetWrapperEl.classList.add(styles.packetWrapper); packetWrapperEl.style.left = xPoint + "px"; packetWrapperEl.style.width = `77px`; packetWrapperEl.style.height = `44px`; packetWrapperEl.style.transform = `scale(0.8) `; const packetEl = document.createElement("img"); packetEl.classList.add(styles.packet); packetEl.style.width = `${getRandom(44, 77)}`; packetEl.style.height = `${getRandom(44, 77)}`; packetEl.src = `/9f/money${Math.floor(Math.random() * 3) + 1}.png`; setInterval(() => { packetEl.style.transform = `rotate(${getRandom(0, 180)}deg) translateX(${Math.random() > 0.5 ? getRandom(0, 180) : -getRandom(0, 180)}px) scale(${getRandom(0.4, 1.2)}) `; }, 1000); packetWrapperEl.appendChild(packetEl); fallContentRef.current?.appendChild(packetWrapperEl); }; useEffect(() => { // @ts-ignore timer.current = setInterval(() => { if (total.current >= totalPackets - 1) { clearInterval(Number(timer.current)); return; } total.current += 1; createPacket(Math.random() * fallContentRef.current?.clientWidth! || 500); }, 200); return () => { clearInterval(Number(timer.current)); }; }, []); return (
); }; const HbyInfoDetail = (props: any) => { const { iconImg, onCloseHby } = props; return (
{/* {"close"} */}
{"detail"} {/*
Dinheiro como chuva
R$200.00 por vez, Máx queda R$7.777
tips
Começa às 23:00
  • Cada sessão de chuva de dinheiro é distribuída gratuitamente com R$200.000
  • Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é distribuida gratuitamente com
  • Membros recarregados podem reivindicar gratuitamente
  • O dinheiro recebido pode ser utilizado para jogar ou sacado diretamente
  • Quanto maior o nivel de associacäo VP, maior o valor recebido
*/}
); }; const HbyInfo = (props: any) => { const { iconImg, onCloseHby, onReciveRed } = props; if (!iconImg) return; return (
{/* {"close"} */}
{"icon"} {/*
Chuva de dinheiro
  • Membros recarregados podem reivindicar gratuitamente.
  • Valor máximo de queda em dinheiro: R$7.777
AGARRAR
*/}
//
// {"close"} //
Chuva de dinheiro
//
1.96
//
Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é
//
); }; const HbyInfo2 = (props: any) => { const { iconImg, onCloseHby, redAmount } = props; console.log(`🚀🚀🚀🚀🚀-> in PopupHby.tsx on 364`, iconImg); return (
{"close"} {/*
*/} {"icon"}
{redAmount}
{/*
Chuva de dinheiro
{redAmount}
Valor máximo de queda em dinheiro:Cada sessäo de chuva de dinheiro é
*/}
); }; type Props = {}; export type RedPacketModalProps = { onClose: () => void; onOpen: (index?: number) => void; }; /** * @description 红包的三种状态 * is_start 可领取 展示红包领取组件 * is_receive 已领取 展示领取详情组件 * is_end 可展示 展示详情界面 */ enum Status { is_start, is_receive, is_end, } const RedPacketModal = forwardRef(function RedPacketModal(props, ref) { const [visible, setVisible] = useState(false); const [iconLists, setIconLists] = useState([]); const [isShowRed, setIsShowRed] = useState(false); const [isShowReciveRed, setIsShowReciveRed] = useState(false); const [isShowRedDetail, setIsShowRedDetail] = useState(false); const [redPacketInfo, setRedPacketInfo] = useState({}); const [redAmount, setRedAmount] = useState(0); const activeIndex = useRef(null); const token = getToken(); useImperativeHandle(ref, () => { return { onClose: () => setVisible(false), onOpen: (index?: number) => { if (index !== null && index !== undefined) { activeIndex.current = index; } getRedPacketInfo().then((res) => { setVisible(true); }); }, }; }); 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 packets = actList.filter((aItem: any) => { return !!aItem.is_start && !aItem.is_receive; }); let current = null; if (activeIndex.current !== null && activeIndex.current !== undefined) { current = packets[activeIndex.current]; } else { current = findCurrentActivity(packets); } let isShowRed = packets.length > 0; let isShowRedDetail = packets.length === 0; // // let redInfo = isShowRed ? isHasStartAct[0] : {}; // if (activeIndex.current !== undefined && activeIndex.current !== null) { // redInfo = isHasStartAct[activeIndex.current]; // } // let curAct = isShowRedDetail ? findCurrentActivity(actList) : actList[0]; let iconList = JSON.parse(current.icon); setIconLists(iconList); setRedPacketInfo(current); setIsShowRed(isShowRed); setIsShowRedDetail(isShowRedDetail); } catch (error) { console.log("redPacketInfo===>error:", error); } }; // 筛选出离当前时间最近的活动 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) ) { closestActivity = activity; } } // 如果不在任何活动范围内,返回离当前时间最近的活动 return closestActivity; }; 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); } }; return ( setVisible(false)} /> {isShowRedDetail && ( setVisible(false)} iconImg={iconLists[0]} /> )} {isShowRed && ( setVisible(false)} onReciveRed={onReciveRed} iconImg={iconLists[1]} /> )} {isShowReciveRed && ( setVisible(false)} redAmount={redAmount} iconImg={iconLists[2]} /> )} ); }); export default RedPacketModal;