一杯沧海 1 year ago
commit aa94eb9a27
  1. 2
      src/components/empty/empty.tsx
  2. 12
      src/components/image/image.module.scss
  3. 37
      src/components/image/image.tsx
  4. 7
      src/components/popPut/popPut.tsx
  5. 22
      src/components/spinner/index.tsx
  6. 12
      src/components/spinner/style.scss
  7. 6
      src/pages/business/videoInfo/videoInfo.scss
  8. 20
      src/pages/business/videoInfo/videoInfo.tsx
  9. 4
      src/pages/home/components/feature_recommended.tsx
  10. 2
      src/pages/home/home.module.scss
  11. 2
      src/pages/home/home.tsx
  12. 2
      src/pages/index/index.config.ts
  13. 4
      src/pages/manage/courseAdmin/courseAdmin.tsx
  14. 4
      src/pages/manage/depAdmin/depAdmin.tsx
  15. 4
      src/pages/manage/selectDep/selectDep.tsx
  16. 5
      src/pages/manage/userInfo/components/info.tsx
  17. 1
      src/pages/manage/userInfo/userInfo.module.scss
  18. 14
      src/pages/preview/brand/info/info.tsx
  19. 7
      src/pages/preview/brand/list/list.tsx
  20. 7
      src/pages/preview/health/health.module.scss
  21. 10
      src/pages/preview/health/health.tsx
  22. 17
      src/pages/preview/illness/list/list.tsx
  23. 19
      src/pages/preview/illness/sort/sort.tsx
  24. 9
      src/pages/preview/profession/profession.module.scss
  25. 16
      src/pages/preview/profession/profession.tsx
  26. 5
      src/static/css/module.scss

