|
@@ -2,12 +2,12 @@ import { baseURL } from '@/utils/http'
|
|
import classNames from 'classnames'
|
|
import classNames from 'classnames'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
import logoImg from '@/assets/img/logo.png'
|
|
import logoImg from '@/assets/img/logo.png'
|
|
-import { Input, Pagination } from 'antd'
|
|
|
|
-import { SearchOutlined, UpOutlined, DownOutlined, ExclamationOutlined, CloseCircleOutlined } from '@ant-design/icons';
|
|
|
|
|
|
+import { Input, Pagination, Select } from 'antd'
|
|
|
|
+import { SearchOutlined, ExclamationOutlined, CloseCircleOutlined } from '@ant-design/icons';
|
|
import { useEffect, useRef, useState } from 'react'
|
|
import { useEffect, useRef, useState } from 'react'
|
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
-import { getListAction, getSortAction } from '@/store/action/home';
|
|
|
|
|
|
+import { getListAction, getSortAction, getAgeAction } from '@/store/action/home';
|
|
import { RootState } from '@/store';
|
|
import { RootState } from '@/store';
|
|
import Model from '@/components/Model'
|
|
import Model from '@/components/Model'
|
|
export default function Home() {
|
|
export default function Home() {
|
|
@@ -16,6 +16,7 @@ export default function Home() {
|
|
// 进页面获取后端文物数据
|
|
// 进页面获取后端文物数据
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
dispatch(getSortAction())
|
|
dispatch(getSortAction())
|
|
|
|
+ dispatch(getAgeAction())
|
|
}, [dispatch])
|
|
}, [dispatch])
|
|
|
|
|
|
// 滚动盒子ref
|
|
// 滚动盒子ref
|
|
@@ -30,7 +31,11 @@ export default function Home() {
|
|
setPageNum(1)
|
|
setPageNum(1)
|
|
const sroolDom = modelBoxRef.current
|
|
const sroolDom = modelBoxRef.current
|
|
sroolDom!.scrollTop = 0
|
|
sroolDom!.scrollTop = 0
|
|
- dispatch(getListAction({ ...fromData.current, dictTextureId: fromData.current.dictTextureId === -1 ? null : fromData.current.dictTextureId, searchKey: '', pageNum: 1 }))
|
|
|
|
|
|
+ dispatch(getListAction({
|
|
|
|
+ ...fromData.current, dictTextureId: fromData.current.dictTextureId === -1 ? null : fromData.current.dictTextureId,
|
|
|
|
+ searchKey: '', pageNum: 1,
|
|
|
|
+ dictAgeId: fromData.current.dictAgeId === -1 ? null : fromData.current.dictAgeId,
|
|
|
|
+ }))
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -41,18 +46,38 @@ export default function Home() {
|
|
getModelList()
|
|
getModelList()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// 分类的数据和高亮
|
|
// 分类的数据和高亮
|
|
- const { sortList, modelInfo } = useSelector((state: RootState) => state.homeStore)
|
|
|
|
|
|
+ const { sortList, modelInfo, ageList } = useSelector((state: RootState) => state.homeStore)
|
|
const { list, total } = modelInfo
|
|
const { list, total } = modelInfo
|
|
|
|
+
|
|
|
|
+ // 分类
|
|
const [sort, setSort] = useState(-1)
|
|
const [sort, setSort] = useState(-1)
|
|
- const [sortAll, setSortAll] = useState(false)
|
|
|
|
|
|
+ // 分类下拉框改变
|
|
|
|
+ const sortChangeFu = (value: number) => {
|
|
|
|
+ setSort(value)
|
|
|
|
+ }
|
|
|
|
+ // 年代
|
|
|
|
+ const [ageSerach, setAgeSerach] = useState(-1)
|
|
|
|
+ // 年代下拉框改变
|
|
|
|
+ const ageChangeFu = (value: number) => {
|
|
|
|
+ setAgeSerach(value)
|
|
|
|
+ fromData.current.dictAgeId = value
|
|
|
|
+ fromData.current.pageNum = 1
|
|
|
|
+ setPageNum(1)
|
|
|
|
+ getModelList()
|
|
|
|
+ }
|
|
|
|
+
|
|
const [pageNum, setPageNum] = useState(1)
|
|
const [pageNum, setPageNum] = useState(1)
|
|
|
|
|
|
|
|
+
|
|
const fromData = useRef({
|
|
const fromData = useRef({
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
pageSize: 30,
|
|
pageSize: 30,
|
|
searchKey: '',
|
|
searchKey: '',
|
|
- dictTextureId: -1
|
|
|
|
|
|
+ dictTextureId: -1,
|
|
|
|
+ dictAgeId: -1
|
|
})
|
|
})
|
|
const pageChangeFu = (page: number) => {
|
|
const pageChangeFu = (page: number) => {
|
|
fromData.current.pageNum = page
|
|
fromData.current.pageNum = page
|
|
@@ -63,7 +88,10 @@ export default function Home() {
|
|
const getModelList = () => {
|
|
const getModelList = () => {
|
|
const sroolDom = modelBoxRef.current
|
|
const sroolDom = modelBoxRef.current
|
|
sroolDom!.scrollTop = 0
|
|
sroolDom!.scrollTop = 0
|
|
- dispatch(getListAction({ ...fromData.current, dictTextureId: fromData.current.dictTextureId === -1 ? null : fromData.current.dictTextureId, searchKey: value }))
|
|
|
|
|
|
+ dispatch(getListAction({
|
|
|
|
+ ...fromData.current, dictTextureId: fromData.current.dictTextureId === -1 ? null : fromData.current.dictTextureId, searchKey: value,
|
|
|
|
+ dictAgeId: fromData.current.dictAgeId === -1 ? null : fromData.current.dictAgeId,
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
fromData.current.dictTextureId = sort
|
|
fromData.current.dictTextureId = sort
|
|
@@ -73,6 +101,15 @@ export default function Home() {
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [sort])
|
|
}, [sort])
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // useEffect(() => {
|
|
|
|
+ // fromData.current.dictAgeId = ageSerach
|
|
|
|
+ // fromData.current.pageNum = 1
|
|
|
|
+ // setPageNum(1)
|
|
|
|
+ // getModelList()
|
|
|
|
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
+ // }, [ageSerach])
|
|
|
|
+
|
|
// 点击每个模型出来的页面
|
|
// 点击每个模型出来的页面
|
|
const [modelId, setModelId] = useState(0)
|
|
const [modelId, setModelId] = useState(0)
|
|
|
|
|
|
@@ -92,39 +129,29 @@ export default function Home() {
|
|
</div>
|
|
</div>
|
|
<div className='mainBox'>
|
|
<div className='mainBox'>
|
|
|
|
|
|
- {/* 筛选的盒子 */}
|
|
|
|
|
|
+ {/* 筛选的盒子 */}
|
|
<div className='screenBox'>
|
|
<div className='screenBox'>
|
|
|
|
|
|
- {/* 输入框 */}
|
|
|
|
- <div className='search'>
|
|
|
|
- <div className='searchBtn' onClick={searchBtnFu}></div>
|
|
|
|
- {value.length > 0 ? (<div className='searchClear' onClick={clearValueFu}>
|
|
|
|
- <CloseCircleOutlined />
|
|
|
|
- </div>) : null}
|
|
|
|
|
|
+ {/* 输入框 */}
|
|
|
|
+ <div className='search'>
|
|
|
|
+ <div className='searchBtn' onClick={searchBtnFu}></div>
|
|
|
|
+ {value.length > 0 ? (<div className='searchClear' onClick={clearValueFu}>
|
|
|
|
+ <CloseCircleOutlined />
|
|
|
|
+ </div>) : null}
|
|
|
|
|
|
- <Input maxLength={10} placeholder='请输入文物名称' value={value} onChange={(e) => setValue(e.target.value)} onKeyUp={(e) => searchKeyUpFu(e)} prefix={<SearchOutlined />} />
|
|
|
|
- </div>
|
|
|
|
|
|
+ <Input maxLength={10} placeholder='请输入文物名称' value={value} onChange={(e) => setValue(e.target.value)} onKeyUp={(e) => searchKeyUpFu(e)} prefix={<SearchOutlined />} />
|
|
|
|
+ </div>
|
|
|
|
|
|
- {/* <div className='sortBox' style={{ height: sortAll ? '90px' : '46px' }}>
|
|
|
|
- <div className='xian' hidden={!sortAll}></div>
|
|
|
|
- <div className={classNames('all', sort === -1 ? 'activeAll' : '')} onClick={() => setSort(-1)}>全部类别</div>
|
|
|
|
- <div className='sortBox_left'>
|
|
|
|
- {sortList.map((item) => (
|
|
|
|
- <div className={classNames(sort === item.id ? 'active' : '')} onClick={() => setSort(item.id)} key={item.id}>{item.name}</div>
|
|
|
|
- ))}
|
|
|
|
- </div>
|
|
|
|
- <div className='sortBox_right' onClick={() => setSortAll(!sortAll)}>
|
|
|
|
- {sortAll ? <DownOutlined /> : <UpOutlined />}
|
|
|
|
- </div>
|
|
|
|
|
|
+ {/* 分类下拉框 */}
|
|
|
|
+ <div className='sortBox'>
|
|
|
|
+ <Select style={{ width: '100%' }} value={sort} onChange={sortChangeFu} options={sortList} />
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
+ {/* 年代筛选下拉框 */}
|
|
|
|
+ <div className='ageSeachBox'>
|
|
|
|
+ <Select style={{ width: '100%' }} value={ageSerach} onChange={ageChangeFu} options={ageList} />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div className='ageBox'>
|
|
|
|
- <div className='ageBoxAll'>全部年代</div>
|
|
|
|
- {[1, 2, 3].map(item => (
|
|
|
|
- <div className='ageRow' key={item}>{'中华明国年代' + item}</div>
|
|
|
|
- ))}
|
|
|
|
- </div> */}
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{/* 页面渲染主体 */}
|
|
{/* 页面渲染主体 */}
|