From 7d1d3475618b49077048ea8ee931db158f8bbf70 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Mon, 28 Aug 2023 14:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=96=BE=E7=97=85=E6=BB=91=E5=8A=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preview/illness/sort/sort.module.scss | 3 +- src/pages/preview/illness/sort/sort.tsx | 76 ++++++++++++------- 2 files changed, 49 insertions(+), 30 deletions(-) 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}) + : + } + + ) + } + + + ) }