index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { useEffect, useRef } from 'react'
  2. import styles from './index.module.scss'
  3. import BtnRight from '@/components/BtnRight'
  4. import { GoodsType } from '@/types'
  5. import { baseURL } from '@/utils/http'
  6. type Props = {
  7. closeFu: () => void
  8. info: GoodsType
  9. }
  10. function HotInfo({ closeFu, info }: Props) {
  11. const videoRef = useRef<HTMLVideoElement>(null)
  12. useEffect(() => {
  13. if (info.type === 'video') {
  14. setTimeout(() => {
  15. if (videoRef.current) videoRef.current.play()
  16. }, 100)
  17. }
  18. }, [info.type])
  19. return (
  20. <div id='HotOpCss' className={styles.HotInfo}>
  21. {/* 左边主体 */}
  22. <div className='S3Ileft'>
  23. {info.type === 'img' ? (
  24. <img src={baseURL + info.inSrc} alt='' />
  25. ) : info.type === 'video' ? (
  26. <video muted ref={videoRef} src={baseURL + info.inSrc} controls></video>
  27. ) : (
  28. <iframe
  29. title={info.name}
  30. src={`${baseURL}modelLoding/model.html?u=${info.inSrc}`}
  31. frameBorder='0'
  32. ></iframe>
  33. )}
  34. </div>
  35. {/* 右边文字 */}
  36. <div className='S3Iright'>
  37. <h3 className='sizeNo'>{info.name}</h3>
  38. <div dangerouslySetInnerHTML={{ __html: info.inTxt }}></div>
  39. </div>
  40. {/* 右下角的返回按钮 */}
  41. <BtnRight imgName='back' clickSon={() => closeFu()} title='返回' />
  42. </div>
  43. )
  44. }
  45. const MemoHotInfo = React.memo(HotInfo)
  46. export default MemoHotInfo