|
|
@ -4,7 +4,6 @@ import {Category, HomeApi} from "@/api"; |
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
import styles from './sort.module.scss' |
|
|
|
import styles from './sort.module.scss' |
|
|
|
import Tabs, {TabList} from "@/components/tabs/tabs"; |
|
|
|
import Tabs, {TabList} from "@/components/tabs/tabs"; |
|
|
|
import {Search} from "@/pages/home/components/search"; |
|
|
|
|
|
|
|
import {illnessApi} from "@/api/illness"; |
|
|
|
import {illnessApi} from "@/api/illness"; |
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
import leftArrow from "@/static/img/leftArrow.png" |
|
|
|
import leftArrow from "@/static/img/leftArrow.png" |
|
|
@ -16,10 +15,10 @@ const Sort: FC = () => { |
|
|
|
const [secondId, setSecondId] = useState<number | undefined>(undefined) |
|
|
|
const [secondId, setSecondId] = useState<number | undefined>(undefined) |
|
|
|
const [list, setList] = useState<any[]>([]) |
|
|
|
const [list, setList] = useState<any[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const globalData = Taro.getApp().globalData |
|
|
|
const globalData = Taro.getApp().globalData |
|
|
|
const menu = Taro.getMenuButtonBoundingClientRect() |
|
|
|
const menu = Taro.getMenuButtonBoundingClientRect() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getData() { |
|
|
|
async function getData() { |
|
|
|
const res = await HomeApi.category(3) |
|
|
|
const res = await HomeApi.category(3) |
|
|
|
setData(res) |
|
|
|
setData(res) |
|
|
@ -30,7 +29,7 @@ const Sort: FC = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function jump(id: number) { |
|
|
|
function jump(id: number) { |
|
|
|
Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id}) |
|
|
|
Taro.navigateTo({url: '/pages/preview/illness/list/list?id=' + id}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getTabList = useMemo((): TabList[] => { |
|
|
|
const getTabList = useMemo((): TabList[] => { |
|
|
@ -48,10 +47,6 @@ const Sort: FC = () => { |
|
|
|
paddingLeft: '10px' |
|
|
|
paddingLeft: '10px' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onConfirm(value: string) { |
|
|
|
|
|
|
|
console.log(value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function firstIdChange(id: number) { |
|
|
|
function firstIdChange(id: number) { |
|
|
|
setFirstId(id) |
|
|
|
setFirstId(id) |
|
|
|
const resource_category = data.find(d => d.id === id)?.resource_category |
|
|
|
const resource_category = data.find(d => d.id === id)?.resource_category |
|
|
@ -64,16 +59,14 @@ const Sort: FC = () => { |
|
|
|
if (secondId) { |
|
|
|
if (secondId) { |
|
|
|
Taro.showLoading({title: '加载中'}) |
|
|
|
Taro.showLoading({title: '加载中'}) |
|
|
|
illnessApi.list(secondId, 1, 100).then(res => { |
|
|
|
illnessApi.list(secondId, 1, 100).then(res => { |
|
|
|
const data = [] |
|
|
|
setList(res.list) |
|
|
|
res.list.forEach(d => { |
|
|
|
|
|
|
|
data.push(...d.articles as []) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
setList(data) |
|
|
|
|
|
|
|
}).finally(() => { |
|
|
|
}).finally(() => { |
|
|
|
Taro.hideLoading() |
|
|
|
Taro.hideLoading() |
|
|
|
}).catch(() => { |
|
|
|
}).catch(() => { |
|
|
|
setList([]) |
|
|
|
setList([]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setList([]) |
|
|
|
} |
|
|
|
} |
|
|
|
}, [secondId]) |
|
|
|
}, [secondId]) |
|
|
|
|
|
|
|
|
|
|
@ -86,13 +79,11 @@ const Sort: FC = () => { |
|
|
|
onClick={() => Taro.navigateBack()}/> |
|
|
|
onClick={() => Taro.navigateBack()}/> |
|
|
|
<Tabs tabList={getTabList} onChange={(data) => firstIdChange(data.tab?.value as number)}/> |
|
|
|
<Tabs tabList={getTabList} onChange={(data) => firstIdChange(data.tab?.value as number)}/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<Search onConfirm={onConfirm}/> |
|
|
|
|
|
|
|
<View className='flex'> |
|
|
|
{/*<Search onConfirm={onConfirm}/>*/} |
|
|
|
<ScrollView |
|
|
|
|
|
|
|
scrollY |
|
|
|
<View className={styles.scrollView} style={{top: `${globalData.statusBarHeight + 59}px`}}> |
|
|
|
scrollWithAnimation |
|
|
|
<ScrollView scrollY className={styles.firstOrder}> |
|
|
|
scrollIntoView={`${prefix}-${secondId}`} |
|
|
|
|
|
|
|
className={styles.firstOrder}> |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
data.find(d => d.id === firstId)?.resource_category?.map(d => <View |
|
|
|
data.find(d => d.id === firstId)?.resource_category?.map(d => <View |
|
|
|
id={`${prefix}-${d.id}`} |
|
|
|
id={`${prefix}-${d.id}`} |
|
|
@ -110,7 +101,7 @@ const Sort: FC = () => { |
|
|
|
scrollWithAnimation> |
|
|
|
scrollWithAnimation> |
|
|
|
{ |
|
|
|
{ |
|
|
|
list.length ? |
|
|
|
list.length ? |
|
|
|
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.title}</View>) |
|
|
|
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>) |
|
|
|
: <Empty name='暂无数据'/> |
|
|
|
: <Empty name='暂无数据'/> |
|
|
|
} |
|
|
|
} |
|
|
|
</ScrollView> |
|
|
|
</ScrollView> |
|
|
|