index.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import React, { useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { baseURL, myData } from '@/utils/http'
  4. import NextPage from '@/components/NextPage'
  5. import FloorBtn from '@/components/FloorBtn'
  6. import { domDelOwnFu } from '@/utils/utilsSome'
  7. import CatVideo from '@/components/CatVideo'
  8. import EndVideo from '@/components/EndVideo'
  9. import A22Pano from './A22Pano'
  10. import BtnRight from '@/components/BtnRight'
  11. import classNames from 'classnames'
  12. import history from '@/utils/history'
  13. function A2visit2() {
  14. const [loding, setLoding] = useState(myData.isLdong ? 0 : 100)
  15. const timeRR = useRef(-1)
  16. useEffect(() => {
  17. clearInterval(timeRR.current)
  18. timeRR.current = window.setInterval(() => {
  19. if (loding >= 100) {
  20. clearInterval(timeRR.current)
  21. return
  22. }
  23. setLoding(loding + 2)
  24. }, 50)
  25. }, [loding])
  26. // 底部按钮选中
  27. const [btnAc, setBtnAc] = useState('贵宾')
  28. // 3个视频切换
  29. const [videoPlay, setVideoPlay] = useState(false)
  30. const videoRef = useRef<HTMLVideoElement>(null)
  31. // 进入院落 全景图显示
  32. const [panoShow, setPanoShow] = useState(false)
  33. // 点击进入室内
  34. const [toShi, setToShi] = useState(false)
  35. // 点击观看百戏
  36. const [baiXi, setBaiXi] = useState(false)
  37. const [xiAc, setXiAc] = useState('')
  38. return (
  39. <div className={styles.A2visit2}>
  40. <div
  41. className='A22imgBox'
  42. style={{ opacity: panoShow ? '0' : '1', pointerEvents: panoShow ? 'none' : 'auto' }}
  43. >
  44. {/* 底部按钮 */}
  45. <div
  46. className='A22btn'
  47. style={{
  48. opacity: loding < 100 ? '0' : '1',
  49. pointerEvents: loding < 100 ? 'none' : 'auto'
  50. }}
  51. >
  52. {myData.visit2.btnArr.map((item, index) => (
  53. <div
  54. onClick={() => {
  55. setBtnAc(item)
  56. setVideoPlay(true)
  57. setTimeout(() => {
  58. if (videoRef.current) videoRef.current.play()
  59. }, 100)
  60. }}
  61. key={index}
  62. className='A22btnRow'
  63. style={{
  64. backgroundImage: `url(${baseURL}plow/left${btnAc === item ? 'Ac' : ''}.png)`,
  65. color: btnAc === item ? '#BD7656' : '#DACB8B'
  66. }}
  67. >
  68. {item}
  69. </div>
  70. ))}
  71. </div>
  72. {loding >= 100 ? (
  73. // 进入院落
  74. <NextPage
  75. clickSon={() => {
  76. setPanoShow(true)
  77. setTimeout(() => {
  78. domDelOwnFu('.A22imgBox')
  79. }, 500)
  80. }}
  81. txt='进入院落'
  82. />
  83. ) : null}
  84. {/* 3个视频 */}
  85. <div className='A22videoBox' style={{ zIndex: videoPlay ? '2' : '0' }}>
  86. {myData.visit2.btnArr.map((item, index) => (
  87. <div key={index} className='A22video' style={{ opacity: btnAc === item ? 1 : 0 }}>
  88. <video
  89. ref={btnAc === item ? videoRef : null}
  90. playsInline
  91. muted
  92. webkit-playsinline='true'
  93. x5-video-player-type='h5'
  94. onEnded={() => setVideoPlay(false)}
  95. >
  96. <source type='video/mp4' src={`${baseURL}visit2/${item}.mp4`} />
  97. Your browser does not support the video tag.
  98. </video>
  99. </div>
  100. ))}
  101. </div>
  102. {/* 加载进度条 */}
  103. {loding >= 100 ? null : (
  104. <div className='A22xian'>
  105. <div>
  106. <div style={{ width: loding + '%' }}></div>
  107. </div>
  108. </div>
  109. )}
  110. </div>
  111. {/* 右下角按钮 */}
  112. <FloorBtn
  113. gameFu={
  114. panoShow
  115. ? () => {
  116. history.push('/unend/game3')
  117. }
  118. : undefined
  119. }
  120. />
  121. <CatVideo
  122. isShow={panoShow}
  123. src={baseURL + myData.visit2.进入院落}
  124. parentFu={() => domDelOwnFu('#CatVideo')}
  125. />
  126. {/* 全景图页面 */}
  127. <div className='A22Pano' style={{ opacity: panoShow ? '1' : '0' }}>
  128. <A22Pano />
  129. {/* 进入室内 */}
  130. <NextPage clickSon={() => setToShi(true)} txt='进入室内' />
  131. {/* 底部按钮 */}
  132. <div
  133. onClick={() => setBaiXi(true)}
  134. className='A22Pbtn'
  135. style={{ backgroundImage: `url(${baseURL}chef/chuBtn.png)` }}
  136. >
  137. 观看百戏
  138. </div>
  139. </div>
  140. {/* 室外看百戏 */}
  141. <div
  142. className='A22baiXi'
  143. style={{
  144. opacity: baiXi ? '1' : '0',
  145. pointerEvents: baiXi ? 'auto' : 'none',
  146. backgroundImage: `url(${baseURL + myData.visit2.baiXiBg})`
  147. }}
  148. >
  149. {/* 进入室内 */}
  150. <NextPage clickSon={() => setToShi(true)} txt='进入室内' />
  151. {/* 百戏底部按钮 */}
  152. <div className='pvfloor'>
  153. {myData.visit2.baixiArr.map((item, index) => (
  154. <div
  155. key={index}
  156. onClick={() => {
  157. setXiAc(item)
  158. setTimeout(() => {
  159. const doms: any = document.querySelectorAll('.A22Bvideo')
  160. if (doms) {
  161. doms.forEach((v: HTMLVideoElement, i: number) => {
  162. if (index === i) v.play()
  163. else {
  164. v.pause()
  165. v.currentTime = 0
  166. }
  167. })
  168. }
  169. }, 100)
  170. }}
  171. className={classNames('pvflRow', xiAc === item ? 'pvflRowAc' : '')}
  172. >
  173. {/* 蒙版 */}
  174. <div className='pvflR1'></div>
  175. {/* 底图 */}
  176. <div className='pvflR2'>
  177. <img src={`${baseURL}visit2/${item}.png`} alt='' />
  178. </div>
  179. {/* 文字 */}
  180. <div className='pvflR3'>{item}</div>
  181. </div>
  182. ))}
  183. </div>
  184. {myData.visit2.baixiArr.map(item => (
  185. // 5个视频
  186. <div
  187. className='A22BvideoBox'
  188. key={item}
  189. style={{
  190. opacity: xiAc === item ? '1' : '0',
  191. pointerEvents: xiAc === item ? 'auto' : 'none'
  192. }}
  193. >
  194. <video
  195. className='A22Bvideo'
  196. playsInline
  197. muted
  198. webkit-playsinline='true'
  199. x5-video-player-type='h5'
  200. loop={true}
  201. >
  202. <source type='video/mp4' src={`${baseURL}visit2/${item}.mp4`} />
  203. Your browser does not support the video tag.
  204. </video>
  205. </div>
  206. ))}
  207. <BtnRight
  208. title='返回'
  209. clickSon={() => {
  210. setBaiXi(false)
  211. setXiAc('')
  212. }}
  213. imgName='back'
  214. />
  215. </div>
  216. {/* 最后的视频 */}
  217. <EndVideo
  218. lastVideo={toShi}
  219. src={baseURL + myData.visit2.进入室内}
  220. path='/banquet'
  221. delDom='.A22Pano'
  222. />
  223. </div>
  224. )
  225. }
  226. const MemoA2visit2 = React.memo(A2visit2)
  227. export default MemoA2visit2