|
@@ -1,23 +1,28 @@
|
|
|
"use client";
|
|
|
|
|
|
-import { WheelsType } from "@/api/cashWheel";
|
|
|
+import { getWheelApi, getWheelRunApi, WheelsType } from "@/api/cashWheel";
|
|
|
import Box from "@/components/Box";
|
|
|
import { Link } from "@/i18n/routing";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
-import { copyText } from "@/utils/methods";
|
|
|
+import { copyText, timeFormat } from "@/utils/methods";
|
|
|
import { LuckyWheel } from "@lucky-canvas/react";
|
|
|
import { useCountDown } 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, useContext, useRef, useState } from "react";
|
|
|
+import { createContext, FC, useContext, useEffect, useRef, useState } from "react";
|
|
|
import LotteryWheel from "./LotteryWheel";
|
|
|
import styles from "./style.module.scss";
|
|
|
interface Props {
|
|
|
- wheel: WheelsType;
|
|
|
+ // wheel: WheelsType;
|
|
|
+ allHistory: any[];
|
|
|
}
|
|
|
-const WheelContext = createContext<Partial<WheelsType>>({});
|
|
|
+interface ContextType extends WheelsType {
|
|
|
+ allHistory: any[];
|
|
|
+ handler: () => void;
|
|
|
+}
|
|
|
+const WheelContext = createContext<Partial<ContextType>>({});
|
|
|
|
|
|
const CashMainCom = () => {
|
|
|
return (
|
|
@@ -84,24 +89,29 @@ const DrawContent = () => {
|
|
|
};
|
|
|
type Dtltype = "left" | "right";
|
|
|
const LeftListClient = () => {
|
|
|
- const winListData = Array(500).fill("1");
|
|
|
+ const wheel = useContext(WheelContext);
|
|
|
return (
|
|
|
<>
|
|
|
- {winListData.length > 0 &&
|
|
|
- winListData.map((item, index) => {
|
|
|
- return (
|
|
|
- <div className={styles.item} key={index}>
|
|
|
- <span className={`${styles.name} ${styles.omitWrap}`}>
|
|
|
- 5533******412
|
|
|
- </span>
|
|
|
- <span className={styles.tipText}> Acabou de saca </span>
|
|
|
- <div className={styles.value}>
|
|
|
- <span className={styles.addCash}>+100</span>
|
|
|
- <span className={styles.unit}> R$</span>
|
|
|
+ <div className={`${styles.winList} ${styles.swipernoswiping} ${styles.type2}`}>
|
|
|
+ {wheel.allHistory &&
|
|
|
+ wheel.allHistory.length > 0 &&
|
|
|
+ wheel.allHistory?.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <div className={styles.item} key={index}>
|
|
|
+ <span className={`${styles.name} ${styles.omitWrap}`}>
|
|
|
+ 55****{(Math.random() * 10000).toFixed(0)}
|
|
|
+ </span>
|
|
|
+ <span className={styles.tipText}>
|
|
|
+ {timeFormat(item.receive_time, "br", undefined, true)}
|
|
|
+ </span>
|
|
|
+ <div className={styles.value}>
|
|
|
+ <span className={styles.addCash}>+100</span>
|
|
|
+ <span className={styles.unit}> R$</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- );
|
|
|
- })}
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
</>
|
|
|
);
|
|
|
};
|
|
@@ -142,11 +152,7 @@ const Report = () => {
|
|
|
<div className={styles.vanTabsContent}>
|
|
|
<div className={styles.vantabpane}>
|
|
|
<div className={styles.tabContent}>
|
|
|
- <div
|
|
|
- className={`${styles.winList} ${styles.swipernoswiping} ${styles.type2}`}
|
|
|
- >
|
|
|
- {activeTab === "left" ? <LeftListClient /> : null}
|
|
|
- </div>
|
|
|
+ {activeTab === "left" ? <LeftListClient /> : null}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -198,7 +204,7 @@ const WheelWallet = () => {
|
|
|
<div className={"mt-[0.2083rem] w-[100%] text-center text-[18px]"}>
|
|
|
<span className={"mr-[10px] text-[#008213]"}>Faltam para O saque</span>
|
|
|
<span className={"text-[yellow]"}>
|
|
|
- R${wheel.num! - wheel.activate?.amount! || 0}
|
|
|
+ R${(wheel.num! - wheel.activate?.amount! || 0).toFixed(2)}
|
|
|
</span>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -267,8 +273,7 @@ const DrawMain = () => {
|
|
|
const myLucky = useRef<any>();
|
|
|
const desktopWheelRef = useRef<any>();
|
|
|
const wheel = useContext(WheelContext);
|
|
|
- console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 213`, wheel);
|
|
|
- const [count, setCount] = useState(0);
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 275`, wheel);
|
|
|
|
|
|
const [buttons, setButtons] = useState([
|
|
|
{
|
|
@@ -282,7 +287,7 @@ const DrawMain = () => {
|
|
|
],
|
|
|
fonts: [
|
|
|
{
|
|
|
- text: count,
|
|
|
+ text: wheel.activate?.can! ? 1 : 0,
|
|
|
top: -5,
|
|
|
fontColor: "#ffdb0e",
|
|
|
fontSize: "22px",
|
|
@@ -294,18 +299,32 @@ const DrawMain = () => {
|
|
|
offsetDegree: 20,
|
|
|
});
|
|
|
|
|
|
+ const currentIndex = useRef<undefined | number>(undefined);
|
|
|
+
|
|
|
const startRotate = () => {
|
|
|
// 点击抽奖按钮会触发star回调
|
|
|
myLucky.current?.play();
|
|
|
- setTimeout(() => {
|
|
|
- const index = (Math.random() * 6) >> 0;
|
|
|
- myLucky.current?.stop(index);
|
|
|
- setButtons((value) => {
|
|
|
- const newValue = [...value];
|
|
|
- newValue[0].fonts[0].text = index;
|
|
|
- return newValue;
|
|
|
- });
|
|
|
- }, 2500);
|
|
|
+ if (wheel.activities) {
|
|
|
+ getWheelRunApi({ activity_id: wheel.activities[0].id })
|
|
|
+ .then((res) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ myLucky.current?.stop(res.data.index);
|
|
|
+
|
|
|
+ setButtons((values) => {
|
|
|
+ const newValues = [...values];
|
|
|
+ newValues[0].fonts[0].text = res.data.amount;
|
|
|
+ return newValues;
|
|
|
+ });
|
|
|
+
|
|
|
+ wheel.handler && wheel.handler();
|
|
|
+ }, 2500);
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ myLucky.current?.init();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ myLucky.current?.init();
|
|
|
+ }
|
|
|
};
|
|
|
const endRotate = (prize: any) => {
|
|
|
console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 304`, prize);
|
|
@@ -319,7 +338,7 @@ const DrawMain = () => {
|
|
|
<img src={"/wheels/wheel-bg.png"} className={"w-[100%]"} />
|
|
|
<img
|
|
|
src={"/wheels/title.png"}
|
|
|
- className={"absolute left-[13%] top-[53%] z-10 w-[70%] object-cover"}
|
|
|
+ className={"absolute left-[13.5%] top-[53%] z-10 w-[70%] object-cover"}
|
|
|
/>
|
|
|
{/*定位到中心圆*/}
|
|
|
<div className={"absolute bottom-[0.0347rem] h-[2.6736rem] w-[100%]"}>
|
|
@@ -423,15 +442,15 @@ const CountdownClient = () => {
|
|
|
const wheel = useContext(WheelContext);
|
|
|
|
|
|
const [_, formattedRes] = useCountDown({
|
|
|
- leftTime: wheel.activate?.end_time,
|
|
|
+ leftTime: wheel.activate?.end_time! * 1000 - Date.now(),
|
|
|
});
|
|
|
const { days, hours, minutes, seconds } = formattedRes;
|
|
|
return (
|
|
|
<div className={"relative flex justify-center"}>
|
|
|
<img src="/wheels/countdown-bg.png" alt="" />
|
|
|
- <span className={"absolute bottom-[50%] translate-y-1/2"}>
|
|
|
- {String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}:
|
|
|
- {String(seconds).padStart(2, "0")}
|
|
|
+ <span className={"absolute bottom-[50%] ml-[0.2083rem] translate-y-1/2"}>
|
|
|
+ {String(days).padStart(2, "0")}:{String(hours).padStart(2, "0")}:
|
|
|
+ {String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
|
|
|
</span>
|
|
|
</div>
|
|
|
);
|
|
@@ -612,7 +631,25 @@ const ShareClient = () => {
|
|
|
};
|
|
|
|
|
|
const CashWheelClient: FC<Props> = (props) => {
|
|
|
- const values = { ...props.wheel, num: 100 };
|
|
|
+ const getWheelData = () => {
|
|
|
+ getWheelApi().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ setValues((staticValue) => {
|
|
|
+ return { ...staticValue, ...res.data };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ const [values, setValues] = useState<Partial<ContextType>>({
|
|
|
+ num: 100,
|
|
|
+ allHistory: props.allHistory || [],
|
|
|
+ handler: getWheelData,
|
|
|
+ });
|
|
|
+ useEffect(() => {
|
|
|
+ getWheelData();
|
|
|
+ }, []);
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<WheelContext.Provider value={values}>
|