index.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import BaseImg from '@/components/BaseImg'
  4. import { baseURL, myData } from '@/utils/http'
  5. import useLoding from '@/components/ownUse/useLoding'
  6. import CatVideo from '@/components/CatVideo'
  7. import A6PanoVideo from './A6PanoVideo'
  8. import classNames from 'classnames'
  9. import { domDelOwnFu } from '@/utils/utilsSome'
  10. import FloorBtn from '@/components/FloorBtn'
  11. import NextPage from '@/components/NextPage'
  12. import EndVideo from '@/components/EndVideo'
  13. import history from '@/utils/history'
  14. import HotIcon from '@/components/HotIcon'
  15. import Hot2 from '../A2visit/PanoVideo/Hot2'
  16. function A6xian() {
  17. // 过度动画
  18. const [cutVideoShow, setCutVideoShow] = useState(false)
  19. // 点击 跳下一个章节
  20. const [lastVideo, setLastVideo] = useState(false)
  21. // 点击继续
  22. const btnStart = useCallback(() => {
  23. setCutVideoShow(true)
  24. }, [])
  25. // 过度动画播放完毕或者点击跳过
  26. const cutEndFu = useCallback(() => {
  27. setCutVideoShow(false)
  28. }, [])
  29. // 先加载背景图 序列帧等 在加载视频
  30. const { imgNow, imgNumFu } = useLoding(3)
  31. // 点击升仙
  32. const [xianShow, setXianShow] = useState(window.location.href.includes('t=xian') ? true : false)
  33. // 滚动
  34. const [isFlag, setIsFlag] = useState(false)
  35. const xianRef = useRef<HTMLDivElement>(null)
  36. const mousemoveFu = useCallback(
  37. (ev: any, flag?: boolean) => {
  38. if (xianRef.current) {
  39. if (flag && !isFlag) {
  40. const nowMove = xianRef.current.scrollLeft
  41. // 滚轮
  42. let num = 50
  43. if (ev.deltaY < 0) num = -num
  44. xianRef.current.scrollLeft = nowMove + num
  45. } else if (isFlag) {
  46. const nowMove = xianRef.current.scrollLeft
  47. // 鼠标按住移动
  48. xianRef.current.scrollLeft = nowMove - ev.movementX
  49. }
  50. }
  51. },
  52. [isFlag]
  53. )
  54. const videoRef = useRef<HTMLVideoElement>(null)
  55. useEffect(() => {
  56. if (window.location.href.includes('t=xian')) {
  57. setTimeout(() => {
  58. if (videoRef.current) videoRef.current.play()
  59. }, 100)
  60. }
  61. }, [])
  62. // 二级的静态图
  63. const [erImg, setErImg] = useState(false)
  64. // 打开热点
  65. const [acName, setAcName] = useState('')
  66. const hotInfo = useMemo(() => {
  67. return myData.xianJu.imgHot.find(v => v.name === acName)!
  68. }, [acName])
  69. return (
  70. <div className={styles.A6xian}>
  71. {/* 初始静态图 */}
  72. <BaseImg
  73. hidden={window.location.href.includes('t=xian')}
  74. isShow={cutVideoShow}
  75. iconSrc={`${baseURL}xianJu/mulu.png`}
  76. parentFu={() => setErImg(true)}
  77. bgImg={`${baseURL}${myData.xianJu.bgImg}`}
  78. imgNow={imgNow}
  79. imgNumFu={imgNumFu}
  80. num={50}
  81. />
  82. {/* 二级静态图 */}
  83. <div
  84. className='A6erImg'
  85. style={{ opacity: erImg ? '1' : '0', pointerEvents: erImg ? 'auto' : 'none' }}
  86. >
  87. <img src={baseURL + 'xianJu/erImg.jpg'} alt='' />
  88. {/* 热点 */}
  89. {myData.xianJu.imgHot.map((v, i) => (
  90. <HotIcon
  91. isModel={v.isModel ? true : false}
  92. style={{
  93. top: v.loc.top,
  94. left: v.loc.left
  95. }}
  96. key={i}
  97. index={i}
  98. clickSon={() => setAcName(v.name)}
  99. hoverSrc={v.hoverSrc}
  100. isXiao={0.67}
  101. />
  102. ))}
  103. {/* 底部按钮 */}
  104. <div
  105. className='A6erImgBtn'
  106. onClick={() => {
  107. domDelOwnFu('.A6erImg')
  108. btnStart()
  109. }}
  110. >
  111. 开始冥想
  112. </div>
  113. {acName ? (
  114. <Hot2 data={hotInfo.data} closeFu={() => setAcName('')} name={hotInfo.name} />
  115. ) : null}
  116. </div>
  117. {/* 过度动画页面 */}
  118. {imgNow ? (
  119. <CatVideo
  120. isShow={cutVideoShow}
  121. src={baseURL + myData.xianJu.videos[0]}
  122. parentFu={() => cutEndFu()}
  123. />
  124. ) : null}
  125. {/* 全景视频 */}
  126. {imgNow && !window.location.href.includes('t=xian') ? (
  127. <div className={classNames('pvBox', cutVideoShow ? '' : 'pvBoxShow')}>
  128. <A6PanoVideo />
  129. <div
  130. className='pvBtn'
  131. onClick={() => {
  132. domDelOwnFu('.pvBox')
  133. setXianShow(true)
  134. setTimeout(() => {
  135. if (videoRef.current) videoRef.current.play()
  136. }, 100)
  137. }}
  138. >
  139. 升仙之途
  140. </div>
  141. </div>
  142. ) : null}
  143. {/* 点击升仙之途 出来的长 滚动 页面 */}
  144. {imgNow || window.location.href.includes('t=xian') ? (
  145. <div
  146. className='A6XimgBox'
  147. style={{ opacity: xianShow ? '1' : '0', pointerEvents: xianShow ? 'auto' : 'none' }}
  148. >
  149. <div
  150. className='A6XimgBoxSon'
  151. style={{ cursor: isFlag ? 'move' : 'default' }}
  152. ref={xianRef}
  153. onMouseDown={() => setIsFlag(true)}
  154. onMouseUp={() => setIsFlag(false)}
  155. onMouseLeave={() => setIsFlag(false)}
  156. onMouseMove={e => mousemoveFu(e)}
  157. onWheel={e => mousemoveFu(e, true)}
  158. >
  159. <video
  160. ref={videoRef}
  161. playsInline
  162. muted
  163. webkit-playsinline='true'
  164. x5-video-player-type='h5'
  165. loop={true}
  166. >
  167. <source type='video/mp4' src={`${baseURL}xianJu/chang.mp4`} />
  168. Your browser does not support the video tag.
  169. </video>
  170. </div>
  171. {/* 跳到下一章 */}
  172. <NextPage clickSon={() => setLastVideo(true)} txt='结束冥想' />
  173. {/* 右下角按钮 */}
  174. <FloorBtn />
  175. {/* 底部按钮 */}
  176. <div className='A6XimgBoxBtn'>
  177. <div onClick={() => history.push('/xian?t=xian')}>卜千秋墓中的升仙图</div>
  178. <div onClick={() => history.push('/yun?t=xian')}>四神云气图</div>
  179. </div>
  180. </div>
  181. ) : null}
  182. {/* 最后的视频 */}
  183. <EndVideo
  184. lastVideo={lastVideo}
  185. src={baseURL + 'xianJu/end.mp4'}
  186. path='/end'
  187. delDom='.A22Pano'
  188. />
  189. </div>
  190. )
  191. }
  192. const MemoA6xian = React.memo(A6xian)
  193. export default MemoA6xian