import React, { useCallback, useEffect, useRef, useState } from 'react' import styles from './index.module.scss' import useDataUrl from '@/components/ownUse/useDataUrl' // import useMove from '@/components/ownUse/useMove' import { myData } from '@/utils/http' import classNames from 'classnames' import { domDelOwnFu } from '@/utils/utilsSome' import EndVideo from '@/components/EndVideo' function A1home() { const { dataUrlSame } = useDataUrl() // const { touchstart, touchmove, touchend } = useMove() // 动画视频的ref const videoRef = useRef(null) const [loding, setLoding] = useState(myData.isLdong ? 0 : 100) const timeRR = useRef(-1) useEffect(() => { clearInterval(timeRR.current) timeRR.current = window.setInterval(() => { if (loding >= 100) { setMoveImgShow(false) setTimeout(() => { const ruDom = document.querySelector('#myStyle') if (ruDom) ruDom.remove() }, 3000) clearInterval(timeRR.current) return } setLoding(loding + 1) }, 50) }, [loding]) // 点击开始 const btnStartFu = useCallback(() => { setLoding(110) // 自动播放视频 setTimeout(() => { if (videoRef.current) { videoRef.current.play() } }, 100) // 0.5s之后删除自己 setTimeout(() => { domDelOwnFu('.A1base') }, 500) }, []) const [ind, setInd] = useState(0) // 向上滑动 const videoEndFu = useCallback( (num: number) => { // 这个页面只能向上滑 if (num === -1) return if (ind === myData.home.videos.length - 1 && num === 1) return setInd(ind + num) }, [ind] ) useEffect(() => { if (ind !== 0) { setTimeout(() => { const domAll: any = document.querySelectorAll('.A1videoBoxSon video') if (domAll && domAll.length) { domAll.forEach((v: HTMLVideoElement, i: number) => { if (ind === i) v.play() else v.pause() }) } }, 100) } }, [ind]) // 最后一个过长动画 const [lastVideo, setLastVideo] = useState(false) // 有关序列帧 const A1BfloorRef = useRef(null) const [moveImgShow, setMoveImgShow] = useState(true) useEffect(() => { // 看看是否已经插入的 script const ruDom = document.querySelector('#myStyle') if (ruDom) ruDom.remove() const styleStr = `.A1Bll { animation: A1BllMove1 8s infinite linear; } @keyframes A1BllMove1 { 100% { left: 0; } } .A1Brr { animation: A1BllMove2 8s infinite linear; } @keyframes A1BllMove2 { 100% { right: 0; } ` const styletDom = document.createElement('style') styletDom.type = 'text/css' styletDom.id = 'myStyle' styletDom.innerHTML = styleStr document.querySelector('html')?.appendChild(styletDom) }, []) return (
{/* 初始加载画面 */}
{loding >= 100 ? (
开始
) : (
{loding}%
)} {/* 序列帧动画 */} {/* 底部颜色条 */} {/* 底部房子 */} {/* 左右小人 */}
{/* 5个动画视频 */}
{myData.home.videos.map((url, index) => (
))}
{/* 操作按钮 */} {loding !== 110 || lastVideo ? null : (
touchstart(e.touches[0].pageY)} // onTouchMove={e => touchmove(e.touches[0].pageY)} // onTouchEnd={() => touchend(val => videoEndFu(val), 'mobile')} // onMouseDown={e => touchstart(e.pageY)} // onMouseMove={e => touchmove(e.pageY)} // onMouseUp={() => touchend(val => videoEndFu(val), 'pc')} > videoEndFu(1)} src={`${dataUrlSame}home/next.png`} alt='' />
setLastVideo(true)}>

点击开始

)} {/* 最后一个过长动画 */}
) } const MemoA1home = React.memo(A1home) export default MemoA1home