|
@@ -1,16 +1,22 @@
|
|
|
-import React, { useCallback, useMemo, useState } from 'react'
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { baseURL, isPc, myData } from '@/utils/http'
|
|
|
import HotIcon from '@/components/HotIcon'
|
|
|
import history from '@/utils/history'
|
|
|
+import { renClickPageFu } from '../data'
|
|
|
+import classNames from 'classnames'
|
|
|
+import { RenListType } from '../type'
|
|
|
+
|
|
|
+const tabArr: ('场景' | '人物')[] = ['场景', '人物']
|
|
|
|
|
|
type Props = {
|
|
|
hidden: boolean
|
|
|
+ setLastVideo: (info: any) => void
|
|
|
}
|
|
|
|
|
|
const data = myData.more['探索庄园']
|
|
|
|
|
|
-function S1manor({ hidden }: Props) {
|
|
|
+function S1manor({ hidden, setLastVideo }: Props) {
|
|
|
const [adInd, setAcInd] = useState(0)
|
|
|
|
|
|
const hotInfo = useMemo(() => {
|
|
@@ -23,6 +29,52 @@ function S1manor({ hidden }: Props) {
|
|
|
else setAcInd(index)
|
|
|
}, [])
|
|
|
|
|
|
+ // 场景和人物的切换
|
|
|
+ const [tab, setTab] = useState<'场景' | '人物'>(renClickPageFu() === '0' ? '人物' : '场景')
|
|
|
+
|
|
|
+ const renArr = useMemo(() => {
|
|
|
+ const arr: RenListType[] = []
|
|
|
+
|
|
|
+ const arrTemp = myData.more['汉代百科']['人'].skArr
|
|
|
+
|
|
|
+ arrTemp.forEach(v1 => {
|
|
|
+ v1.son.forEach(v2 => {
|
|
|
+ if (!v2.noShow) {
|
|
|
+ arr.push(v2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ // 器具连连看
|
|
|
+ arr.push({
|
|
|
+ name: '宴饮',
|
|
|
+ imgSrc: 'more/ren/lianLianKan.jpg',
|
|
|
+ path: '/unend/game1?r=ren',
|
|
|
+ pagetop: '30%',
|
|
|
+ pageLeft: '47%',
|
|
|
+ zIndex: 5
|
|
|
+ })
|
|
|
+
|
|
|
+ return arr
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ // 人---------------
|
|
|
+ // 一级选中
|
|
|
+ const [renAc1, setRenAc1] = useState('庄园主')
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (renSorrlRef.current) {
|
|
|
+ renSorrlRef.current.scrollTo({ top: 0, behavior: 'smooth' })
|
|
|
+ }
|
|
|
+ }, [renAc1])
|
|
|
+
|
|
|
+ // 一级选中的数据
|
|
|
+ const renAcData = useMemo(() => {
|
|
|
+ return myData.more.汉代百科.人.skArr.find(v => v.name === renAc1)!.son
|
|
|
+ }, [renAc1])
|
|
|
+
|
|
|
+ const renSorrlRef = useRef<HTMLDivElement>(null)
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
hidden={hidden}
|
|
@@ -30,7 +82,11 @@ function S1manor({ hidden }: Props) {
|
|
|
style={{ backgroundImage: `url(${baseURL + data.bg})` }}
|
|
|
>
|
|
|
{/* 左侧图标 */}
|
|
|
- <div className='S1left' style={{ backgroundImage: `url(${baseURL}more/s1Zhe.png)` }}>
|
|
|
+ <div
|
|
|
+ className='S1left'
|
|
|
+ hidden={tab === '人物'}
|
|
|
+ style={{ backgroundImage: `url(${baseURL}more/s1Zhe.png)` }}
|
|
|
+ >
|
|
|
<img className='SlL1' src={baseURL + hotInfo.leftImg} alt='' />
|
|
|
|
|
|
<div className='SlL2' onClick={() => history.push(hotInfo.path)}>
|
|
@@ -39,7 +95,7 @@ function S1manor({ hidden }: Props) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div className='S1hotBox'>
|
|
|
+ <div className='S1hotBox' hidden={tab === '人物'}>
|
|
|
{data.hot.map((item, index) => (
|
|
|
// 热点图标
|
|
|
<HotIcon
|
|
@@ -59,6 +115,95 @@ function S1manor({ hidden }: Props) {
|
|
|
/>
|
|
|
))}
|
|
|
</div>
|
|
|
+
|
|
|
+ {/* 右侧tab */}
|
|
|
+ <div className='S1tab'>
|
|
|
+ {tabArr.map(v => (
|
|
|
+ <div onClick={() => setTab(v)} className={classNames(tab === v ? 'S1tabAc' : '')} key={v}>
|
|
|
+ {v}
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 人物左侧列表 */}
|
|
|
+ <div
|
|
|
+ className='S1renList'
|
|
|
+ hidden={tab === '场景'}
|
|
|
+ style={{ backgroundImage: `url(${baseURL}more/s1Zhe.png)` }}
|
|
|
+ >
|
|
|
+ {/* 人------------- */}
|
|
|
+ <div className='S2renBox'>
|
|
|
+ {/* 左侧 */}
|
|
|
+ <div className='S2renBox1'>
|
|
|
+ {myData.more.汉代百科.人.skArr.map((item, index) => (
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ backgroundImage: `url(${baseURL}plow/left${
|
|
|
+ renAc1 === item.name ? 'Ac2' : ''
|
|
|
+ }.png)`,
|
|
|
+ color: renAc1 === item.name ? '#EACF60' : '#DACB8B'
|
|
|
+ }}
|
|
|
+ key={index}
|
|
|
+ className='S2renRow'
|
|
|
+ onClick={() => setRenAc1(item.name)}
|
|
|
+ >
|
|
|
+ {item.name}
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 右侧图文信息 */}
|
|
|
+ <div className='S2renBox2'>
|
|
|
+ <div
|
|
|
+ className='mySorrl'
|
|
|
+ ref={renSorrlRef}
|
|
|
+ style={{
|
|
|
+ display: renAcData.length < 4 ? 'flex' : 'block',
|
|
|
+ paddingBottom: renAcData.length < 4 ? '30px' : '0'
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {renAcData.map((item, index) => (
|
|
|
+ <div
|
|
|
+ className='S2ren2Row'
|
|
|
+ key={index}
|
|
|
+ onClick={() => {
|
|
|
+ const path = item.path.includes('?r=') ? item.path + '0' : item.path
|
|
|
+ if (item.videoSrc) {
|
|
|
+ setLastVideo({ src: item.videoSrc, path: path })
|
|
|
+ } else history.push(path)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <img src={baseURL + item.imgSrc} alt='' />
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className='S1hotBox' hidden={tab === '场景'}>
|
|
|
+ {renArr.map((item, index) => (
|
|
|
+ // 热点图标
|
|
|
+ <HotIcon
|
|
|
+ isModel={false}
|
|
|
+ key={index}
|
|
|
+ index={index}
|
|
|
+ zIndex={item.zIndex ? item.zIndex : 1}
|
|
|
+ clickSon={() => {
|
|
|
+ const path = item.path.includes('?r=') ? item.path + '0' : item.path
|
|
|
+ if (item.videoSrc) {
|
|
|
+ setLastVideo({ src: item.videoSrc, path: path })
|
|
|
+ } else history.push(path)
|
|
|
+ }}
|
|
|
+ isXiao={0.6}
|
|
|
+ hoverSrc={item.imgSrc.replace('ren/', 'ren/tag_').replace('.jpg', '.png')}
|
|
|
+ style={{
|
|
|
+ top: item.pagetop,
|
|
|
+ left: item.pageLeft
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
)
|
|
|
}
|