index.tsx 7.7 KB

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