import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import styles from './index.module.scss' import { baseURL, myData } from '@/utils/http' import history from '@/utils/history' import classNames from 'classnames' import B3txt from './B3txt' import useLoding from '@/components/ownUse/useLoding' function B3yun() { // 一级图标id const [ac1, setAc1] = useState(0) useEffect(() => { ac2FlagRef.current = true setAc2('') }, [ac1]) // 热点点位数组 const hotArr = useMemo(() => { if (myData.yun.iconArr[ac1 - 1]) return myData.yun.iconArr[ac1 - 1].dian || [] else return [] }, [ac1]) // 是否进入二级状态 const ac2Time = useRef(-1) const ac2FlagRef = useRef(true) const [ac2, setAc2] = useState('') // 图片的放大和位移 const [imgChange, setImgChange] = useState('') const setAc2Fu = useCallback( (id: string) => { if (!ac2FlagRef.current) return setAc2(id) // 控制图片放大 const chage = hotArr.find(v => v.id === id)?.change if (chage) setImgChange(chage) // else setImgChange('') ac2FlagRef.current = false clearTimeout(ac2Time.current) ac2Time.current = window.setTimeout(() => { ac2FlagRef.current = true setImgChange('') setAc2('') }, 3000) }, [hotArr] ) // 先加载背景图 序列帧等 在加载视频 const { imgNow, imgNumFu } = useLoding(2) return (
{/* 左侧主体 */}
{/* 主要 */}
{/* 高亮白色盒子 */} {ac1 > 0 && imgNow ? (
{/* 点 */} {hotArr.map(v => (
setAc2Fu(v.id)} key={v.id} style={{ top: v.loc.top, left: v.loc.left }} >
))}
) : null} {/* 二级别高亮 */} {imgNow ? (
{ac2 ? : null}
) : null} {/* {ac1 > 0 && ac2 ?
: null} */}
{imgNow ? (
{myData.yun.iconArr.map(item => (
setAc1(item.id)} className={classNames('yunll2Row', ac1 === item.id ? 'yunll2RowAc' : '')} key={item.id} title={item.title} >
))}
) : null}
{/* 右侧文字 */} {imgNow ? (

{myData.yun.name}

{myData.yun.tit}
setAc2Fu(val)} />
) : null} {/* 右下角的图标 */} {imgNow ? (
history.push('/hots')}>
history.go(-1)}>
) : null}
) } const MemoB3yun = React.memo(B3yun) export default MemoB3yun