diff --git a/src/app.tsx b/src/app.tsx index 157f647..2c2836c 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -50,6 +50,7 @@ function App(props) { safeArea, isIos, textBarHeight, + pageHeight: screenHeight - statusBarHeight - textBarHeight - (screenHeight - (safeArea?.bottom || 0)), menu: Taro.getMenuButtonBoundingClientRect(), } } diff --git a/src/components/tabs/tabs.tsx b/src/components/tabs/tabs.tsx index de5c184..0348c7b 100644 --- a/src/components/tabs/tabs.tsx +++ b/src/components/tabs/tabs.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useState} from "react"; +import {CSSProperties, FC, useEffect, useState} from "react"; import './tabs.scss' import {ScrollView, View} from "@tarojs/components"; import Taro from "@tarojs/taro"; @@ -22,6 +22,7 @@ interface TabsProps { height?: number | string onChange?: (data: OnChangOpt) => void backMode?: boolean // 块级模式 + style?: CSSProperties } const Tabs: FC = (opt) => { @@ -49,7 +50,7 @@ const Tabs: FC = (opt) => { return ( - + {opt.tabList.map((d, index) => { const [navbarOpacity, setNavbarOpacity] = useState('0') const navbarHeight = globalData.statusBarHeight + globalData.textBarHeight; + console.log(globalData) + Taro.useDidShow(() => { token && userApi.companyList().then(res => { setCompanyList(res as Company[]) diff --git a/src/pages/preview/illness/sort/sort.module.scss b/src/pages/preview/illness/sort/sort.module.scss index 75605d6..2367ac9 100644 --- a/src/pages/preview/illness/sort/sort.module.scss +++ b/src/pages/preview/illness/sort/sort.module.scss @@ -1,14 +1,3 @@ -.scrollView { - height: auto !important; - position: fixed; - top: 0; - bottom: 0; - left: 0; - right: 0; - width: 100%; - margin: auto; -} - .firstOrder { width: 260rpx; height: 100%; diff --git a/src/pages/preview/illness/sort/sort.tsx b/src/pages/preview/illness/sort/sort.tsx index 672f843..6ad6f1d 100644 --- a/src/pages/preview/illness/sort/sort.tsx +++ b/src/pages/preview/illness/sort/sort.tsx @@ -1,13 +1,13 @@ -import {ScrollView, Image, Swiper, SwiperItem, View} from "@tarojs/components"; -import {CSSProperties, FC, useEffect, useMemo, useState} from "react"; +import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; +import {FC, useEffect, useMemo, useState} from "react"; import {Category, HomeApi} from "@/api"; import Taro from "@tarojs/taro"; import styles from './sort.module.scss' import Tabs, {TabList} from "@/components/tabs/tabs"; import {illnessApi} from "@/api/illness"; import Empty from "@/components/empty/empty"; -import leftArrow from "@/static/img/leftArrow.png" import Spin from "@/components/spinner"; +import NavigationBar from "@/components/navigationBar/navigationBar"; const prefix = 'SORT' const Sort: FC = () => { @@ -18,11 +18,9 @@ const Sort: FC = () => { const [enable, setEnable] = useState(true) const [loading, setLoading] = useState(false) const globalData = Taro.getApp().globalData - const menu = Taro.getMenuButtonBoundingClientRect() async function getData() { try { - const res = await HomeApi.category(3) setData(res) if (res.length) { @@ -46,13 +44,6 @@ const Sort: FC = () => { })) }, [data]) - const headerStyles: CSSProperties = { - paddingTop: globalData.statusBarHeight + 'px', - display: 'flex', - alignItems: "center", - width: menu.left - 10 + 'px', - } - function firstIdChange(id: number) { setFirstId(id) const resource_category = data.find(d => d.id === id)?.resource_category @@ -82,69 +73,66 @@ const Sort: FC = () => { setSecondId(firstData?.resource_category?.[0]?.id) } + const SecondLevel = (category: Category) => { + if (!category.resource_category?.length) { + return () + } else { + return ( + + + { + category.resource_category?.map(d => setSecondId(d.id)} + className={secondId === d.id && styles.select}> + {d.name} + ) + } + + + { + loading ? : <> + { + list.length ? + list.map(d => jump(d.id)}>{d.name}) + : + } + + } + + + ) + } + } + return ( + firstIdChange(data.tab?.value as number)} + />}/> - - Taro.navigateBack()}> - - - - firstIdChange(data.tab?.value as number)} - /> - - - - - - 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} - ) - } - - - - { - loading ? : <> - { - list.length ? - list.map(d => jump(d.id)}>{d.name}) - : - } - - } - - ) - } - + { + data.length > 0 ? d.id === firstId)}> + { + data.map(d => + {SecondLevel(d)} + ) + } + + : + } ) }