From fa81566f32f762e3234b5a46f5514eedd453f35e Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Wed, 6 Sep 2023 14:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=96=BE=E7=97=85=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=92=8C=E9=A1=B5=E9=9D=A2=E9=AB=98=E5=BA=A6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.tsx | 1 + src/components/tabs/tabs.tsx | 5 +- src/pages/my/my.tsx | 2 + .../preview/illness/sort/sort.module.scss | 11 -- src/pages/preview/illness/sort/sort.tsx | 132 ++++++++---------- 5 files changed, 66 insertions(+), 85 deletions(-) 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)} + ) + } + + : + } ) }