@ -10,7 +10,7 @@ interface Props {
const Empty: FC<Props> = ({name}) => {
return (
<View className={styles.empty}>
<Image src={emptyImg} mode='widthFix' className={styles.image}/>
<Image src={emptyImg} mode='widthFix' className={styles.image} fadeIn lazyLoad/>
<View className={styles.name}>{name}</View>
</View>
)

@ -0,0 +1,12 @@
.imgBox {
position: relative;
}
.imgError {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
}

@ -1,7 +1,8 @@
import {FC, useEffect, useState} from "react";
import {Image, ImageProps, View} from "@tarojs/components";
import {AtActivityIndicator} from "taro-ui";
import shard from '@/static/img/shard.png'
import styles from './image.module.scss'
import Taro from "@tarojs/taro";
interface Props extends ImageProps {
width: number
@ -13,14 +14,12 @@ const Img: FC<Props> = ({src, mode = 'aspectFill', width, height, fallback = sha
const [isError, setIsError] = useState(false)
const [loading, setLoading] = useState(true)
const imgAnimation = Taro.createAnimation({duration: 0}).opacity(0).step()
const [animationData, setAnimationData] = useState<TaroGeneral.IAnyObject>(imgAnimation.export())
useEffect(() => {
if (!src) {
setIsError(true)
setLoading(false)
} else {
setIsError(false)
setLoading(false)
}
setIsError(!src)
setLoading(!!src)
}, [src])
// 图片加载失败
@ -32,25 +31,37 @@ const Img: FC<Props> = ({src, mode = 'aspectFill', width, height, fallback = sha
function onLoadHandler() {
setLoading(false)
setIsError(false)
imgAnimation.opacity(1).step({duration: 200})
setAnimationData(imgAnimation.export())
}
return (
<View style={{width: `${width}rpx`, height: `${height}rpx`, backgroundColor: '#eee'}}>
<View
style={{width: `${width}rpx`, height: `${height}rpx`, backgroundColor: '#F8F8F8'}}
className={`${props.className} ${styles.imgBox}`}>
{!isError &&
<View animation={animationData}>
<Image
{...props}
src={src}
mode={mode}
lazyLoad
fadeIn
defaultSource={fallback}
style={{width: `${width}rpx`, height: `${height}rpx`}}
onError={onErrorHandler}
onLoad={onLoadHandler}>
</Image>
onLoad={onLoadHandler}/>
</View>
}
{loading && <AtActivityIndicator mode="center"/>}
{
isError && !loading &&
<Image mode={'aspectFill'} src={fallback} style={{width: `${width}rpx`, height: `${height}rpx`}}/>
<Image
className={styles.imgError}
mode='aspectFit'
src={fallback}
lazyLoad
fadeIn
style={{width: `${width * .7}rpx`, height: `${height * .7}rpx`, margin: 'auto'}}/>
}
</View>
)

@ -1,7 +1,8 @@
import {FC, ReactNode, useEffect, useState} from "react";
import {View, Image} from "@tarojs/components";
import {View} from "@tarojs/components";
import Icon from "@/components/icon";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container";
import Img from "@/components/image/image";
interface Props {
height?: number | string
@ -46,13 +47,13 @@ const PopPut: FC<Props> = ({title, chevron, content, image, isProp, children, sh
<>
<View className='card' onClick={click} style={style()}>
<View className='flex align-center'>
{opt.leftImage != null && <Image src={opt.leftImage} className='mr-3 image' mode='aspectFit'/>}
{opt.leftImage != null && <Img width={68} height={68} src={opt.leftImage} className='mr-3' mode='aspectFit'/>}
<View>{title}</View>
</View>
<View className='card-content'>
<View>{content}</View>
{!chevron && <Icon name='chevron-right'/>}
{image && <Image src={image} mode='scaleToFill' className='image'/>}
{image && <Img src={image} mode='scaleToFill' className='image' width={68} height={68}/>}
</View>
</View>
{

@ -12,8 +12,9 @@ type Status =
| 'completed'
interface Props {
enable?: boolean
overlay?: boolean
enable?: boolean // 控制显现
overlay?: boolean // 页面覆盖
block?: boolean // 块级
}
interface State {
@ -49,8 +50,8 @@ function createController(setState: StateSetter): Controller {
}
// 清空动画
background.export()
rotation.export()
background.step().export()
rotation.step().export()
// 通知 UI 刷新
if (notify) {
@ -80,7 +81,6 @@ function createController(setState: StateSetter): Controller {
const onFinish = (opacity: number, nextStatus: Status) => {
const lockStatus = status
setTimeout(() => {
if (lockStatus === status) {
background.backgroundColor(`rgba(255,255,255,${opacity})`).step({duration: 0})
if (nextStatus === 'dismissed') {
@ -89,14 +89,12 @@ function createController(setState: StateSetter): Controller {
status = nextStatus
notifyListener()
}
}, 600)
}
const setStatus = (newStatus: Status, opacity: number) => {
if (status !== newStatus) {
status = newStatus
setAnimation(opacity)
if (status === 'reverse') {
onFinish(0, 'dismissed')
} else if (status === 'forward') {
@ -140,10 +138,9 @@ export default class Spin extends Component<Props, State> {
this.setState((s) => ({...s, ...state}))
}
componentDidMount(): void {
console.log(this.props.enable)
this.controller.setTick(this.props.enable)
}
// componentDidMount(): void {
// this.controller.setTick(this.props.enable)
// }
componentDidUpdate(): void {
this.controller.setTick(this.props.enable)
@ -161,7 +158,8 @@ export default class Spin extends Component<Props, State> {
render(): ReactNode {
return (
<View className={`spinner-wrapper ${this.state.status} ${this.props.overlay ? 'is-fixed' : ''}`}>
<View
className={`spinner-wrapper ${this.state.status} ${this.props.overlay && 'is-fixed'} ${this.props.block && 'is-block'}`}>
<View className={`spinner ${this.state.status}`}>
<Image className="spinner-icon" src={indicator}/>
</View>

@ -1,8 +1,17 @@
.spinner-wrapper {
background-color: rgba( #fff, 1.0);
transition: background-color 1200ms ease-out;
&.is-block {
width: auto;
position: absolute;
z-index: 99999;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
&.is-fixed {
background-color: rgba(#fff, 1.0);
z-index: 99999;
position: fixed;
width: 100%;
@ -36,6 +45,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.spinner {

@ -7,11 +7,7 @@
height: 500rpx;
}
.image {
width: 100%;
height: 100%;
display: block;
}
.header {
margin-bottom: 10px;

@ -1,4 +1,4 @@
import {Image, Text, View} from "@tarojs/components";
import {Text, View} from "@tarojs/components";
import {FC, useCallback, useEffect, useState} from "react";
import {CourseDepData, curriculum} from "@/api";
import './videoInfo.scss'
@ -9,6 +9,7 @@ import eventsIndex from "@/hooks/eventsIndex";
import {formatMinute} from "@/utils/time";
import videoEvents from "@/hooks/videoEvents";
import unique_ident from "@/hooks/unique_ident";
import Img from "@/components/image/image";
const VideoInfo: FC = () => {
const {id, depId} = Taro.getCurrentInstance()?.router?.params as any
@ -18,12 +19,11 @@ const VideoInfo: FC = () => {
const [playing, setPlaying] = useState(false) // 学习中
const getData = useCallback(async (playing: boolean) => {
try {
const res = await curriculum.courseDep(id, depId)
if (res) {
setData(res)
}
if (playId != null) { // 用于自动播放 判断当前课程是否完成
currentVideo(res, playing)
res && setData(res)
playId != null && currentVideo(res, playing) // 用于自动播放 判断当前课程是否完成
} catch (e) {
}
}, [playing, playId])
@ -73,9 +73,7 @@ const VideoInfo: FC = () => {
}
}, [playId, data, preview])
/**
*
*/
/** 判断当前课程是否完成 */
const currentVideo = useCallback((data: CourseDepData, playing: boolean) => {
const courseHourRecordsFinish = data?.learn_hour_records.find(d => d.id === playId)?.courseHourRecordsFinish
if (typeof courseHourRecordsFinish === 'number') {
@ -105,13 +103,12 @@ const VideoInfo: FC = () => {
videoEvents.videoOff()
})
return (
<>
<View className='content'>
<View className='content-video'>
{
playId
? <Course id={playId} courseId={id} curEnd={curEnd} preview={preview}/>
: <Image src={data?.course.thumb || ''} className='image' mode='aspectFill'/>
: <Img width={750} height={500} src={data?.course.thumb || ''} mode='aspectFill'/>
}
</View>
@ -128,7 +125,6 @@ const VideoInfo: FC = () => {
</View>
<Catalogue data={data} setHors={setHors} id={id} playId={playId}/>
</View>
</>
)
}

@ -150,8 +150,8 @@ const FeatureRecommended: FC<Props> = (props) => {
}
return (
<View className={styles.feature} style={{height: '263px'}}>
<Swiper nextMargin='30px' style={{height: '263px'}}>
<View className={styles.feature}>
<Swiper nextMargin='30px' style={{height: '225px'}}>
{
data.map(d => <SwiperItem key={d.url}>
<Image

@ -51,9 +51,9 @@
}
.adware {
width: 100%;
border-radius: 16rpx;
overflow: hidden;
background: #eee;
margin-bottom: 40rpx;
}

@ -40,7 +40,7 @@ const Home: FC = () => {
{data && <CurRecommended/>}
{
!token && <View className={styles.tipsLogin} onClick={unLogin}>
<View>~</View>
<View>~</View>
<MyButton fillet size='mini'></MyButton>
</View>
}

@ -1,5 +1,5 @@
export default definePageConfig({
navigationBarTitleText: '医学道',
navigationBarTitleText: '学习课程',
navigationBarBackgroundColor: '#92ecc5',
navigationBarTextStyle: 'white',
})

@ -6,12 +6,14 @@ import styles from './courseAdmin.module.scss'
import Taro, {useReachBottom} from "@tarojs/taro";
import MyButton from "@/components/button/MyButton";
import storageDep from "@/hooks/storageDep";
import Spin from "@/components/spinner";
const CourseAdmin: FC = () => {
const [total, setTotal] = useState(0)
const [data, setData] = useState<Curriculum[]>([])
const [batch, setBatch] = useState(false)
const [curs, setCurs] = useState<number[]>([])
const [enable, setEnable] = useState(true)
const [param, setParam] = useState<CourseAllParam>({
page: 1,
page_size: 10,
@ -34,6 +36,7 @@ const CourseAdmin: FC = () => {
])
}
})
setEnable(false)
}
useEffect(() => {
@ -149,6 +152,7 @@ const CourseAdmin: FC = () => {
return (
<View>
<Spin enable={enable} overlay/>
<Search param={param} setParam={setParam}/>
<View className={styles.curList}>

@ -8,6 +8,7 @@ import folder from '@/static/img/folder.png'
import ShowModel from "@/components/showModel/showModel";
import Empty from "@/components/empty/empty";
import {Profile} from '@/store'
import Spin from "@/components/spinner";
const DepAdmin: FC = () => {
const router = useRouter()
@ -17,6 +18,7 @@ const DepAdmin: FC = () => {
const [isPut, setIsPut] = useState(false)
const [depName, setDepName] = useState('')
const [reset, setReset] = useState(false)
const [enable, setEnable] = useState(true)
const {company} = Profile.useContainer()
@ -31,6 +33,7 @@ const DepAdmin: FC = () => {
}
} catch (e) {
}
setEnable(false)
}
function showPop(name: string | undefined) {
@ -137,6 +140,7 @@ const DepAdmin: FC = () => {
return (
<>
<Spin overlay enable={enable}/>
<View>
{manages.map(d => <PopPut
key={d.id}

@ -6,6 +6,7 @@ import PopPut from "@/components/popPut/popPut";
import folder from "@/static/img/folder.png";
import MyButton from "@/components/button/MyButton";
import storageDep from "@/hooks/storageDep";
import Spin from "@/components/spinner";
/**
* depIds JSON = number[]
@ -16,11 +17,13 @@ const SelectDep: FC = () => {
const [ids, setIds] = useState<number[]>([])
const [deps, setDeps] = useState<Manage[]>([])
const [required, setRequired] = useState<number[]>([])
const [enable, setEnable] = useState(true)
useEffect(() => {
curriculum.department().then(res => {
setDeps(res.data)
})
setEnable(false)
setIds(JSON.parse(params.depIds))
setRequired(JSON.parse(params.required || "[]"))
}, [])
@ -79,6 +82,7 @@ const SelectDep: FC = () => {
return (
<View className='px-2 bg-white'>
<Spin overlay enable={enable}/>
{deps.map((d) => <View className='flex align-center' key={d.id} onClick={() => onChange(d.id)}>
<Checkbox value={d.id + ''} checked={ids.includes(d.id)} color='#45d4a8'/>
<View style={{flex: 1}}>

@ -1,6 +1,7 @@
import {FC} from "react";
import {Image, Text, View} from "@tarojs/components";
import { Text, View} from "@tarojs/components";
import styles from '../userInfo.module.scss'
import Img from "@/components/image/image";
interface Props {
data: User | null
@ -12,7 +13,7 @@ const Info: FC<Props> = ({data}) => {
return (
<>
<View className={styles.box}>
<Image src={data?.avatar || ''} className={styles.image}/>
<Img width={120} height={120} src={data?.avatar || ''} className={styles.image}/>
<View className='ml-2'>
<View>
<Text className='font-weight'>{data?.name}</Text>

@ -15,7 +15,6 @@
.image {
width: 120rpx;
height: 120rpx;
background: #ddd;
border-radius: 10rpx;
overflow: hidden;
}

@ -7,6 +7,7 @@ import LineEllipsis from "@/components/textCollapse/collapse";
import Empty from "@/components/empty/empty";
import Img from "@/components/image/image";
import {rfc33392time} from "@/utils/day";
import Spin from "@/components/spinner";
type Params = {
id: number
@ -18,15 +19,9 @@ const BrandInfo: FC = () => {
const [curIndex, setCurIndex] = useState<number>(1)
const [page, setPage] = useState(1)
const [total, setTotal] = useState(0)
const [enable, setEnable] = useState(true)
useEffect(() => {
Taro.showLoading({
title: '加载中',
mask: true
})
setTimeout(function () {
Taro.hideLoading()
}, 1000)
getData()
}, [id])
@ -44,6 +39,7 @@ const BrandInfo: FC = () => {
} catch (e) {
// setBrandInfo({disabled: 0, graphic_introduction: "", id: 0, introductory_video: "", name: "", brand_album:['1','2','3']})
}
setEnable(false)
}
useReachBottom(useCallback(() => {
@ -64,12 +60,12 @@ const BrandInfo: FC = () => {
}, [page])
function onChange(e) {
console.log(e)
setCurIndex(+e.detail.current + 1)
}
return (
<View className='flex flex-column' style={{display:brandInfo?'flex':'none'}}>
<View className='flex flex-column' style={{display: 'flex'}}>
<Spin enable={enable} overlay/>
<Swiper
className={styles['swiper']}
indicatorColor='#999'

@ -1,10 +1,11 @@
import {FC, useCallback, useEffect, useState} from "react";
import {Image, View} from "@tarojs/components";
import {View} from "@tarojs/components";
import {brandApi, BrandRecord} from "@/api";
import styles from './list.module.scss'
import Taro, {useReachBottom} from "@tarojs/taro";
import Empty from "@/components/empty/empty";
import Spinner from "@/components/spinner";
import Img from "@/components/image/image";
const BrandList: FC = () => {
const [page, setPage] = useState(1)
@ -52,13 +53,13 @@ const BrandList: FC = () => {
return (
<View className='p-2' style={{display: text ? 'block' : 'none'}}>
<View className='p-2'>
<Spinner enable={loading} overlay/>
{
brands.length ?
<>
{brands.map((d) => <View onClick={() => jumpInfo(d.id)} className={styles.box} key={d.id}>
<Image src={d.logo} mode='aspectFill' className={styles.image}/>
<Img width={128} height={128} src={d.logo} mode='aspectFill' className={styles.image}/>
<View className={styles.rightBox}>
<View className='font-weight mb-2 font-28'>{d.name}</View>
<View className={styles.desc}>{d.graphic_introduction}</View>

@ -13,13 +13,6 @@
overflow: hidden;
margin-bottom: 20rpx;
position: relative;
image,
Image {
background: #eee;
width: 100%;
min-height: 345rpx;
}
}
.play {

@ -5,16 +5,23 @@ import Taro, {useReachBottom} from "@tarojs/taro";
import styles from './health.module.scss'
import play from '@/static/img/play.png'
import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner";
import Img from "@/components/image/image";
const Health: FC = () => {
const [page, setPage] = useState(1)
const [data, setData] = useState<Health[]>([])
const [total, setTotal] = useState(0)
const [enable, setEnable] = useState(true)
async function getData(page: number) {
try {
const res = await HomeApi.health(page, 10)
setData(res.data)
setTotal(res.total)
} catch (e) {
}
setEnable(false)
}
useReachBottom(() => {
@ -32,11 +39,12 @@ const Health: FC = () => {
return (
<ScrollView>
<Spin enable={enable} overlay/>
<View className={styles.container}>
{
data.length > 0
? data.map(d => <View key={d.id} className={styles.health} onClick={() => jump(d)}>
<Image src={d.url_path} mode='widthFix' lazyLoad fadeIn/>
<Img width={370} height={345} src={d.url_path} mode='widthFix'/>
<Image src={play} className={styles.play} mode='aspectFit'/>
<View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View>
<View className='font-26 text-muted mx-2 mb-2'>{d.video_view}</View>

@ -4,29 +4,31 @@ import styles from './list.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import {illnessApi} from "@/api/illness";
import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner";
const BrandList: FC = () => {
const params = useRouter().params as unknown as { id: number }
const [page, setPage] = useState(1)
const [articles, setArticles] = useState<any[]>([])
const [illness,setIllness] = useState<{name:string;description:string;resource:any;album:string[]}>()
// const [illness, setIllness] = useState<{ name: string; description: string; resource: any; album: string[] }>()
const [total, setTotal] = useState(0)
const [fetchDone, setFetchDone] = useState(false)
const [enable, setEnable] = useState(true)
useEffect(() => {
Taro.showLoading({title: '加载中', mask: true})
getData().then()
}, [page])
const getData = useCallback(async () => {
try {
const data = await illnessApi.articleInfo(params.id, page, 20)
Taro.setNavigationBarTitle({title:data.illness.name})
setIllness(data.illness)
Taro.setNavigationBarTitle({title: data?.illness?.name || '暂无文章'})
// setIllness(data.illness)
setTotal(data.list.total)
setArticles([...articles, ...data.list.list])
} catch (e) {
}
setEnable(false)
setFetchDone(true)
Taro.hideLoading()
}, [page])
@ -44,12 +46,17 @@ const BrandList: FC = () => {
return (
<View style={{display: fetchDone ? 'block' : 'none'}} className='px-2 mt-2 bg-white'>
<View style={{display: fetchDone ? 'block' : 'none'}} className='px-2 mt-2'>
<Spin enable={enable} overlay/>
{
articles.length > 0 ?
<View className='bg-white'>
{
articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}>
{index + 1} . {d.title}
</View>)
}
</View>
: <Empty name='暂无文章'/>
}
</View>

@ -7,6 +7,7 @@ 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";
const prefix = 'SORT'
const Sort: FC = () => {
@ -14,16 +15,24 @@ const Sort: FC = () => {
const [firstId, setFirstId] = useState<number | undefined>(undefined) // 一级分类
const [secondId, setSecondId] = useState<number | undefined>(undefined) // 二级分类
const [list, setList] = useState<any[]>([])
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) {
setFirstId(res[0].id)
setSecondId(res[0]?.resource_category?.[0].id)
}
} catch (e) {
setLoading(false)
}
setEnable(false)
}
function jump(id: number) {
@ -54,17 +63,16 @@ const Sort: FC = () => {
useEffect(() => {
if (secondId) {
Taro.showLoading({title: '加载中'})
setLoading(true)
illnessApi.list(secondId, 1, 100).then(res => {
setList(res.list)
}).finally(() => {
Taro.hideLoading()
}).catch(() => {
setList([])
})
} else {
setList([])
}
setLoading(false)
}, [secondId])
function swiperChange(e) {
@ -76,6 +84,7 @@ const Sort: FC = () => {
return (
<View>
<Spin enable={enable} overlay/>
<View style={headerStyles}>
<Image src={leftArrow}
mode='widthFix'
@ -118,11 +127,15 @@ const Sort: FC = () => {
scrollY
className={styles.tree}
scrollWithAnimation>
{
loading ? <Spin enable={loading}/> : <>
{
list.length ?
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)
: <Empty name='暂无数据'/>
}
</>
}
</ScrollView>
</SwiperItem>)
}

@ -10,13 +10,10 @@
box-sizing: border-box;
display: flex;
margin-bottom: 20rpx;
}
Image,
image {
width: 320rpx;
max-height: 180rpx;
.image {
margin-right: 20rpx;
border-radius: 10rpx;
background: #eee;
}
}

@ -1,10 +1,12 @@
import {Image, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components";
import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components";
import {HomeApi} from "@/api";
import {useEffect, useState} from "react";
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import Empty from "@/components/empty/empty";
import Taro from "@tarojs/taro";
import styles from './profession.module.scss'
import Spin from "@/components/spinner";
import Img from "@/components/image/image";
interface KillData {
data: Kill[]
@ -16,6 +18,7 @@ const Profession = () => {
const [tabs, setTabs] = useState<TabList[]>([])
const [categoryId, setCategoryId] = useState<number | null>(null)
const [data, setData] = useState<Map<number, KillData>>(new Map)
const [enable, setEnable] = useState(true)
/**
* more
@ -32,9 +35,6 @@ const Profession = () => {
}
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)
@ -54,7 +54,6 @@ const Profession = () => {
setData(oldData)
} catch (e) {
}
Taro.hideLoading()
}
useEffect(() => {
@ -62,10 +61,14 @@ const Profession = () => {
}, [categoryId])
async function getCategory() {
try {
const res = await HomeApi.skillCategory()
const newTabs = res.map<TabList>(d => ({title: d.name, value: d.id}))
setTabs(newTabs)
setCategoryId(newTabs[0].value as number)
} catch (e) {
}
setEnable(false)
}
function tabsChange(tab: OnChangOpt) {
@ -96,7 +99,7 @@ const Profession = () => {
{
data.data.map(d =>
<View className={styles.killBox} onClick={() => jump(d)}>
<Image src={d.url_path} mode='widthFix'/>
<Img width={320} height={180} src={d.url_path} mode='widthFix' className={styles.image}/>
<View className='text-ellipsis flex-1'>{d?.resource?.name}</View>
</View>
)
@ -108,6 +111,7 @@ const Profession = () => {
return (
<>
<Spin enable={enable} overlay/>
<View className='bg-white'>
<Tabs tabList={tabs} onChange={tabsChange} current={categoryId!}/>
</View>

@ -59,11 +59,6 @@ taro-button-core::after {
align-items: center;
justify-content: center;
}
.image {
width: 68px;
height: 68px;
}
}
.Textarea {

Loading…
Cancel
Save