|
@@ -0,0 +1,162 @@
|
|
|
+import { WheelModalProps } from "@/components/Box/WheelModal";
|
|
|
+import { SlotMachine } from "@lucky-canvas/react";
|
|
|
+import { Mask } from "antd-mobile";
|
|
|
+import { forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
|
|
|
+import animation from "./animations.module.scss";
|
|
|
+interface Props {}
|
|
|
+
|
|
|
+const randomColor = () => {
|
|
|
+ const r = Math.floor(Math.random() * 256);
|
|
|
+ const g = Math.floor(Math.random() * 256);
|
|
|
+ const b = Math.floor(Math.random() * 256);
|
|
|
+ const a = Math.random();
|
|
|
+ let rgba = `rgba(${r},${g},${b},${a})`;
|
|
|
+ return rgba;
|
|
|
+};
|
|
|
+const SlotsClient = () => {
|
|
|
+ const prizes = [
|
|
|
+ {
|
|
|
+ background: "#bac5ee",
|
|
|
+ borderRadius: "10px",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ background: "#bac5ee",
|
|
|
+ borderRadius: "10px",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const slots = [{}, {}, {}, {}];
|
|
|
+
|
|
|
+ const slotsRef = useRef(null);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div className={"border-[1px] border-[red]"}>
|
|
|
+ <div className={"relative m-[0.1389rem] h-[3.3333rem]"}>
|
|
|
+ <img
|
|
|
+ src={"/slots/slots-bg.png"}
|
|
|
+ className={"h-[100%] w-[100%]" + "object-cover" + " " + ""}
|
|
|
+ />
|
|
|
+ <div className={"absolute top-0 h-[2.47rem]"}>
|
|
|
+ <img
|
|
|
+ src={"/slots/light-1.png"}
|
|
|
+ alt={""}
|
|
|
+ className={`h-[100%] ${animation.flashingAnimation}`}
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ src="/slots/light-2.png"
|
|
|
+ alt=""
|
|
|
+ className={`absolute top-0 h-[100%] ${animation.antiFlashingAnimation} `}
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "absolute left-[52%] top-0 -translate-x-1/2" +
|
|
|
+ " h-[0.625rem] w-[1.6rem]" +
|
|
|
+ " border-[1px] border-[green]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ {/*<div*/}
|
|
|
+ {/* className={*/}
|
|
|
+ {/* "h-[0.625rem] w-[1.8rem] " +*/}
|
|
|
+ {/* " relative flex items-center justify-center border-[1px]" +*/}
|
|
|
+ {/* " border-[blue]"*/}
|
|
|
+ {/* }*/}
|
|
|
+ {/*>*/}
|
|
|
+ {/* <div*/}
|
|
|
+ {/* className={*/}
|
|
|
+ {/* "absolute left-0 top-0 flex w-[100%] border-4" +*/}
|
|
|
+ {/* " -z-1 h-[100%] flex-wrap overflow-hidden px-[10px]"*/}
|
|
|
+ {/* }*/}
|
|
|
+ {/* >*/}
|
|
|
+ {/* {Array(200)*/}
|
|
|
+ {/* .fill(0)*/}
|
|
|
+ {/* .map((n, index) => {*/}
|
|
|
+ {/* return (*/}
|
|
|
+ {/* <div*/}
|
|
|
+ {/* style={{ background: randomColor() }}*/}
|
|
|
+ {/* key={index}*/}
|
|
|
+ {/* className={*/}
|
|
|
+ {/* "h-[0.0694rem] w-[0.0694rem]" +*/}
|
|
|
+ {/* " rounded-[50%]"*/}
|
|
|
+ {/* }*/}
|
|
|
+ {/* ></div>*/}
|
|
|
+ {/* );*/}
|
|
|
+ {/* })}*/}
|
|
|
+ {/* </div>*/}
|
|
|
+ {/* <div className={"flex h-[100%] items-center"}>*/}
|
|
|
+ {/* <img*/}
|
|
|
+ {/* src={"/slots/0.png"}*/}
|
|
|
+ {/* alt={""}*/}
|
|
|
+ {/* className={"relative z-10 h-[0.4rem]"}*/}
|
|
|
+ {/* />*/}
|
|
|
+ {/* </div>*/}
|
|
|
+ {/*</div>*/}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/*<div*/}
|
|
|
+ {/* className={*/}
|
|
|
+ {/* "absolute bottom-[50%] left-0 flex w-[100%] translate-y-1/2 " +*/}
|
|
|
+ {/* " p-[20px]" +*/}
|
|
|
+ {/* " justify-center"*/}
|
|
|
+ {/* }*/}
|
|
|
+ {/*></div>*/}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className={"hidden"}>
|
|
|
+ <SlotMachine
|
|
|
+ slots={slots}
|
|
|
+ ref={slotsRef}
|
|
|
+ width="440px"
|
|
|
+ height="201px"
|
|
|
+ prizes={prizes}
|
|
|
+ ></SlotMachine>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+};
|
|
|
+const SlotsModal = forwardRef<WheelModalProps, Props>(function RedPacketModal(props, ref) {
|
|
|
+ const [visible, setVisible] = useState(true);
|
|
|
+
|
|
|
+ const [detailsVisible, setDetailsVisible] = useState(false);
|
|
|
+
|
|
|
+ useImperativeHandle(ref, () => {
|
|
|
+ return {
|
|
|
+ onClose: () => setVisible(false),
|
|
|
+ onOpen: () => {
|
|
|
+ setVisible(true);
|
|
|
+ },
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ const onRotateEnd = () => {
|
|
|
+ setVisible(false);
|
|
|
+ setDetailsVisible(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ const onUnload = () => {
|
|
|
+ setDetailsVisible(false);
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <Mask visible={detailsVisible} getContainer={null} destroyOnClose={true}>
|
|
|
+ <div className={"absolute top-[18%] z-50 w-[100%] px-[0.1389rem]"}>
|
|
|
+ <div>中奖</div>
|
|
|
+ </div>
|
|
|
+ </Mask>
|
|
|
+ <Mask visible={visible} destroyOnClose={true} getContainer={null}>
|
|
|
+ <div
|
|
|
+ className={"absolute right-[0.2083rem] top-[18%] z-50"}
|
|
|
+ onClick={() => setVisible(false)}
|
|
|
+ >
|
|
|
+ <span className={"iconfont icon-guanbi"}></span>
|
|
|
+ </div>
|
|
|
+ <div className={"absolute top-[18%] w-[100%]"}>
|
|
|
+ <SlotsClient />
|
|
|
+ </div>
|
|
|
+ </Mask>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+});
|
|
|
+
|
|
|
+export default memo(SlotsModal);
|