index.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { useCallback, useMemo, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { baseURL, isPc, myData } from '@/utils/http'
  4. import HotIcon from '@/components/HotIcon'
  5. import history from '@/utils/history'
  6. type Props = {
  7. hidden: boolean
  8. isLoding: boolean
  9. }
  10. const data = myData.more['探索庄园']
  11. function S1manor({ hidden, isLoding }: Props) {
  12. const [adInd, setAcInd] = useState(0)
  13. const hotInfo = useMemo(() => {
  14. return data.hot[adInd]
  15. }, [adInd])
  16. // 点击热点
  17. const clickSon = useCallback((index: number) => {
  18. if (isPc) history.push(data.hot[index].path)
  19. else setAcInd(index)
  20. }, [])
  21. return (
  22. <div
  23. hidden={hidden}
  24. className={styles.S1manor}
  25. style={{ backgroundImage: `url(${baseURL + data.bg})` }}
  26. >
  27. {/* 左侧图标 */}
  28. <div
  29. className='S1left'
  30. hidden={isLoding}
  31. style={{ backgroundImage: `url(${baseURL}more/s1Zhe.png)` }}
  32. >
  33. <img className='SlL1' src={baseURL + hotInfo.leftImg} alt='' />
  34. <div className='SlL2' onClick={() => history.push(hotInfo.path)}>
  35. <img src={`${baseURL}visit/arrow.png`} alt='' />
  36. <div className='BIBtxt'>开始探索</div>
  37. </div>
  38. </div>
  39. <div className='S1hotBox' hidden={isLoding}>
  40. {data.hot.map((item, index) => (
  41. // 热点图标
  42. <HotIcon
  43. key={index}
  44. index={index}
  45. clickSon={val => clickSon(val)}
  46. hoverSrc={item.hoverSrc}
  47. style={{
  48. top: item.loc.top,
  49. left: item.loc.left
  50. }}
  51. zIndex={item.zIndex}
  52. // 这个模块特有的参数
  53. hoverFu={val => setAcInd(val)}
  54. isHoverAc={adInd === index}
  55. isZhan={true}
  56. />
  57. ))}
  58. </div>
  59. </div>
  60. )
  61. }
  62. const MemoS1manor = React.memo(S1manor)
  63. export default MemoS1manor