index.tsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import React, { useCallback, useEffect, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { baseURL, myData } from '@/utils/http'
  4. import classNames from 'classnames'
  5. import Hot2 from '../A2visit/PanoVideo/Hot2'
  6. import EndVideo from '@/components/EndVideo'
  7. import BaseImg from '@/components/BaseImg'
  8. import HotIcon from '@/components/HotIcon'
  9. import FloorBtn from '@/components/FloorBtn'
  10. import NextPage from '@/components/NextPage'
  11. import useLoding from '@/components/ownUse/useLoding'
  12. import history from '@/utils/history'
  13. import BtnRight from '@/components/BtnRight'
  14. function A4dance() {
  15. const [baseSta, setBaseSta] = useState(false)
  16. // 点击继续
  17. const btnStart = useCallback(() => {
  18. setBaseSta(true)
  19. }, [])
  20. // 点击 跳下一个章节
  21. const [lastVideo, setLastVideo] = useState(false)
  22. // 底部选中
  23. const [floorAc, setFloorAc] = useState(-1)
  24. useEffect(() => {
  25. if (floorAc !== -1) {
  26. setTimeout(() => {
  27. const domAll: any = document.querySelectorAll('.A4fRvideo')
  28. if (domAll && domAll.length) {
  29. domAll.forEach((v: HTMLVideoElement, i: number) => {
  30. if (floorAc === i) v.play()
  31. else {
  32. v.pause()
  33. v.currentTime = 0
  34. }
  35. })
  36. }
  37. }, 100)
  38. }
  39. }, [floorAc])
  40. const [hotInd, setHotInd] = useState(-1)
  41. const hotShowFu = useCallback((index: number) => {
  42. if (index === 0) {
  43. // 云气图 直接跳页面
  44. history.push('/yun')
  45. } else setHotInd(index)
  46. }, [])
  47. // 先加载背景图 序列帧等 在加载视频
  48. const { imgNow, imgNumFu } = useLoding(2)
  49. return (
  50. <div className={styles.A4dance} style={{ backgroundImage: `url(${baseURL}dance/bj.jpg)` }}>
  51. {/* 初始页面 */}
  52. <BaseImg
  53. isShow={baseSta}
  54. iconSrc={`${baseURL}dance/mulu.png`}
  55. parentFu={() => btnStart()}
  56. imgNow={imgNow}
  57. imgNumFu={imgNumFu}
  58. />
  59. {/* 主要内容 */}
  60. {imgNow ? (
  61. <div
  62. className={classNames(
  63. 'pvBox',
  64. lastVideo ? 'pvBoxHide' : '',
  65. baseSta ? 'pvBoxShow' : 'pvBoxHide'
  66. )}
  67. >
  68. {/* 热点图标 云气图为第一个*/}
  69. {myData.dance.hot.map((item, index) =>
  70. item.name === '汉代乐舞百戏' ? (
  71. <div
  72. onClick={() => hotShowFu(1)}
  73. key={index}
  74. className='A4leftBtn'
  75. style={{ backgroundImage: `url(${baseURL}chef/chuBtn.png)` }}
  76. >
  77. 汉代乐舞百戏
  78. </div>
  79. ) : (
  80. <HotIcon
  81. style={{
  82. top: item.locPage.top,
  83. left: item.locPage.left
  84. }}
  85. key={index}
  86. index={index}
  87. clickSon={val => hotShowFu(val)}
  88. hoverSrc={item.hoverSrc}
  89. isZhan={true}
  90. />
  91. )
  92. )}
  93. {/* 底部 */}
  94. <div className='pvfloor'>
  95. {myData.dance.floor.map((item, index) =>
  96. // 直接去掉杂技
  97. item.name === '杂技' ? null : (
  98. <div
  99. key={index}
  100. onClick={() => setFloorAc(index)}
  101. className={classNames('pvflRow', floorAc === index ? 'pvflRowAc' : '')}
  102. >
  103. {/* 蒙版 */}
  104. <div className='pvflR1'></div>
  105. {/* 底图 */}
  106. <div className='pvflR2'>
  107. <img src={baseURL + item.hoverSrc} alt='' />
  108. </div>
  109. {/* 文字 */}
  110. <div className='pvflR3'>{item.name}</div>
  111. </div>
  112. )
  113. )}
  114. </div>
  115. {/* 跳到下一章 */}
  116. <NextPage clickSon={() => setLastVideo(true)} txt='后厨备宴' />
  117. {/* 右下角按钮 */}
  118. <FloorBtn />
  119. {/* 中间的8个动画视频*/}
  120. <div
  121. className={classNames('A4floorBox', floorAc === -1 ? 'A4floorBoxHide' : '')}
  122. style={{ backgroundImage: `url(${baseURL}dance/dongBj.png)` }}
  123. >
  124. <div className='A4fMain'>
  125. {/* 边框遮盖 */}
  126. {/* <img className='A4fMainKK' src={`${baseURL}dance/dongK.png`} alt='' /> */}
  127. {/* 返回按钮 */}
  128. <BtnRight imgName='back' clickSon={() => setFloorAc(-1)} title='返回' />
  129. {myData.dance.floor.map((item, index) => (
  130. <div key={index} className='A4fRow' style={{ opacity: floorAc === index ? 1 : 0 }}>
  131. <video
  132. className='A4fRvideo'
  133. playsInline
  134. muted
  135. webkit-playsinline='true'
  136. x5-video-player-type='h5'
  137. loop
  138. >
  139. <source type='video/mp4' src={baseURL + item.videoSrc} />
  140. Your browser does not support the video tag.
  141. </video>
  142. </div>
  143. ))}
  144. </div>
  145. </div>
  146. </div>
  147. ) : null}
  148. {/* 点击四神云气图的动画 */}
  149. {/* {imgNow ? (
  150. <EndVideo
  151. lastVideo={hotInd === 0}
  152. delDom='.pvBox'
  153. src={baseURL + myData.dance.hot[0].videoSrc}
  154. path='/yun'
  155. />
  156. ) : null} */}
  157. {/* 点击其他热点 */}
  158. {hotInd > 0 ? (
  159. <div className={'A4othHot'}>
  160. <Hot2
  161. data={myData.dance.hot[hotInd].data}
  162. closeFu={() => setHotInd(-1)}
  163. name={myData.dance.hot[hotInd].name}
  164. />
  165. </div>
  166. ) : null}
  167. {/* 结尾动画 */}
  168. {imgNow ? (
  169. <EndVideo
  170. lastVideo={lastVideo}
  171. delDom='.pvBox'
  172. src={baseURL + myData.dance.lastVideo}
  173. path='/chef'
  174. />
  175. ) : null}
  176. </div>
  177. )
  178. }
  179. const MemoA4dance = React.memo(A4dance)
  180. export default MemoA4dance