v2
parent
7844106068
commit
c961892d9b
@ -0,0 +1,3 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '疾病知识', |
||||
}) |
@ -0,0 +1,71 @@ |
||||
.firstOrder { |
||||
width: 300rpx; |
||||
height: calc(100vh - env(safe-area-inset-bottom)); |
||||
|
||||
View { |
||||
width: 100%; |
||||
text-align: center; |
||||
min-height: 100rpx; |
||||
color: #323635; |
||||
display: flex; |
||||
align-items: center; |
||||
padding: 10rpx; |
||||
box-sizing: border-box; |
||||
justify-content: center; |
||||
} |
||||
} |
||||
|
||||
/** 选中 */ |
||||
.select { |
||||
color: #45D4A8 !important; |
||||
font-weight: bold; |
||||
position: relative; |
||||
transition: all 200ms; |
||||
|
||||
&:after { |
||||
content: ''; |
||||
display: block; |
||||
width: 8rpx; |
||||
height: 60rpx; |
||||
background: #45D4A8; |
||||
position: absolute; |
||||
left: 0; |
||||
top: 0; |
||||
bottom: 0; |
||||
margin: auto; |
||||
border-radius: 10rpx; |
||||
} |
||||
} |
||||
|
||||
.tree { |
||||
padding: 0 15rpx; |
||||
background: #fff; |
||||
box-sizing: border-box; |
||||
height: calc(100vh - env(safe-area-inset-bottom)); |
||||
} |
||||
|
||||
.name { |
||||
font-size: 32rpx; |
||||
font-weight: bold; |
||||
color: #323635; |
||||
padding: 40rpx 0 40rpx 15rpx; |
||||
} |
||||
|
||||
.secondaryBox { |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
align-items: flex-start; |
||||
} |
||||
|
||||
.secondary { |
||||
width: 50%; |
||||
padding: 0 15rpx; |
||||
box-sizing: border-box; |
||||
color: #323635; |
||||
text-align: center; |
||||
line-height: 60rpx; |
||||
background: #F5F8F7; |
||||
border-radius: 8rpx; |
||||
margin-bottom: 20rpx; |
||||
background-clip: content-box; |
||||
} |
@ -0,0 +1,71 @@ |
||||
import {ScrollView, View} from "@tarojs/components"; |
||||
import {FC, useState} from "react"; |
||||
import {Category, HomeApi} from "@/api"; |
||||
import Taro from "@tarojs/taro"; |
||||
import styles from './sort.module.scss' |
||||
|
||||
const prefix = 'SORT' |
||||
const Sort: FC = () => { |
||||
const [data, setData] = useState<Category[]>([]) |
||||
const [select, setSelect] = useState<string | null>(null) |
||||
|
||||
async function getData() { |
||||
const res = await HomeApi.category(3) |
||||
setData(res) |
||||
if (res.length) { |
||||
setSelect(`${prefix}-${res[0].id}`) |
||||
} |
||||
} |
||||
|
||||
function jump(id: number) { |
||||
console.log(id) |
||||
} |
||||
|
||||
Taro.useLoad(getData) |
||||
|
||||
return ( |
||||
<View className='flex'> |
||||
<ScrollView |
||||
scrollY |
||||
scrollWithAnimation |
||||
scrollIntoView={select!} |
||||
className={styles.firstOrder}> |
||||
{ |
||||
data.map(d => <View |
||||
id={`${prefix}-${d.id}`} |
||||
key={d.id} |
||||
onClick={() => setSelect(`${prefix}-${d.id}`)} |
||||
className={`${select === `${prefix}-${d.id}` && styles.select}`}> |
||||
{d.name} |
||||
</View>) |
||||
} |
||||
</ScrollView> |
||||
|
||||
<ScrollView |
||||
scrollY |
||||
className={styles.tree} |
||||
scrollWithAnimation |
||||
scrollIntoView={select!}> |
||||
{ |
||||
data.map(d => <View key={d.id} id={`${prefix}-${d.id}`}> |
||||
<View className={styles.name} |
||||
style={{color: (select === `${prefix}-${d.id}` ? '#45D4A8' : undefined)}}>{d.name}</View> |
||||
<View className={styles.secondaryBox}> |
||||
{ |
||||
d.resource_category?.map(c => <View |
||||
onClick={() => jump(d.id)} |
||||
key={d.id} |
||||
className={styles.secondary}> |
||||
<View className='p-1'>{c.name}</View> |
||||
</View>) |
||||
} |
||||
</View> |
||||
</View> |
||||
) |
||||
} |
||||
</ScrollView> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
export default Sort |
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 681 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 791 B |
Before Width: | Height: | Size: 466 B After Width: | Height: | Size: 853 B |
Loading…
Reference in new issue