index.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React, { useState } from 'react'
  2. import styles from './index.module.scss'
  3. import classNames from 'classnames'
  4. import { GoodsRow } from '@/types'
  5. import { baseURL } from '@/utils/history'
  6. import { Image } from 'antd'
  7. import LazyImg from '../LazyImg'
  8. type Props = {
  9. info: GoodsRow
  10. closeFu: () => void
  11. type: 'img' | 'model' | 'video'
  12. }
  13. function LookGood({ info, closeFu, type }: Props) {
  14. const [imgLook, setImgLook] = useState('')
  15. return (
  16. <div className={classNames(styles.LookGood)} id='LookGood'>
  17. {/* 关闭按钮 */}
  18. <img onClick={closeFu} className='Lcolse' src={baseURL + 'goods/close.png'} alt='' />
  19. <div className={classNames('Lmain', type === 'model' ? 'LmainFull' : '')}>
  20. <div className='LmainCen'>
  21. {type === 'img' ? (
  22. <div className='Limg' onClick={() => setImgLook(baseURL + info.lookSrc)}>
  23. <LazyImg src={baseURL + info.lookSrc} />
  24. </div>
  25. ) : null}
  26. {type === 'model' ? (
  27. <iframe
  28. title={'模型'}
  29. src={`${baseURL}modelLoding/model.html?u=${info.lookSrc}`}
  30. frameBorder='0'
  31. ></iframe>
  32. ) : null}
  33. {type === 'video' ? <video src={baseURL + info.lookSrc} controls /> : null}
  34. </div>
  35. <div className='LmTxt'>{info.name}</div>
  36. </div>
  37. {/* pc端查看图片 */}
  38. {imgLook ? (
  39. <Image
  40. preview={{
  41. visible: !!imgLook,
  42. src: imgLook,
  43. onVisibleChange: () => setImgLook('')
  44. }}
  45. />
  46. ) : null}
  47. </div>
  48. )
  49. }
  50. const MemoLookGood = React.memo(LookGood)
  51. export default MemoLookGood