index.jsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import styles from './styles.module.scss';
  2. import Spring from "@components/Spring";
  3. import React, {useEffect} from "react";
  4. import icon_1 from "@assets/promotion/icon_1.svg";
  5. import banner_1 from "@assets/promotion/banner_1.png";
  6. import icon_2 from "@assets/promotion/icon_2.svg";
  7. import banner_2 from "@assets/promotion/banner_2.png";
  8. import icon_3 from "@assets/promotion/icon_3.svg";
  9. import banner_3 from "@assets/promotion/banner_3.png";
  10. import {useNavigate} from "react-router-dom";
  11. import {useDispatch, useSelector} from "react-redux";
  12. import {getRedPackInfo} from "@features/redpackSlice";
  13. import {formatTime} from "@utils/helpers";
  14. import {reqRedpackCheck} from "@features/api";
  15. import {getTurnplate} from "@features/turnplateSlice";
  16. const icons=[
  17. null,
  18. icon_1,
  19. icon_2,
  20. icon_3
  21. ]
  22. const banners=[
  23. null,
  24. banner_1,
  25. banner_2,
  26. banner_3
  27. ]
  28. const WPromotion=({close})=>{
  29. const navigate=useNavigate();
  30. const redpack=useSelector(getRedPackInfo);
  31. const turnplate=useSelector(getTurnplate);
  32. const dispatch=useDispatch();
  33. let data=[
  34. {
  35. id:1,
  36. title:"Tycoon",
  37. icon:"",
  38. banner:"",
  39. link:"#/cashwheel",
  40. },
  41. {
  42. id:2,
  43. title:"Collection",
  44. icon:"",
  45. banner:"",
  46. link:"#/moneyrain",
  47. },
  48. {
  49. id:3,
  50. title:"Agent",
  51. icon:"",
  52. banner:"",
  53. link:"#/agent",
  54. }
  55. ]
  56. useEffect(()=>{
  57. dispatch(reqRedpackCheck());
  58. },[])
  59. const checkRenderDot=(item)=>{
  60. if (item.id===1){
  61. if (turnplate&&turnplate.times>0){
  62. return (<div className={styles.red_dot}></div>)
  63. }
  64. }
  65. return (<></>);
  66. }
  67. const renderRedPackItem=(item)=>{
  68. if (redpack==null)return (<></>);
  69. let status=redpack.status;
  70. let cdLeft=redpack.next_in_seconds;
  71. let cdLeftStr=formatTime(cdLeft);
  72. return (
  73. <>
  74. <div className={styles.gift_title}>{status!==0?item.title:cdLeftStr}</div>
  75. <button className={styles.git_fun_item} onClick={() => {
  76. navigate(item.link);
  77. }}>
  78. <div className={styles.left}>
  79. <div className={styles.icon_con}>
  80. <img className={"iconshake"} src={icons[item.id]}/>
  81. {
  82. status===1? (<div className={styles.red_dot}></div>):(<></>)
  83. }
  84. </div>
  85. </div>
  86. <div className={styles.right}>
  87. <img src={banners[item.id]}/>
  88. </div>
  89. </button>
  90. </>
  91. )
  92. }
  93. const renderItem = (item) => {
  94. if (item.id === 2) return (renderRedPackItem(item));
  95. return (
  96. <>
  97. <div className={styles.gift_title}>{item.title}</div>
  98. <button className={styles.git_fun_item} onClick={() => {
  99. navigate(item.link);
  100. }}>
  101. <div className={styles.left}>
  102. <div className={styles.icon_con}>
  103. <img className={"iconshake"} src={icons[item.id]}/>
  104. {/*<div className={styles.red_dot}></div>*/}
  105. {checkRenderDot(item)}
  106. </div>
  107. </div>
  108. <div className={styles.right}>
  109. <img src={banners[item.id]}/>
  110. </div>
  111. </button>
  112. </>
  113. )
  114. }
  115. const renderList = () => {
  116. return (
  117. <>
  118. {
  119. data.map((item, index) => {
  120. return (
  121. <div key={index} className={styles.gift_item}>
  122. {renderItem(item)}
  123. </div>
  124. )
  125. })
  126. }
  127. </>
  128. )
  129. }
  130. return (
  131. <div className={styles.container}>
  132. <Spring type="slideUp" className={styles.content}>
  133. {renderList()}
  134. </Spring>
  135. </div>
  136. )
  137. }
  138. export default WPromotion;