index.tsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import React, { useCallback, useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import useDataUrl from '@/components/ownUse/useDataUrl'
  4. import { myData } from '@/utils/http'
  5. import classNames from 'classnames'
  6. import { domDelOwnFu } from '@/utils/utilsSome'
  7. import { ArrowRightOutlined } from '@ant-design/icons'
  8. import history from '@/utils/history'
  9. import Hot2 from '../A2visit/PanoVideo/Hot2'
  10. function A4dance() {
  11. const { dataUrlSame } = useDataUrl()
  12. // 待完善
  13. const [loding, setLoding] = useState(100)
  14. const timeRR = useRef(-1)
  15. useEffect(() => {
  16. clearInterval(timeRR.current)
  17. timeRR.current = window.setInterval(() => {
  18. if (loding >= 100) {
  19. clearInterval(timeRR.current)
  20. return
  21. }
  22. setLoding(loding + 1)
  23. }, 40)
  24. }, [loding])
  25. // 点击继续
  26. const btnStart = useCallback(() => {
  27. if (loding >= 100) {
  28. setLoding(110)
  29. // 0.5s之后删除自己
  30. setTimeout(() => {
  31. domDelOwnFu('.A4base')
  32. }, 500)
  33. }
  34. }, [loding])
  35. // 点击 跳下一个章节
  36. const [lastVideo, setLastVideo] = useState(false)
  37. const videoRefLast = useRef<HTMLVideoElement>(null)
  38. const lastVideoFu = useCallback(() => {
  39. setLastVideo(true)
  40. setTimeout(() => {
  41. if (videoRefLast.current) {
  42. videoRefLast.current.play()
  43. }
  44. }, 100)
  45. // 0.5s之后删除自己
  46. setTimeout(() => {
  47. domDelOwnFu('.pvBox')
  48. }, 500)
  49. }, [])
  50. // 底部选中
  51. const [floorAc, setFloorAc] = useState(-1)
  52. useEffect(() => {
  53. if (floorAc !== -1) {
  54. setTimeout(() => {
  55. const domAll: any = document.querySelectorAll('.A4fRvideo')
  56. if (domAll && domAll.length) {
  57. domAll.forEach((v: HTMLVideoElement, i: number) => {
  58. if (floorAc === i) v.play()
  59. else {
  60. v.pause()
  61. v.currentTime = 0
  62. }
  63. })
  64. }
  65. }, 100)
  66. }
  67. }, [floorAc])
  68. // 点击 云气图
  69. const hotVideoRef = useRef<HTMLVideoElement>(null)
  70. const [hotInd, setHotInd] = useState(-1)
  71. const hotShowFu = useCallback((index: number) => {
  72. setHotInd(index)
  73. // 第一个热点 云气图 其他是通用热点
  74. if (index === 0) {
  75. setTimeout(() => {
  76. if (hotVideoRef.current) {
  77. hotVideoRef.current.play()
  78. }
  79. }, 100)
  80. }
  81. }, [])
  82. return (
  83. <div className={styles.A4dance} style={{ backgroundImage: `url(${dataUrlSame}dance/bj.jpg)` }}>
  84. {/* 初始页面 */}
  85. <div className={classNames('A4base', loding === 110 ? 'A4baseHide' : '')}>
  86. <img src={`${dataUrlSame}dance/mulu.png`} alt='' />
  87. <div className='A4baseBtn' onClick={btnStart}>
  88. {/* anpg动图 */}
  89. <div className='A4BIcon'>
  90. <img src={`${dataUrlSame}visit/arrow.png`} alt='' />
  91. </div>
  92. <img src={`${dataUrlSame}visit/btn.png`} alt='' />
  93. <div className='A4Btxt'>{loding >= 100 ? '点击继续' : '加载中'}</div>
  94. {loding >= 100 ? null : (
  95. <div className='A4Bxian'>
  96. <div>
  97. <div style={{ width: loding + '%' }}></div>
  98. </div>
  99. </div>
  100. )}
  101. </div>
  102. </div>
  103. {/* 主要内容 */}
  104. <div
  105. className={classNames(
  106. 'pvBox',
  107. lastVideo ? 'pvBoxHide' : '',
  108. loding === 110 ? 'pvBoxShow' : 'pvBoxHide'
  109. )}
  110. >
  111. {/* 热点 云气图为第一个 */}
  112. {myData.dance.hot.map((item, index) => (
  113. <div
  114. onClick={() => hotShowFu(index)}
  115. key={index}
  116. className='pvHot'
  117. style={{
  118. top: item.loc.top,
  119. left: item.loc.left
  120. }}
  121. >
  122. <img className='pvHotBase' src={`${dataUrlSame}visit/hot/hotBase.png`} alt='' />
  123. <img className='pvHotHover' src={dataUrlSame + item.imgSrc} alt='' />
  124. </div>
  125. ))}
  126. {/* 底部 */}
  127. <div className='pvfloor'>
  128. {myData.dance.floor.map((item, index) => (
  129. <div
  130. key={index}
  131. onClick={() => setFloorAc(index)}
  132. className={classNames('pvflRow', floorAc === index ? 'pvflRowAc' : '')}
  133. >
  134. {/* 蒙版 */}
  135. <div className='pvflR1'></div>
  136. {/* 底图 */}
  137. <div className='pvflR2'>
  138. <img src={dataUrlSame + item.imgSrc} alt='' />
  139. </div>
  140. {/* 文字 */}
  141. <div className='pvflR3'>{item.name}</div>
  142. </div>
  143. ))}
  144. </div>
  145. {/* 跳到下一章 */}
  146. <div className='pvBtn'>
  147. <img src={`${dataUrlSame}visit/btn.png`} alt='' />
  148. <div onClick={lastVideoFu}>
  149. 后厨备宴
  150. <ArrowRightOutlined />
  151. </div>
  152. </div>
  153. {/* 右下角按钮 */}
  154. <div className='pvRRbtn'>
  155. {/* <div className='pvRRbtn1' title='漫游模式'></div> */}
  156. {/* 更多 跳新页面 */}
  157. <div className='pvRRbtn2' title='更多' onClick={() => history.push('/chef')}></div>
  158. </div>
  159. {/* 中间的8个动画视频*/}
  160. <div
  161. className={classNames('A4floorBox', floorAc === -1 ? 'A4floorBoxHide' : '')}
  162. style={{ backgroundImage: `url(${dataUrlSame}dance/dongBj.png)` }}
  163. >
  164. <div className='A4fMain'>
  165. {/* 边框遮盖 */}
  166. <img className='A4fMainKK' src={`${dataUrlSame}dance/dongK.png`} alt='' />
  167. {/* 返回按钮 */}
  168. <img
  169. className='A4fMback'
  170. onClick={() => setFloorAc(-1)}
  171. src={`${dataUrlSame}dance/back22.png`}
  172. alt=''
  173. />
  174. {myData.dance.floor.map((item, index) => (
  175. <div key={index} className='A4fRow' style={{ opacity: floorAc === index ? 1 : 0 }}>
  176. <video
  177. className='A4fRvideo'
  178. playsInline
  179. muted
  180. webkit-playsinline='true'
  181. x5-video-player-type='h5'
  182. src={dataUrlSame + item.videoSrc}
  183. >
  184. <source type='video/mp4' />
  185. Your browser does not support the video tag.
  186. </video>
  187. </div>
  188. ))}
  189. </div>
  190. </div>
  191. </div>
  192. {/* 点击四神云气图的动画 */}
  193. <div className={classNames('A4hotBox', hotInd === 0 ? 'A4hotBoxShow' : '')}>
  194. <video
  195. ref={hotVideoRef}
  196. playsInline
  197. muted
  198. webkit-playsinline='true'
  199. x5-video-player-type='h5'
  200. src={dataUrlSame + myData.dance.hot[0].videoSrc}
  201. onEnded={() => history.push('/yun')}
  202. >
  203. <source type='video/mp4' />
  204. Your browser does not support the video tag.
  205. </video>
  206. </div>
  207. {/* 点击其他热点 */}
  208. {hotInd > 0 ? (
  209. <div className={'A4othHot'}>
  210. <Hot2
  211. data={myData.dance.hot[hotInd].data}
  212. closeFu={() => setHotInd(-1)}
  213. name={myData.dance.hot[hotInd].name}
  214. />
  215. </div>
  216. ) : null}
  217. {/* 最后一个过长动画 */}
  218. <div className={classNames('A4last', lastVideo ? 'A4lastShow' : '')}>
  219. <video
  220. ref={videoRefLast}
  221. playsInline
  222. muted
  223. webkit-playsinline='true'
  224. x5-video-player-type='h5'
  225. src={dataUrlSame + myData.dance.lastVideo}
  226. onEnded={() => history.push('/chef')}
  227. >
  228. <source type='video/mp4' />
  229. Your browser does not support the video tag.
  230. </video>
  231. <div
  232. title='跳过'
  233. className='A3videoLastBtn'
  234. style={{ backgroundImage: `url(${dataUrlSame}home/tiao.png)` }}
  235. onClick={() => history.push('/chef')}
  236. ></div>
  237. </div>
  238. </div>
  239. )
  240. }
  241. const MemoA4dance = React.memo(A4dance)
  242. export default MemoA4dance