|
@@ -1,13 +1,178 @@
|
|
-import React from 'react'
|
|
|
|
|
|
+import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
-function AAAAA() {
|
|
|
|
|
|
+import LeftTopLogo from '@/components/LeftTopLogo'
|
|
|
|
+import { SearchOutline } from 'antd-mobile-icons'
|
|
|
|
+import classNames from 'classnames'
|
|
|
|
+import LazyImg from '@/components/LazyImg'
|
|
|
|
+
|
|
|
|
+import { Swiper, SwiperSlide } from 'swiper/react'
|
|
|
|
+
|
|
|
|
+import { FreeMode, Mousewheel } from 'swiper'
|
|
|
|
+// Import Swiper styles
|
|
|
|
+import 'swiper/css'
|
|
|
|
+import 'swiper/css/free-mode'
|
|
|
|
+import 'swiper/css/mousewheel'
|
|
|
|
+
|
|
|
|
+import { getDictList, getExpertList } from '@/store/action/all'
|
|
|
|
+import { DictType, ExpertType, GoodsRow } from '@/types'
|
|
|
|
+import { FromDataType } from './data'
|
|
|
|
+import { Input, Pagination } from 'antd'
|
|
|
|
+import { baseURL } from '@/utils/http'
|
|
|
|
+
|
|
|
|
+// 图片导入
|
|
|
|
+import topBgImg from '@/assets/img/expert/topBg.png'
|
|
|
|
+import nullImg from '@/assets/img/goods/null.png'
|
|
|
|
+import A4look from './A4look'
|
|
|
|
+
|
|
|
|
+function A4expert() {
|
|
|
|
+ const [topArr, setTopArr] = useState<DictType[]>([])
|
|
|
|
+
|
|
|
|
+ const getDictListFu = useCallback(async () => {
|
|
|
|
+ const res = await getDictList()
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ setTopArr([{ id: null, name: '全部' }, ...res.data])
|
|
|
|
+ }
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ getDictListFu()
|
|
|
|
+ }, [getDictListFu])
|
|
|
|
+
|
|
|
|
+ const [fromData, setFromData] = useState<FromDataType>({
|
|
|
|
+ searchKey: '',
|
|
|
|
+ dictId: null,
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 5
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 输入框的输入
|
|
|
|
+ const timeRef = useRef(-1)
|
|
|
|
+ const txtChangeFu = useCallback(
|
|
|
|
+ (e: React.ChangeEvent<HTMLInputElement>, key: 'searchKey') => {
|
|
|
|
+ clearTimeout(timeRef.current)
|
|
|
|
+ timeRef.current = window.setTimeout(() => {
|
|
|
|
+ setFromData({ ...fromData, [key]: e.target.value.replaceAll("'", ''), pageNum: 1 })
|
|
|
|
+ }, 500)
|
|
|
|
+ },
|
|
|
|
+ [fromData]
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ // 列表数据
|
|
|
|
+ const [listObj, setListObj] = useState<ExpertType>({ list: [], total: 0 })
|
|
|
|
+ const [loding, setLoding] = useState(false)
|
|
|
|
+
|
|
|
|
+ const getListFu = useCallback(async () => {
|
|
|
|
+ const res = await getExpertList(fromData)
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ setLoding(true)
|
|
|
|
+ setListObj({ list: res.data.records || [], total: res.data.total })
|
|
|
|
+ }
|
|
|
|
+ }, [fromData])
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ getListFu()
|
|
|
|
+ }, [getListFu])
|
|
|
|
+
|
|
|
|
+ // 平时展示 和 鼠标移入的相同dom
|
|
|
|
+ const rowTongDom = useCallback((info: GoodsRow) => {
|
|
|
|
+ return (
|
|
|
|
+ <>
|
|
|
|
+ <div className={classNames('A4mRtitle', info.intro ? '' : 'A4mRtitleDuo')}>
|
|
|
|
+ <div>{info.name}</div>
|
|
|
|
+ </div>
|
|
|
|
+ <div className='A4mRtxt mySorrl'>{info.intro}</div>
|
|
|
|
+ </>
|
|
|
|
+ )
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
|
|
+ const [editId, setEditId] = useState(0)
|
|
|
|
+
|
|
return (
|
|
return (
|
|
- <div className={styles.AAAAA}>
|
|
|
|
- <h1>AAAAA</h1>
|
|
|
|
|
|
+ <div className={styles.A4expert}>
|
|
|
|
+ <LeftTopLogo />
|
|
|
|
+
|
|
|
|
+ <div className='A4top' hidden={!!editId}>
|
|
|
|
+ <img className='A4topll' src={topBgImg} alt='' />
|
|
|
|
+ <div className='A4toprr'>
|
|
|
|
+ 类型:
|
|
|
|
+ <Swiper
|
|
|
|
+ modules={[FreeMode, Mousewheel]}
|
|
|
|
+ className='appSw'
|
|
|
|
+ spaceBetween={0}
|
|
|
|
+ slidesPerView='auto'
|
|
|
|
+ freeMode={true}
|
|
|
|
+ mousewheel={true}
|
|
|
|
+ >
|
|
|
|
+ {topArr.map(v => (
|
|
|
|
+ <SwiperSlide key={v.id}>
|
|
|
|
+ <div
|
|
|
|
+ onClick={() => setFromData({ ...fromData, pageNum: 1, dictId: v.id })}
|
|
|
|
+ className={classNames('A4trRow', fromData.dictId === v.id ? 'A4trRowAc' : '')}
|
|
|
|
+ key={v.id}
|
|
|
|
+ >
|
|
|
|
+ {v.name}
|
|
|
|
+ </div>
|
|
|
|
+ </SwiperSlide>
|
|
|
|
+ ))}
|
|
|
|
+ </Swiper>
|
|
|
|
+ <div className='A4trInp'>
|
|
|
|
+ <Input
|
|
|
|
+ placeholder='请输入搜索内容'
|
|
|
|
+ allowClear
|
|
|
|
+ onChange={e => txtChangeFu(e, 'searchKey')}
|
|
|
|
+ />
|
|
|
|
+ <div className='A4trInpInco'>
|
|
|
|
+ <SearchOutline />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div hidden={!!editId} className='A4main'>
|
|
|
|
+ {listObj.list.length ? (
|
|
|
|
+ <div className='A4mBox'>
|
|
|
|
+ {listObj.list.map((v, i) => (
|
|
|
|
+ <div
|
|
|
|
+ onClick={() => setEditId(v.id)}
|
|
|
|
+ title={v.name}
|
|
|
|
+ className={classNames('A4mRow', i % 2 === 0 ? 'A4mRowOu' : '')}
|
|
|
|
+ key={v.id}
|
|
|
|
+ >
|
|
|
|
+ <div>
|
|
|
|
+ <div className='A4mRowShow'>
|
|
|
|
+ <LazyImg src={baseURL + v.thumb} />
|
|
|
|
+ {rowTongDom(v)}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ ))}
|
|
|
|
+ </div>
|
|
|
|
+ ) : (
|
|
|
|
+ <div className='A4mNull' hidden={!loding}>
|
|
|
|
+ <img src={nullImg} alt='' />
|
|
|
|
+ <p>暂时没有数据</p>
|
|
|
|
+ <p>请试一下其他关键字</p>
|
|
|
|
+ </div>
|
|
|
|
+ )}
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ {/* 分页 */}
|
|
|
|
+ <div className='pageBox' hidden={!!editId}>
|
|
|
|
+ <Pagination
|
|
|
|
+ current={fromData.pageNum}
|
|
|
|
+ pageSize={fromData.pageSize}
|
|
|
|
+ onChange={(pageNum, pageSize) => setFromData({ ...fromData, pageNum, pageSize })}
|
|
|
|
+ total={listObj.total}
|
|
|
|
+ />
|
|
|
|
+ ;
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ {/* 查看详情 */}
|
|
|
|
+ {editId ? <A4look editId={editId} closeFu={() => setEditId(0)} /> : null}
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
-const MemoAAAAA = React.memo(AAAAA)
|
|
|
|
|
|
+const MemoA4expert = React.memo(A4expert)
|
|
|
|
|
|
-export default MemoAAAAA
|
|
|
|
|
|
+export default MemoA4expert
|