import React, { useCallback, useEffect, useRef, useState } from 'react' import styles from './index.module.scss' import useDataUrl from '@/components/ownUse/useDataUrl' import classNames from 'classnames' import { myData } from '@/utils/http' import { domDelOwnFu } from '@/utils/utilsSome' import history from '@/utils/history' import { ArrowRightOutlined } from '@ant-design/icons' function A5chef() { const { dataUrlSame } = useDataUrl() const [loding, setLoding] = useState(myData.isLdong ? 0 : 100) const timeRR = useRef(-1) useEffect(() => { clearInterval(timeRR.current) timeRR.current = window.setInterval(() => { if (loding >= 100) { clearInterval(timeRR.current) return } setLoding(loding + 1) }, 30) }, [loding]) // 点击继续 const [baseFlag, setBaseFlag] = useState(true) const btnStart = useCallback(() => { if (loding >= 100) { setBaseFlag(false) // 0.5s之后删除初始盒子 setTimeout(() => { domDelOwnFu('.A5base') }, 500) } }, [loding]) // 点击 跳下一个章节 const [lastVideo, setLastVideo] = useState(false) const videoRefLast = useRef(null) const lastVideoFu = useCallback(() => { setLastVideo(true) setTimeout(() => { if (videoRefLast.current) { videoRefLast.current.play() } }, 100) }, []) // 点击后厨群像 const [chuShow, setChuShow] = useState(false) // 点击热点 const [hotInd, setHotInd] = useState(-1) const hotTime = useRef(-1) const hotIndFu = useCallback((index: number) => { setBgMove(myData.chef.hot[index].change) clearTimeout(hotTime.current) hotTime.current = window.setTimeout(() => { setHotInd(index) }, 500) }, []) useEffect(() => { if (hotInd === -1) setBgMove('') setTimeout(() => { const videoDomAll: any = document.querySelectorAll('.A5video video') videoDomAll.forEach((v: HTMLVideoElement, index: number) => { if (hotInd === index) { v.currentTime = 0 v.play() } else v.pause() }) }, 100) }, [hotInd]) const hotAcRef = useRef(null) // 热点位移 const [bgMove, setBgMove] = useState('') return (
{/* 整体盒子 */}
{/* 加载页面 */}
{/* anpg动图 */}
{loding >= 100 ? '点击继续' : '加载中'}
{loding >= 100 ? null : (
)}
{/* 热点按钮页面 */}
{/* 循环渲染热点 */} {myData.chef.hot.map((item, index) => (
hotIndFu(index)} key={index} className='pvHot' style={{ top: item.loc.top, left: item.loc.left }} >
))} {/* 后厨群像 */}
{/* 返回按钮 */}
setChuShow(false)} >
setChuShow(true)} className='A5chuBtn' style={{ backgroundImage: `url(${dataUrlSame}chef/chuBtn.png)` }} > 后厨群像
{/* 跳到下一章 */}
田间耕作
{/* 更多 跳新页面 */}
history.push('/more')}>
{/* 点击热点之后出来的视频 */} {myData.chef.hot.map((item, index) => (
{/* 热点右侧图文信息 */}
{/* 返回按钮 */}
setHotInd(-1)} >
))} {/* 最后一个过长动画 */}
) } const MemoA5chef = React.memo(A5chef) export default MemoA5chef