import React, { useCallback, useMemo, useState } from 'react' import styles from './index.module.scss' import BaseImg from '@/components/BaseImg' import { baseURL, myData } from '@/utils/http' import EndVideo from '@/components/EndVideo' import NextPage from '@/components/NextPage' import classNames from 'classnames' import FloorBtn from '@/components/FloorBtn' import HotIcon from '@/components/HotIcon' import Hot2 from '../A2visit/PanoVideo/Hot2' import { PlowHotType } from '@/types' import useLoding from '@/components/ownUse/useLoding' function A6plow() { // 初始显示和隐藏 const [cutVideoShow, setCutVideoShow] = useState(false) // 控制视频播放的方法 const videoPlayFu = useCallback((index: number) => { setTimeout(() => { const domAll: any = document.querySelectorAll('.A6video') if (domAll && domAll.length) { domAll.forEach((v: HTMLVideoElement, i: number) => { if (index === i) v.play() else { v.pause() v.currentTime = 0 } }) } }, 100) }, []) // 点击继续 const btnStart = useCallback(() => { setCutVideoShow(true) // 播放第一个整地的视频 videoPlayFu(0) }, [videoPlayFu]) // 点击 跳下一个章节 const [lastVideo, setLastVideo] = useState(false) // 左侧按钮的选中 const [leftAc, setLeftAc] = useState(0) const leftAcFu = useCallback( (index: number) => { videoPlayFu(index) setLeftAc(index) }, [videoPlayFu] ) // 底部文字 const floorTxt = useMemo(() => { return myData.plow.info[leftAc].txt }, [leftAc]) // 打开热点 const [hotInd, setHotInd] = useState(-1) const hotInfo = useMemo(() => { let info = {} as PlowHotType const temp = myData.plow.info[leftAc].hot if (temp && temp[hotInd]) { info = temp[hotInd] } return info }, [hotInd, leftAc]) // 先加载背景图 序列帧等 在加载视频 const { imgNow, imgNumFu } = useLoding(3) return (
{/* 初始静态图 */} btnStart()} bgImg={`${baseURL}${myData.plow.baseImg}`} imgNow={imgNow} imgNumFu={imgNumFu} /> {/* 主要内容 */} {imgNow ? (
{/* 左侧title */}
{myData.plow.info.map((item, index) => (
leftAcFu(index)} style={{ backgroundImage: `url(${baseURL}plow/left${leftAc === index ? 'Ac' : ''}.png)`, color: leftAc === index ? '#BD7656' : '#DACB8B' }} > {item.name}
))}
{/* 底部文字 */}
{/* 视频加热点 */}
{myData.plow.info.map((item, index) => (
{/* 热点 */} {item.hot.map((v: PlowHotType, i) => ( setHotInd(val)} hoverSrc={v.hoverSrc} /> ))}
))}
{/* 跳到下一章 */} setLastVideo(true)} txt='结束宴饮' /> {/* 右下角按钮 */}
) : null} {hotInd >= 0 && hotInfo.name ? ( setHotInd(-1)} name={hotInfo.name} /> ) : null} {/* 结尾动画 */} {imgNow ? ( ) : null}
) } const MemoA6plow = React.memo(A6plow) export default MemoA6plow