index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import React, { useCallback, useEffect, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import classNames from 'classnames'
  4. import { baseURL, hotInfo, myData } from '@/utils/http'
  5. import EndVideo from '@/components/EndVideo'
  6. import BaseImg from '@/components/BaseImg'
  7. import HotIcon from '@/components/HotIcon'
  8. import NextPage from '@/components/NextPage'
  9. import FloorBtn from '@/components/FloorBtn'
  10. import useLoding from '@/components/ownUse/useLoding'
  11. import BtnRight from '@/components/BtnRight'
  12. import Zhot from '@/components/Zhot'
  13. import history from '@/utils/history'
  14. function A5chef() {
  15. // 点击继续
  16. const [baseFlag, setBaseFlag] = useState(true)
  17. const btnStart = useCallback(() => {
  18. setBaseFlag(false)
  19. }, [])
  20. // 点击 跳下一个章节
  21. const [lastVideo, setLastVideo] = useState(false)
  22. // 点击后厨群像
  23. const [chuShow, setChuShow] = useState(false)
  24. // 点击热点
  25. const [hotInd, setHotInd] = useState(-1)
  26. useEffect(() => {
  27. if (hotInd !== -1) {
  28. setTimeout(() => {
  29. const doms: any = document.querySelectorAll('.A5videoDom')
  30. if (doms && doms.length) {
  31. doms.forEach((v: HTMLVideoElement, i: number) => {
  32. if (hotInd === i) v.play()
  33. else {
  34. v.pause()
  35. v.currentTime = 0
  36. }
  37. })
  38. }
  39. }, 100)
  40. }
  41. }, [hotInd])
  42. // 先加载背景图 序列帧等 在加载视频
  43. const { imgNow, imgNumFu } = useLoding(2)
  44. //热点
  45. const [acName, setAcName] = useState('')
  46. return (
  47. <div className={styles.A5chef}>
  48. {/* 整体盒子 */}
  49. <div className='A5main' style={{ backgroundImage: `url(${baseURL + myData.chef.baseImg})` }}>
  50. {/* 初始页面 */}
  51. <BaseImg
  52. num={50}
  53. isShow={!baseFlag}
  54. iconSrc={`${baseURL}chef/mulu.png`}
  55. parentFu={() => btnStart()}
  56. imgNow={imgNow}
  57. imgNumFu={imgNumFu}
  58. bird='houCu'
  59. />
  60. {/* 热点按钮页面 */}
  61. {imgNow ? (
  62. <div className={classNames('A5hotBox', baseFlag ? '' : 'A5hotBoxAc')}>
  63. {/* 循环渲染热点 */}
  64. {myData.chef.hot.map((item, index) => (
  65. <HotIcon
  66. isModel={item.isModel ? true : false}
  67. style={{
  68. top: item.loc.top,
  69. left: item.loc.left
  70. }}
  71. key={index}
  72. index={index}
  73. clickSon={val => setHotInd(val)}
  74. hoverSrc={item.hoverSrc}
  75. isXiao={0.67}
  76. />
  77. ))}
  78. {/* ---------最新热点-------------- */}
  79. {hotInfo.houCu.map((item, index) => (
  80. <HotIcon
  81. isModel={item.tubiao === '文物' ? true : false}
  82. key={index}
  83. index={index}
  84. style={{ top: item.locPage.top, left: item.locPage.left }}
  85. hoverSrc={item.hoverSrc}
  86. zIndex={item.zIndex}
  87. clickSon={() => setAcName(item.name)}
  88. isXiao={0.67}
  89. />
  90. ))}
  91. {/* 后厨群像 */}
  92. <div
  93. style={{
  94. backgroundImage: `url(${baseURL}chef/houChu.jpg)`,
  95. zIndex: chuShow ? 30 : 1
  96. }}
  97. className={classNames('A5chu', chuShow ? 'A5chuShow' : '')}
  98. >
  99. {/* 返回按钮 */}
  100. <BtnRight imgName='back' clickSon={() => setChuShow(false)} title='返回' />
  101. </div>
  102. <div
  103. onClick={() => setChuShow(true)}
  104. className='A5chuBtn'
  105. style={{ backgroundImage: `url(${baseURL}chef/chuBtn.png)` }}
  106. >
  107. 后厨群像
  108. </div>
  109. {/* 跳到下一章 */}
  110. <NextPage clickSon={() => setLastVideo(true)} txt='田间耕作' />
  111. {/* 右下角按钮 */}
  112. <FloorBtn unityEnd={() => history.push('unend/end')} />
  113. </div>
  114. ) : null}
  115. </div>
  116. {/* 点击热点之后出来的视频 */}
  117. {imgNow
  118. ? myData.chef.hot.map((item, index) => (
  119. <div key={index} className={classNames('A5video', hotInd === index ? 'A5videoAc' : '')}>
  120. <video
  121. className='A5videoDom'
  122. key={index}
  123. playsInline
  124. muted
  125. webkit-playsinline='true'
  126. x5-video-player-type='h5'
  127. loop
  128. >
  129. <source type='video/mp4' src={`${baseURL}chef/${item.videoId}.mp4`} />
  130. Your browser does not support the video tag.
  131. </video>
  132. {/* 热点左侧图文信息 */}
  133. <div
  134. className='A5vTxt'
  135. style={{
  136. backgroundImage: `url(${baseURL}chef/hotBg.png)`
  137. }}
  138. >
  139. <img src={baseURL + item.showImg} alt='' />
  140. <div dangerouslySetInnerHTML={{ __html: item.txt }}></div>
  141. </div>
  142. {/* 返回按钮 */}
  143. <BtnRight imgName='back' clickSon={() => setHotInd(-1)} title='返回' />
  144. </div>
  145. ))
  146. : null}
  147. {/* 结尾动画 */}
  148. {imgNow ? (
  149. <EndVideo
  150. lastVideo={lastVideo}
  151. src={baseURL + myData.chef.lastVideo}
  152. path='/plow'
  153. delDom='.A5video'
  154. noBtn={true}
  155. />
  156. ) : null}
  157. {acName ? <Zhot name={acName} closeFu={() => setAcName('')} /> : null}
  158. </div>
  159. )
  160. }
  161. const MemoA5chef = React.memo(A5chef)
  162. export default MemoA5chef