|
@@ -1,18 +1,29 @@
|
|
|
"use client";
|
|
|
|
|
|
-import { getWheelApi, getWheelReceiveApi, WheelsType } from "@/api/cashWheel";
|
|
|
+import { getWheelReceiveApi } from "@/api/cashWheel";
|
|
|
import Box from "@/components/Box";
|
|
|
import { WheelClient } from "@/components/Box/WheelModal";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
+import useWheelStore from "@/stores/useWheelStore";
|
|
|
import { server } from "@/utils/client";
|
|
|
import { copyText, timeFormat } from "@/utils/methods";
|
|
|
import NumberFlow from "@number-flow/react";
|
|
|
-import { useCountDown } from "ahooks";
|
|
|
+import { useCountDown, useRequest } from "ahooks";
|
|
|
import { Popup, Toast } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import Image from "next/image";
|
|
|
-import { createContext, FC, Fragment, useContext, useEffect, useState } from "react";
|
|
|
+import {
|
|
|
+ createContext,
|
|
|
+ FC,
|
|
|
+ forwardRef,
|
|
|
+ Fragment,
|
|
|
+ useContext,
|
|
|
+ useEffect,
|
|
|
+ useImperativeHandle,
|
|
|
+ useRef,
|
|
|
+ useState,
|
|
|
+} from "react";
|
|
|
import LotteryWheel from "./LotteryWheel";
|
|
|
import styles from "./style.module.scss";
|
|
|
interface Props {
|
|
@@ -20,8 +31,9 @@ interface Props {
|
|
|
allHistory: any[];
|
|
|
phones: any[];
|
|
|
}
|
|
|
-interface ContextType extends WheelsType, Props {
|
|
|
- handler: () => void;
|
|
|
+interface ContextType extends Props {
|
|
|
+ cancelHandler: () => void;
|
|
|
+ startHandler: () => void;
|
|
|
}
|
|
|
const WheelContext = createContext<Partial<ContextType>>({});
|
|
|
|
|
@@ -222,7 +234,7 @@ const Report = () => {
|
|
|
<ul className={styles.tipsContent}>
|
|
|
<li>1.Você pode iniciar um saque quando o valor acumulado atingir 100 BRL. </li>
|
|
|
<li>
|
|
|
- 2.Convidar amigos para se registrarem no 9f.com irá ajudá- lo a sacar
|
|
|
+ 2.Convidar amigos para se registrarem no BCWIN777.com irá ajudá- lo a sacar
|
|
|
dinheiro rapidamente.
|
|
|
</li>
|
|
|
<li>3. Cada usuário receberá uma única rodada grátis por dia. </li>
|
|
@@ -242,7 +254,17 @@ const Report = () => {
|
|
|
};
|
|
|
const WheelWallet = () => {
|
|
|
const user = useUserInfoStore((state) => state.userInfo);
|
|
|
- const wheel = useContext(WheelContext);
|
|
|
+ const { statusWheel, currentWheel, setWheel, totalCount } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ totalCount: state.totalCount,
|
|
|
+ }));
|
|
|
+ const [count, setCount] = useState<number>(0);
|
|
|
+ useEffect(() => {
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 252`, currentWheel);
|
|
|
+ setCount(currentWheel.amount || 0);
|
|
|
+ }, [currentWheel.amount]);
|
|
|
return (
|
|
|
<Box className={"w-[100%]"}>
|
|
|
<div
|
|
@@ -259,11 +281,7 @@ const WheelWallet = () => {
|
|
|
<span>{user.user_phone}</span>
|
|
|
</div>
|
|
|
<div className={"text-[0.4861rem] font-bold text-[#008213]"}>
|
|
|
- <NumberFlow
|
|
|
- value={wheel.activate?.amount! || 0}
|
|
|
- prefix={"R$ "}
|
|
|
- trend={+1}
|
|
|
- />
|
|
|
+ <NumberFlow value={count} prefix={"R$ "} trend={+1} />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div
|
|
@@ -273,11 +291,7 @@ const WheelWallet = () => {
|
|
|
>
|
|
|
<span className={"mr-[10px] text-[#008213]"}>Faltam para O saque</span>
|
|
|
<span className={"text-[#eef100]"}>
|
|
|
- <NumberFlow
|
|
|
- value={wheel.num! - wheel.activate?.amount! || 0}
|
|
|
- prefix={"R$ "}
|
|
|
- trend={-1}
|
|
|
- />
|
|
|
+ <NumberFlow value={totalCount - count} prefix={"R$ "} trend={-1} />
|
|
|
</span>
|
|
|
</div>
|
|
|
{/*top*/}
|
|
@@ -288,32 +302,55 @@ const WheelWallet = () => {
|
|
|
|
|
|
const DrawMain = () => {
|
|
|
const wheel = useContext(WheelContext);
|
|
|
-
|
|
|
+ const { statusWheel, currentWheel, receiveTarget, setWheel } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ receiveTarget: state.receiveTarget,
|
|
|
+ }));
|
|
|
+ const shareRef = useRef<{ open: () => void } | null>(null);
|
|
|
return (
|
|
|
- <div className={""}>
|
|
|
+ <>
|
|
|
<WheelWallet />
|
|
|
|
|
|
<div className={"-mt-[0.2083rem]"}>
|
|
|
- <WheelClient isRotate={true} wheel={wheel} onRotateEnd={wheel.handler!} />
|
|
|
+ <WheelClient
|
|
|
+ isRotate={true}
|
|
|
+ onRotateEnd={wheel.startHandler}
|
|
|
+ onRotateDisable={() => shareRef.current?.open()}
|
|
|
+ onRotateBefore={wheel.cancelHandler}
|
|
|
+ />
|
|
|
</div>
|
|
|
- </div>
|
|
|
+
|
|
|
+ {/*倒计时*/}
|
|
|
+ <CountdownClient />
|
|
|
+ {/*分享*/}
|
|
|
+ {currentWheel.end_time && currentWheel.end_time > 0 ? (
|
|
|
+ <ShareClient ref={shareRef} />
|
|
|
+ ) : null}
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
const CountdownClient = () => {
|
|
|
const wheel = useContext(WheelContext);
|
|
|
-
|
|
|
+ const { setWheel, currentWheel, receiveTarget } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ receiveTarget: state.receiveTarget,
|
|
|
+ }));
|
|
|
const [_, formattedRes] = useCountDown({
|
|
|
- leftTime: wheel.activate?.end_time! * 1000 - Date.now(),
|
|
|
+ leftTime: currentWheel.end_time ? currentWheel.end_time * 1000 - Date.now() : 0,
|
|
|
});
|
|
|
const { days, hours, minutes, seconds } = formattedRes;
|
|
|
const receiveHandler = () => {
|
|
|
- getWheelReceiveApi({ unique_id: wheel.not_receive![0].unique_id }).then((res) => {
|
|
|
- wheel.handler && wheel.handler();
|
|
|
+ getWheelReceiveApi({ unique_id: receiveTarget.unique_id! }).then((res) => {
|
|
|
+ setWheel();
|
|
|
});
|
|
|
};
|
|
|
return (
|
|
|
<div className={"relative flex justify-center"}>
|
|
|
- {wheel.not_receive && wheel.not_receive.length > 0 ? (
|
|
|
+ {receiveTarget.unique_id ? (
|
|
|
<div className={"mt-[10px]"}>
|
|
|
<Image
|
|
|
src={"/wheels/receive-button.png"}
|
|
@@ -343,15 +380,26 @@ const phones = Array(9)
|
|
|
.padStart(4, "0")}`;
|
|
|
return num;
|
|
|
});
|
|
|
-const ShareClient = () => {
|
|
|
+const ShareClient = forwardRef<{ open: () => void }, {}>(function ShareClient(props, ref) {
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const wheel = useContext(WheelContext);
|
|
|
const user = useUserInfoStore((state) => state.userInfo);
|
|
|
- const currentWheel = wheel.activities?.[0];
|
|
|
+ const { statusWheel, currentWheel, receiveTarget } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ receiveTarget: state.receiveTarget,
|
|
|
+ }));
|
|
|
+
|
|
|
+ useImperativeHandle(ref, () => {
|
|
|
+ return {
|
|
|
+ open: () => setVisible(true),
|
|
|
+ };
|
|
|
+ });
|
|
|
|
|
|
const [currentPhoneIndex, setCurrentPhoneIndex] = useState(0);
|
|
|
|
|
|
- const shareUrl = `${process.env.NEXT_PUBLIC_SHARE_URL}/br/sharecwbr?turntable=${wheel.activities && wheel.activities[0].id}&user=${user.id}&time=${wheel.activate?.end_time}`;
|
|
|
+ const shareUrl = `${process.env.NEXT_PUBLIC_SHARE_URL}/br/sharecwbr?turntable=${currentWheel.id}&user=${user.id}&time=${currentWheel.end_time}`;
|
|
|
const url = encodeURIComponent(`${shareUrl}`);
|
|
|
const text = encodeURIComponent(`Receba 100 BRL de graça,Pix SAQUE RÁPIDO`);
|
|
|
const t = useTranslations();
|
|
@@ -394,7 +442,7 @@ const ShareClient = () => {
|
|
|
};
|
|
|
|
|
|
const smsHandler = () => {
|
|
|
- const phoneNumber = `sms:${wheel.phones?.join(",")}?body=${currentWheel?.note + url}`;
|
|
|
+ const phoneNumber = `sms:${wheel.phones?.join(",")}?body=${currentWheel.note + url}`;
|
|
|
window.location.href = phoneNumber;
|
|
|
};
|
|
|
|
|
@@ -481,105 +529,105 @@ const ShareClient = () => {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div className={"mt-[0.0694rem]"}>
|
|
|
- <h1>2.Enviar convite para jogador aleatório ajudar</h1>
|
|
|
+ {currentWheel.share_phone_enable === 1 ? (
|
|
|
+ <div className={"mt-[0.0694rem]"}>
|
|
|
+ <h1>2.Enviar convite para jogador aleatório ajudar</h1>
|
|
|
|
|
|
- <div className={"mt-[0.0694rem] bg-[#000] p-[10px]"}>
|
|
|
- <div className={"grid grid-cols-3 gap-[5px] text-[0.0833rem]"}>
|
|
|
- {wheel.phones?.map((phone, index) => {
|
|
|
- return (
|
|
|
- <span
|
|
|
- style={{
|
|
|
- color: index < currentPhoneIndex ? "#fff" : "#ccc",
|
|
|
- }}
|
|
|
- key={index}
|
|
|
- >
|
|
|
- {phone}
|
|
|
- </span>
|
|
|
- );
|
|
|
- })}
|
|
|
- </div>
|
|
|
+ <div className={"mt-[0.0694rem] bg-[#000] p-[10px]"}>
|
|
|
+ <div className={"grid grid-cols-3 gap-[5px] text-[0.0833rem]"}>
|
|
|
+ {wheel.phones?.map((phone, index) => {
|
|
|
+ return (
|
|
|
+ <span
|
|
|
+ style={{
|
|
|
+ color:
|
|
|
+ index < currentPhoneIndex ? "#fff" : "#ccc",
|
|
|
+ }}
|
|
|
+ key={index}
|
|
|
+ >
|
|
|
+ {phone}
|
|
|
+ </span>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
|
|
|
- <div
|
|
|
- className={
|
|
|
- "grid grid-cols-2 gap-[0.1389rem] text-[0.12rem] text-[#fff]"
|
|
|
- }
|
|
|
- >
|
|
|
<div
|
|
|
- onClick={handler}
|
|
|
className={
|
|
|
- "flex items-center rounded-[0.0694rem] bg-[#10cb8c]" +
|
|
|
- " p-[0.0694rem] text-[#fff]"
|
|
|
+ "grid grid-cols-2 gap-[0.1389rem] text-[0.12rem] text-[#fff]"
|
|
|
}
|
|
|
>
|
|
|
- <div className={"flex-1"}>
|
|
|
- <p>Enviar Mensagem </p>
|
|
|
- <p>no WhatsAPP</p>
|
|
|
+ <div
|
|
|
+ onClick={handler}
|
|
|
+ className={
|
|
|
+ "flex items-center rounded-[0.0694rem] bg-[#10cb8c]" +
|
|
|
+ " p-[0.0694rem] text-[#fff]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div className={"flex-1"}>
|
|
|
+ <p>Enviar Mensagem </p>
|
|
|
+ <p>no WhatsAPP</p>
|
|
|
+ </div>
|
|
|
+ <Image
|
|
|
+ src={"/summary/WhatsApp-nobg.png"}
|
|
|
+ alt={"whatsApp"}
|
|
|
+ width={40}
|
|
|
+ height={40}
|
|
|
+ />
|
|
|
</div>
|
|
|
- <Image
|
|
|
- src={"/summary/WhatsApp-nobg.png"}
|
|
|
- alt={"whatsApp"}
|
|
|
- width={40}
|
|
|
- height={40}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div
|
|
|
- onClick={smsHandler}
|
|
|
- className={
|
|
|
- "flex items-center rounded-[10px] bg-[#35b2fe]" +
|
|
|
- " p-[0.0694rem] text-[#fff]"
|
|
|
- }
|
|
|
- >
|
|
|
- <div className={"flex-1"}>
|
|
|
- <p>Enviar Mensagem </p>
|
|
|
- <p>SMS</p>
|
|
|
+ <div
|
|
|
+ onClick={smsHandler}
|
|
|
+ className={
|
|
|
+ "flex items-center rounded-[10px] bg-[#35b2fe]" +
|
|
|
+ " p-[0.0694rem] text-[#fff]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div className={"flex-1"}>
|
|
|
+ <p>Enviar Mensagem </p>
|
|
|
+ <p>SMS</p>
|
|
|
+ </div>
|
|
|
+ <Image
|
|
|
+ src={"/summary/SMS.png"}
|
|
|
+ alt={"whatsApp"}
|
|
|
+ width={40}
|
|
|
+ height={40}
|
|
|
+ />
|
|
|
</div>
|
|
|
- <Image
|
|
|
- src={"/summary/SMS.png"}
|
|
|
- alt={"whatsApp"}
|
|
|
- width={40}
|
|
|
- height={40}
|
|
|
- />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
</Popup>
|
|
|
</>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
|
|
|
const CashWheelClient: FC<Props> = (props) => {
|
|
|
- const getWheelData = async () => {
|
|
|
- return getWheelApi().then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- setValues((staticValue) => {
|
|
|
- return { ...staticValue, ...res.data };
|
|
|
- });
|
|
|
- }
|
|
|
- return res;
|
|
|
- });
|
|
|
- };
|
|
|
+ const { statusWheel, currentWheel, receiveTarget, setWheel } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ receiveTarget: state.receiveTarget,
|
|
|
+ }));
|
|
|
|
|
|
- const [values, setValues] = useState<Partial<ContextType>>({
|
|
|
- num: 100,
|
|
|
- allHistory: props.allHistory || [],
|
|
|
- phones: props.phones || [],
|
|
|
- handler: getWheelData,
|
|
|
+ const { run, cancel } = useRequest<any, any>(setWheel, {
|
|
|
+ pollingInterval: 5000,
|
|
|
+ pollingErrorRetryCount: 1,
|
|
|
+ pollingWhenHidden: false,
|
|
|
});
|
|
|
- useEffect(() => {
|
|
|
- getWheelData();
|
|
|
- }, []);
|
|
|
+ useEffect(() => {}, []);
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
- <WheelContext.Provider value={values}>
|
|
|
+ <WheelContext.Provider
|
|
|
+ value={{
|
|
|
+ allHistory: props.allHistory || [],
|
|
|
+ phones: props.phones || [],
|
|
|
+ cancelHandler: cancel,
|
|
|
+ startHandler: run,
|
|
|
+ }}
|
|
|
+ >
|
|
|
<DrawMain />
|
|
|
- {/*倒计时*/}
|
|
|
- <CountdownClient />
|
|
|
- {/*分享*/}
|
|
|
- {values.activate && values.activate?.end_time > 0 ? <ShareClient /> : null}
|
|
|
+
|
|
|
<div className={styles.cashWheelClient}>
|
|
|
{/*<CashMainCom />*/}
|
|
|
{/*<DrawContent />*/}
|