diff --git a/src/pages/preview/illness/sort/sort.module.scss b/src/pages/preview/illness/sort/sort.module.scss index efab5db..c59026b 100644 --- a/src/pages/preview/illness/sort/sort.module.scss +++ b/src/pages/preview/illness/sort/sort.module.scss @@ -1,11 +1,12 @@ .scrollView { + height: auto !important; position: fixed; top: 0; bottom: 0; left: 0; right: 0; + width: 100%; margin: auto; - display: flex; } .firstOrder { diff --git a/src/pages/preview/illness/sort/sort.tsx b/src/pages/preview/illness/sort/sort.tsx index 3c0bbe7..695f3ea 100644 --- a/src/pages/preview/illness/sort/sort.tsx +++ b/src/pages/preview/illness/sort/sort.tsx @@ -1,4 +1,4 @@ -import {Image, ScrollView, View} from "@tarojs/components"; +import {Image, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {FC, useEffect, useMemo, useState} from "react"; import {Category, HomeApi} from "@/api"; import Taro from "@tarojs/taro"; @@ -11,8 +11,8 @@ import leftArrow from "@/static/img/leftArrow.png" const prefix = 'SORT' const Sort: FC = () => { const [data, setData] = useState([]) - const [firstId, setFirstId] = useState(undefined) - const [secondId, setSecondId] = useState(undefined) + const [firstId, setFirstId] = useState(undefined) // 一级分类 + const [secondId, setSecondId] = useState(undefined) // 二级分类 const [list, setList] = useState([]) const globalData = Taro.getApp().globalData const menu = Taro.getMenuButtonBoundingClientRect() @@ -67,6 +67,13 @@ const Sort: FC = () => { } }, [secondId]) + function swiperChange(e) { + const firstData = data[e.target.current] + if (!firstData) return; + setFirstId(firstData.id) + setSecondId(firstData?.resource_category?.[0]?.id) + } + return ( @@ -78,6 +85,7 @@ const Sort: FC = () => { firstIdChange(data.tab?.value as number)}/> @@ -85,32 +93,42 @@ const Sort: FC = () => { {/**/} - - - { - data.find(d => d.id === firstId)?.resource_category?.map(d => setSecondId(d.id)} - className={secondId === d.id && styles.select}> - {d.name} - ) - } - - - - { - list.length ? - list.map(d => jump(d.id)}>{d.name}) - : - } - - + d.id === firstId)} + style={{top: `${globalData.statusBarHeight + 59}px`}}> + { + data.map(d => + + { + d.resource_category?.map(d => setSecondId(d.id)} + className={secondId === d.id && styles.select}> + {d.name} + ) + } + + + + { + list.length ? + list.map(d => jump(d.id)}>{d.name}) + : + } + + ) + } + + + ) }