|
|
@@ -12,6 +12,11 @@ function Appreciate({
|
|
|
}) {
|
|
|
const [currentIndex, setCurrentIndex] = useState<number | undefined>(undefined)
|
|
|
const [isShowInfo, setIsShowInfo] = useState<boolean>(true)
|
|
|
+ const [oreData1, setOreData1] = useState(oreData)
|
|
|
+ const [searchText, setSearchText] = useState('')
|
|
|
+ const [textureFilter, setTextureFilter] = useState('all')
|
|
|
+ const [typeFilter, setTypeFilter] = useState('all')
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (currentIndex !== undefined) {
|
|
|
setHidenComplete(true)
|
|
|
@@ -21,39 +26,64 @@ function Appreciate({
|
|
|
|
|
|
}, [currentIndex, setHidenComplete])
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ let filteredData = oreData;
|
|
|
+ if (textureFilter !== 'all') {
|
|
|
+ filteredData = filteredData.filter(item => item.texture === textureFilter);
|
|
|
+ }
|
|
|
+ if (typeFilter !== 'all') {
|
|
|
+ filteredData = filteredData.filter(item => item.type === typeFilter);
|
|
|
+ }
|
|
|
+ filteredData = filteredData.filter(item => item.title.includes(searchText));
|
|
|
+ setOreData1(filteredData);
|
|
|
+ }, [searchText, textureFilter, typeFilter]);
|
|
|
|
|
|
return (
|
|
|
<div className={styles.Appreciate} style={style}>
|
|
|
<div className='top_A'>
|
|
|
{isMobileFu() && <div className="txt_A">文物赏析</div>}
|
|
|
<div className='search'>
|
|
|
- <input type='text' placeholder='请输入要查找的文字信息' />
|
|
|
+ <input type='text' value={searchText} onChange={e => setSearchText(e.target.value)} placeholder='请输入要查找的文字信息' />
|
|
|
<img src={require('@/assets/img/search.png')} alt='' />
|
|
|
</div>
|
|
|
<div className='texture'>
|
|
|
<div className='label'>质地:</div>
|
|
|
<Select
|
|
|
- defaultValue='lucy'
|
|
|
+ defaultValue={textureFilter}
|
|
|
+ options={[
|
|
|
+ { value: 'all', label: '全部' },
|
|
|
+ ...Array.from(new Set(oreData.map(item => item.texture)))
|
|
|
+ .map(texture => ({ value: texture, label: texture }))
|
|
|
+ ]}
|
|
|
+ onChange={value => setTextureFilter(value)}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='type'>
|
|
|
+ <div className='label'>文物类别:</div>
|
|
|
+ <Select
|
|
|
+ defaultValue={typeFilter}
|
|
|
options={[
|
|
|
- { value: 'lucy', label: 'Lucy' },
|
|
|
- { value: 'jack', label: 'Jack' }
|
|
|
+ { value: 'all', label: '全部' },
|
|
|
+ ...Array.from(new Set(oreData.map(item => item.type)))
|
|
|
+ .map(type => ({ value: type, label: type }))
|
|
|
]}
|
|
|
+ onChange={value => setTypeFilter(value)}
|
|
|
/>
|
|
|
</div>
|
|
|
- <div className='total'>文物总数:25件</div>
|
|
|
+ <div className='total'>文物总数:{oreData.length}件</div>
|
|
|
</div>
|
|
|
<div className='content'>
|
|
|
<div className="scroll">
|
|
|
- {[1, 2, 3, 4, 5, 6, 7, 8].map((item, index) => (
|
|
|
+ {oreData1.map((item, index) => (
|
|
|
<div
|
|
|
className={`item ${currentIndex === index ? 'active' : ''}`}
|
|
|
key={index}
|
|
|
onClick={() => setCurrentIndex(index)}
|
|
|
>
|
|
|
<div className='img'>
|
|
|
- <img src={require('@/assets/img/homeBg.png')} alt='' />
|
|
|
+ <img src={item.img} alt='' />
|
|
|
</div>
|
|
|
- <div className='txt'>掩护也会用户优化以后养护</div>
|
|
|
+ <div className='txt'>{item.title}</div>
|
|
|
</div>
|
|
|
))}
|
|
|
</div>
|
|
|
@@ -70,10 +100,10 @@ function Appreciate({
|
|
|
<img src={require(`@/assets/img/${isMobileFu() ? 'up' : 'left'}.png`)} alt='' />
|
|
|
</div>
|
|
|
<div className="content">
|
|
|
- <div className="title">鼻烟壶</div>
|
|
|
- <div className="time">年代:清</div>
|
|
|
- <div className="texture">质地:硬</div>
|
|
|
- <div className="size">尺寸:长120cm,宽60cm,高40cm,长120cm,宽60cm,高40cm,长120cm,宽60cm,高40cm,长120cm,宽60cm,高40cm</div>
|
|
|
+ <div className="title">{oreData1[currentIndex]?.title}</div>
|
|
|
+ <div className="time">年代:{oreData1[currentIndex]?.year}</div>
|
|
|
+ <div className="texture">质地:{oreData1[currentIndex]?.texture}</div>
|
|
|
+ <div className="size">尺寸:{oreData1[currentIndex]?.size}</div>
|
|
|
</div>
|
|
|
<div className="arrow arrowR" onClick={() => { isMobileFu() ? setIsShowInfo(false) : setIsShowInfo(true) }}>
|
|
|
<img src={require(`@/assets/img/${isMobileFu() ? 'down' : 'right'}.png`)} alt='' />
|