index.tsx 8.1 KB

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