|
@@ -1,19 +1,143 @@
|
|
|
-import React from 'react'
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import useDataUrl from '@/components/ownUse/useDataUrl'
|
|
|
import { myData } from '@/utils/http'
|
|
|
+import history from '@/utils/history'
|
|
|
+import classNames from 'classnames'
|
|
|
+import B3txt from './B3txt'
|
|
|
+
|
|
|
function B3yun() {
|
|
|
const { dataUrlSame } = useDataUrl()
|
|
|
+
|
|
|
+ // 一级图标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('')
|
|
|
+ }, 4000)
|
|
|
+ },
|
|
|
+ [hotArr]
|
|
|
+ )
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ console.log('---', ac2)
|
|
|
+ }, [ac2])
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
className={styles.B3yun}
|
|
|
style={{ backgroundImage: `url(${dataUrlSame + myData.yun.bjImg})` }}
|
|
|
>
|
|
|
{/* 左侧主体 */}
|
|
|
- <div className='yunll'></div>
|
|
|
+ <div className='yunll' style={{ pointerEvents: ac2 ? 'none' : 'auto' }}>
|
|
|
+ {/* 主要 */}
|
|
|
+ <div className='yunllCon'>
|
|
|
+ <div
|
|
|
+ className='yunll1'
|
|
|
+ style={{ backgroundImage: `url(${dataUrlSame}yun/di.jpg)`, transform: imgChange }}
|
|
|
+ >
|
|
|
+ {/* 高亮白色盒子 */}
|
|
|
+ {ac1 > 0 && !ac2 ? (
|
|
|
+ <div
|
|
|
+ style={{ backgroundImage: `url(${dataUrlSame}yun/liang${ac1}.png)` }}
|
|
|
+ className='yunll1Ac'
|
|
|
+ >
|
|
|
+ {/* 点 */}
|
|
|
+ {hotArr.map(v => (
|
|
|
+ <div
|
|
|
+ className='yunDian'
|
|
|
+ onClick={() => setAc2Fu(v.id)}
|
|
|
+ key={v.id}
|
|
|
+ style={{ top: v.loc.top, left: v.loc.left }}
|
|
|
+ >
|
|
|
+ <img src={`${dataUrlSame}yun/hot.png`} alt='' />
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+
|
|
|
+ {/* 二级别高亮 */}
|
|
|
+
|
|
|
+ <div className={classNames('yunAc2Box', ac2 ? 'yunAc2BoxAc' : '')}>
|
|
|
+ {ac2 ? <img className='yunShan' src={`${dataUrlSame}yun/${ac2}.png`} alt='' /> : null}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* {ac1 > 0 && ac2 ? <div className=''></div> : null} */}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className='yunll2'>
|
|
|
+ {myData.yun.iconArr.map(item => (
|
|
|
+ <div
|
|
|
+ onClick={() => setAc1(item.id)}
|
|
|
+ className={classNames('yunll2Row', ac1 === item.id ? 'yunll2RowAc' : '')}
|
|
|
+ key={item.id}
|
|
|
+ title={item.title}
|
|
|
+ ></div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
{/* 右侧文字 */}
|
|
|
- <div className='yunrr'></div>
|
|
|
+ <div className='yunrr' style={{ pointerEvents: ac2 ? 'none' : 'auto' }}>
|
|
|
+ <div className='yunrr1'>
|
|
|
+ <h2>{myData.yun.name}</h2>
|
|
|
+ <div style={{ backgroundImage: `url(${dataUrlSame}yun/titLiang.png)` }}>
|
|
|
+ {myData.yun.tit}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className='yunrr2'>
|
|
|
+ <div>
|
|
|
+ <B3txt ac1={ac1} ac2={ac2} setAc2Fu={val => setAc2Fu(val)} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 右下角的图标 */}
|
|
|
+ <div className='yunBtn'>
|
|
|
+ <div className='yunBtn1' title='仙居世界' onClick={() => history.push('/hots')}></div>
|
|
|
+ <div className='yunBtn2' title='返回' onClick={() => history.go(-1)}></div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
)
|
|
|
}
|