一杯沧海 1 year ago
commit 97fbd3343a
  1. 6
      src/components/videoCover/videoCover.scss
  2. 4
      src/pages/home/components/curRecommended.tsx
  3. 2
      src/pages/home/components/feature.tsx
  4. 10
      src/pages/home/home.module.scss
  5. 2
      src/pages/home/home.tsx
  6. 3
      src/pages/preview/illness/sort/sort.module.scss
  7. 76
      src/pages/preview/illness/sort/sort.tsx
  8. 4
      src/pages/preview/profession/profession.module.scss
  9. 23
      src/pages/preview/profession/profession.tsx

@ -51,7 +51,7 @@
.box {
box-sizing: border-box;
padding: 15rpx;
padding: 20rpx;
.title {
width: 100%;
@ -61,6 +61,10 @@
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 28rpx;
font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500;
color: #323635;
}
}

@ -37,9 +37,9 @@ const CurRecommended: FC = () => {
return (
<>
{
data.length > 0 && <View className='mt-8'>
data.length > 0 && <View>
<Image src={courseTag} mode='widthFix' className={styles.courseTag}/>
<View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}>
<View className={'pb-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{
data.map(c => <VideoCover
thumb={c.thumb}

@ -20,7 +20,7 @@ const Feature: FC = () => {
}
return (
<View className='flex justify-around' style={{marginBottom: '20px'}}>
<View className='flex justify-around' style={{marginBottom: '25px'}}>
{
list.map(d => <View className='text-center' onClick={() => jump(d.url)}>
<Image src={d.image} style={{width: '48px', height: '48px'}}/>

@ -71,8 +71,8 @@
.courseTag {
width: 200px;
margin: auto;
width: 162px;
margin: 0 auto 30rpx;
display: block;
}
@ -80,7 +80,7 @@
color: #323635;
background: #fff;
padding: 30rpx 0 30rpx 30rpx;
margin-bottom: 40rpx;
margin-bottom: 50rpx;
border-radius: 30rpx;
}
@ -119,8 +119,8 @@
.ranking {
position: absolute;
left: 24rpx;
width: 40px;
height: 40px;
width: 30px;
height: 30px;
}
.featureImage {

@ -28,7 +28,7 @@ const Home: FC = () => {
}, [])
return (
<View className={styles.content} style={{paddingTop: '20px'}}>
<View className={styles.content}>
{/*<Search/>*/}
<Adware data={data?.adverts || []} only_flag='routine_home_top_banner' width={710}/>
<Feature/>

@ -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 {

@ -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<Category[]>([])
const [firstId, setFirstId] = useState<number | undefined>(undefined)
const [secondId, setSecondId] = useState<number | undefined>(undefined)
const [firstId, setFirstId] = useState<number | undefined>(undefined) // 一级分类
const [secondId, setSecondId] = useState<number | undefined>(undefined) // 二级分类
const [list, setList] = useState<any[]>([])
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 (
<View>
<View style={headerStyles}>
@ -78,6 +85,7 @@ const Sort: FC = () => {
<View style={{width: '200px', margin: 'auto'}}>
<Tabs
tabList={getTabList}
current={firstId}
onChange={(data) => firstIdChange(data.tab?.value as number)}/>
</View>
</View>
@ -85,32 +93,42 @@ const Sort: FC = () => {
{/*<Search onConfirm={onConfirm}/>*/}
<View className={styles.scrollView} style={{top: `${globalData.statusBarHeight + 59}px`}}>
<ScrollView scrollY className={styles.firstOrder} enhanced showScrollbar={false}>
{
data.find(d => d.id === firstId)?.resource_category?.map(d => <View
id={`${prefix}-${d.id}`}
key={d.id}
onClick={() => setSecondId(d.id)}
className={secondId === d.id && styles.select}>
{d.name}
</View>)
}
</ScrollView>
<ScrollView
enhanced
showScrollbar={false}
scrollY
className={styles.tree}
scrollWithAnimation>
{
list.length ?
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)
: <Empty name='暂无数据'/>
}
</ScrollView>
</View>
<Swiper
onChange={swiperChange}
className={styles.scrollView}
current={data.findIndex(d => d.id === firstId)}
style={{top: `${globalData.statusBarHeight + 59}px`}}>
{
data.map(d => <SwiperItem key={d.id} className='flex'>
<ScrollView scrollY className={styles.firstOrder} enhanced showScrollbar={false}>
{
d.resource_category?.map(d => <View
id={`${prefix}-${d.id}`}
key={d.id}
onClick={() => setSecondId(d.id)}
className={secondId === d.id && styles.select}>
{d.name}
</View>)
}
</ScrollView>
<ScrollView
enhanced
showScrollbar={false}
scrollY
className={styles.tree}
scrollWithAnimation>
{
list.length ?
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)
: <Empty name='暂无数据'/>
}
</ScrollView>
</SwiperItem>)
}
</Swiper>
</View>
)
}

@ -13,8 +13,10 @@
Image,
image {
width: 200rpx;
width: 320rpx;
max-height: 180rpx;
margin-right: 20rpx;
border-radius: 10rpx;
background: #eee;
}
}

@ -21,16 +21,20 @@ const Profession = () => {
* more
*/
async function getData(more = false) {
if (categoryId) {
const oldData = new Map<number, KillData>(data)
const categoryData = oldData.get(categoryId)
const page = more ? (categoryData?.page || 0) + 1 : categoryData?.page || 1
if (!categoryId) return;
const oldData = new Map<number, KillData>(data)
const categoryData = oldData.get(categoryId)
const page = more ? (categoryData?.page || 0) + 1 : categoryData?.page || 1
/** 无更多 */
if (more && categoryData && categoryData.data.length >= categoryData.total) {
return
}
/** 无更多 */
if (more && categoryData && categoryData.data.length >= categoryData.total) {
return
try {
if (!data.has(categoryId)) {
Taro.showLoading()
}
const res = await HomeApi.skillList(categoryId!, page, 10)
const dataList = res.data.reduce((pre, cur) => {
const index = pre.findIndex(d => d.id === cur.id)
@ -42,14 +46,15 @@ const Profession = () => {
return pre
}, categoryData?.data || [])
oldData.delete(categoryId)
oldData.set(categoryId, {
data: dataList,
total: res.total,
page: page
})
setData(oldData)
} catch (e) {
}
Taro.hideLoading()
}
useEffect(() => {

Loading…
Cancel
Save