ActivityMask.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. "use client";
  2. import { getUserMoneyApi } from "@/api/user";
  3. import { useRequest } from "ahooks";
  4. import { Mask } from "antd-mobile";
  5. import { motion } from "framer-motion";
  6. import { useState } from "react";
  7. import styles from "./activityMask.module.scss";
  8. const ActivityMask = () => {
  9. const [count, setCount] = useState<number>(0);
  10. // const wallet = useWalletStore((state) => state.wallet);
  11. // useEffect(() => {
  12. // if (wallet?.notice?.lose_score > 0) {
  13. // setVisible(true);
  14. // }
  15. // }, [wallet?.notice?.lose_score]);
  16. const { run, cancel } = useRequest(getUserMoneyApi, {
  17. pollingInterval: 5000,
  18. pollingWhenHidden: true,
  19. pollingErrorRetryCount: 3,
  20. staleTime: 5000,
  21. onError: (error) => {},
  22. onSuccess: (res) => {
  23. if (res.data.notice.lose_score > 0) {
  24. setCount(res.data.notice.lose_score);
  25. cancel();
  26. }
  27. },
  28. });
  29. return (
  30. <Mask
  31. visible={!!count}
  32. destroyOnClose={true}
  33. getContainer={null}
  34. onMaskClick={() => {
  35. setCount(0);
  36. run();
  37. }}
  38. >
  39. {/*<div*/}
  40. {/* className={"absolute right-[0.2083rem] top-[20%] z-50"}*/}
  41. {/* onClick={() => setVisible(false)}*/}
  42. {/*>*/}
  43. {/* <span className={"iconfont icon-guanbi"}></span>*/}
  44. {/*</div>*/}
  45. <div
  46. className={"absolute top-[18%] z-50 w-[100%]"}
  47. onClick={() => {
  48. setCount(0);
  49. run();
  50. }}
  51. >
  52. <div className={"relative flex h-[4.4653rem] w-[100%] justify-center"}>
  53. <img
  54. alt={""}
  55. src={"/doings/activity.png"}
  56. className={"h-[100%]" + " object-contain" + " absolute"}
  57. />
  58. <motion.div
  59. className={"absolute -top-[13%] -z-10 flex h-[4.1667rem] items-center"}
  60. animate={{
  61. rotate: [0, 90, 180],
  62. }}
  63. transition={{
  64. duration: 10,
  65. ease: "linear",
  66. repeat: Infinity,
  67. }}
  68. >
  69. <img src="/img/light.png" alt="" />
  70. </motion.div>
  71. <motion.div
  72. className={"absolute -top-[23%] -z-[9] flex h-[4.1667rem] items-center"}
  73. animate={{
  74. rotate: [0, 90, 180],
  75. }}
  76. transition={{
  77. duration: 20,
  78. ease: "linear",
  79. repeat: Infinity,
  80. }}
  81. >
  82. <img src="/img/light-1.png" alt="" />
  83. </motion.div>
  84. <div
  85. className={
  86. "absolute left-[50%] top-[28%] h-[2.8rem] w-[56%]" +
  87. " -translate-x-1/2 p-[0.0694rem]"
  88. }
  89. >
  90. <div className={"mt-[0.35rem] text-center font-[Arial]"}>
  91. <div
  92. className={styles.ActivityShadow}
  93. // @ts-ignore
  94. style={{ "--font-size": "0.2583rem" }}
  95. data-text={"PRESENTE"}
  96. >
  97. PRESENTE
  98. </div>
  99. <div
  100. className={`${styles.ActivityShadow} -mt-[0.1389rem]`}
  101. // @ts-ignore
  102. style={{ "--font-size": "0.4167rem" }}
  103. data-text={`R$${count}`}
  104. >
  105. R${count}
  106. </div>
  107. </div>
  108. <div className={"absolute bottom-0 text-center text-[#663f23]"}>
  109. <p>Não tive sorte hoje,</p>
  110. <p>Continue com o bom trabalho</p>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </Mask>
  116. );
  117. };
  118. export default ActivityMask;