替换微信加载状态 && 替换网络图片加载公共组件

v2
king 1 year ago
parent 20564f42fb
commit bcbf3b8e41
  1. 2
      src/components/empty/empty.tsx
  2. 7
      src/components/popPut/popPut.tsx
  3. 44
      src/pages/business/videoInfo/videoInfo.tsx
  4. 2
      src/pages/home/home.tsx
  5. 2
      src/pages/index/index.config.ts
  6. 4
      src/pages/manage/courseAdmin/courseAdmin.tsx
  7. 4
      src/pages/manage/depAdmin/depAdmin.tsx
  8. 4
      src/pages/manage/selectDep/selectDep.tsx
  9. 5
      src/pages/manage/userInfo/components/info.tsx
  10. 1
      src/pages/manage/userInfo/userInfo.module.scss
  11. 88
      src/pages/preview/brand/info/info.tsx
  12. 7
      src/pages/preview/brand/list/list.tsx
  13. 7
      src/pages/preview/health/health.module.scss
  14. 3
      src/pages/preview/health/health.tsx
  15. 23
      src/pages/preview/illness/list/list.tsx
  16. 13
      src/pages/preview/profession/profession.module.scss
  17. 9
      src/pages/preview/profession/profession.tsx
  18. 5
      src/static/css/module.scss

@ -10,7 +10,7 @@ interface Props {
const Empty: FC<Props> = ({name}) => { const Empty: FC<Props> = ({name}) => {
return ( return (
<View className={styles.empty}> <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 className={styles.name}>{name}</View>
</View> </View>
) )

@ -1,7 +1,8 @@
import {FC, ReactNode, useEffect, useState} from "react"; import {FC, ReactNode, useEffect, useState} from "react";
import {View, Image} from "@tarojs/components"; import {View} from "@tarojs/components";
import Icon from "@/components/icon"; import Icon from "@/components/icon";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; import CustomPageContainer from "@/components/custom-page-container/custom-page-container";
import Img from "@/components/image/image";
interface Props { interface Props {
height?: number | string 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='card' onClick={click} style={style()}>
<View className='flex align-center'> <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>{title}</View>
</View> </View>
<View className='card-content'> <View className='card-content'>
<View>{content}</View> <View>{content}</View>
{!chevron && <Icon name='chevron-right'/>} {!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>
</View> </View>
{ {

@ -9,7 +9,6 @@ import eventsIndex from "@/hooks/eventsIndex";
import {formatMinute} from "@/utils/time"; import {formatMinute} from "@/utils/time";
import videoEvents from "@/hooks/videoEvents"; import videoEvents from "@/hooks/videoEvents";
import unique_ident from "@/hooks/unique_ident"; import unique_ident from "@/hooks/unique_ident";
import Spin from "@/components/spinner";
import Img from "@/components/image/image"; import Img from "@/components/image/image";
const VideoInfo: FC = () => { const VideoInfo: FC = () => {
@ -18,7 +17,6 @@ const VideoInfo: FC = () => {
const [playId, setPlayId] = useState<number | null>(null) const [playId, setPlayId] = useState<number | null>(null)
const [preview, setPreview] = useState(false) // 预览 const [preview, setPreview] = useState(false) // 预览
const [playing, setPlaying] = useState(false) // 学习中 const [playing, setPlaying] = useState(false) // 学习中
const [enable, setEnable] = useState(true)
const getData = useCallback(async (playing: boolean) => { const getData = useCallback(async (playing: boolean) => {
try { try {
@ -27,7 +25,6 @@ const VideoInfo: FC = () => {
playId != null && currentVideo(res, playing) // 用于自动播放 判断当前课程是否完成 playId != null && currentVideo(res, playing) // 用于自动播放 判断当前课程是否完成
} catch (e) { } catch (e) {
} }
setEnable(false)
}, [playing, playId]) }, [playing, playId])
const curEnd = (test?: boolean) => { const curEnd = (test?: boolean) => {
@ -106,31 +103,28 @@ const VideoInfo: FC = () => {
videoEvents.videoOff() videoEvents.videoOff()
}) })
return ( return (
<> <View className='content'>
<Spin enable={enable} overlay/> <View className='content-video'>
<View className='content'> {
<View className='content-video'> playId
{ ? <Course id={playId} courseId={id} curEnd={curEnd} preview={preview}/>
playId : <Img width={750} height={500} src={data?.course.thumb || ''} mode='aspectFill'/>
? <Course id={playId} courseId={id} curEnd={curEnd} preview={preview}/> }
: <Img width={750} height={500} src={data?.course.thumb || ''} mode='aspectFill'/> </View>
}
</View>
<View className='header'> <View className='header'>
<View className='flex justify-between text-muted'> <View className='flex justify-between text-muted'>
<Text className='font-34 text-warning'>{data?.is_required ? '必修' : '选修'}</Text> <Text className='font-34 text-warning'>{data?.is_required ? '必修' : '选修'}</Text>
<Text className='font-24'>{data?.course.class_hour}</Text> <Text className='font-24'>{data?.course.class_hour}</Text>
</View> </View>
<View className='font-weight font-36 my-2'>{data?.course.title}</View> <View className='font-weight font-36 my-2'>{data?.course.title}</View>
<View className='text-muted font-26 mt-3'> <View className='text-muted font-26 mt-3'>
<Text className='mr-2'>{formatMinute(data?.duration || 0)}</Text> <Text className='mr-2'>{formatMinute(data?.duration || 0)}</Text>
<Text>{((data?.learn_hour_records.length || 0) / (data?.course.class_hour || 1) * 100).toFixed(0)}%</Text> <Text>{((data?.learn_hour_records.length || 0) / (data?.course.class_hour || 1) * 100).toFixed(0)}%</Text>
</View>
</View> </View>
<Catalogue data={data} setHors={setHors} id={id} playId={playId}/>
</View> </View>
</> <Catalogue data={data} setHors={setHors} id={id} playId={playId}/>
</View>
) )
} }

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

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

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

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

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

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

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

@ -7,6 +7,7 @@ import LineEllipsis from "@/components/textCollapse/collapse";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Img from "@/components/image/image"; import Img from "@/components/image/image";
import {rfc33392time} from "@/utils/day"; import {rfc33392time} from "@/utils/day";
import Spin from "@/components/spinner";
type Params = { type Params = {
id: number id: number
@ -15,18 +16,12 @@ const BrandInfo: FC = () => {
const {id} = useRouter().params as unknown as Params const {id} = useRouter().params as unknown as Params
const [brandInfo, setBrandInfo] = useState<BrandRecord>() const [brandInfo, setBrandInfo] = useState<BrandRecord>()
const [articleList, setArticleList] = useState<ArticleRecord[]>([]) const [articleList, setArticleList] = useState<ArticleRecord[]>([])
const [curIndex,setCurIndex] = useState<number>(1) const [curIndex, setCurIndex] = useState<number>(1)
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [total, setTotal] = useState(0) const [total, setTotal] = useState(0)
const [enable, setEnable] = useState(true)
useEffect(() => { useEffect(() => {
Taro.showLoading({
title: '加载中',
mask: true
})
setTimeout(function () {
Taro.hideLoading()
}, 1000)
getData() getData()
}, [id]) }, [id])
@ -35,7 +30,7 @@ const BrandInfo: FC = () => {
const data = await brandApi.info(id) const data = await brandApi.info(id)
Taro.setNavigationBarTitle({title: data.name}) Taro.setNavigationBarTitle({title: data.name})
setBrandInfo(data) setBrandInfo(data)
const data1 = await brandApi.articleList(id,page) const data1 = await brandApi.articleList(id, page)
setTotal(data1.total) setTotal(data1.total)
setArticleList([ setArticleList([
...(articleList || []), ...(articleList || []),
@ -44,6 +39,7 @@ const BrandInfo: FC = () => {
} catch (e) { } catch (e) {
// setBrandInfo({disabled: 0, graphic_introduction: "", id: 0, introductory_video: "", name: "", brand_album:['1','2','3']}) // setBrandInfo({disabled: 0, graphic_introduction: "", id: 0, introductory_video: "", name: "", brand_album:['1','2','3']})
} }
setEnable(false)
} }
useReachBottom(useCallback(() => { useReachBottom(useCallback(() => {
@ -53,7 +49,7 @@ const BrandInfo: FC = () => {
}, [total, articleList])) }, [total, articleList]))
useEffect(() => { useEffect(() => {
brandApi.articleList(id,page).then(res => { brandApi.articleList(id, page).then(res => {
setTotal(res.total) setTotal(res.total)
setArticleList([ setArticleList([
...(articleList || []), ...(articleList || []),
@ -63,46 +59,46 @@ const BrandInfo: FC = () => {
}, [page]) }, [page])
function onChange(e){ function onChange(e) {
console.log(e) setCurIndex(+e.detail.current + 1)
setCurIndex(+e.detail.current+1)
} }
return ( return (
<View className='flex flex-column' style={{display:brandInfo?'flex':'none'}}> <View className='flex flex-column' style={{display: 'flex'}}>
<Swiper <Spin enable={enable} overlay/>
className={styles['swiper']} <Swiper
indicatorColor='#999' className={styles['swiper']}
indicatorActiveColor='#333' indicatorColor='#999'
indicatorDots={false} indicatorActiveColor='#333'
onChange={onChange} indicatorDots={false}
onChange={onChange}
> >
{ brandInfo?.introductory_video_resource?.url && <SwiperItem> {brandInfo?.introductory_video_resource?.url && <SwiperItem>
<Video <Video
style={{width: '750rpx', height: '600rpx'}} style={{width: '750rpx', height: '600rpx'}}
playBtnPosition={"center"} playBtnPosition={"center"}
id='video' id='video'
src={brandInfo?.introductory_video_resource?.url} src={brandInfo?.introductory_video_resource?.url}
initialTime={0} initialTime={0}
controls={true} controls={true}
enableProgressGesture={false} enableProgressGesture={false}
showFullscreenBtn={false} showFullscreenBtn={false}
autoplay={false} autoplay={false}
loop={false} loop={false}
muted={false} muted={false}
/> />
</SwiperItem>} </SwiperItem>}
{brandInfo?.brand_album?.length {brandInfo?.brand_album?.length
&& brandInfo?.brand_album?.split(',').map((d) => && brandInfo?.brand_album?.split(',').map((d) =>
<SwiperItem> <SwiperItem>
<Image mode={'aspectFill'} style={{width:'750rpx',height:'600rpx'}} src={d}></Image> <Image mode={'aspectFill'} style={{width: '750rpx', height: '600rpx'}} src={d}></Image>
</SwiperItem>) </SwiperItem>)
} }
</Swiper> </Swiper>
<View className={styles.curIndexBox}> <View className={styles.curIndexBox}>
<Text>{curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1:0)}</Text> <Text>{curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}</Text>
</View> </View>
<View className={styles['body']}> <View className={styles['body']}>
<View className={styles['top']}> <View className={styles['top']}>
<Text className={styles['title']}>{brandInfo?.name}</Text> <Text className={styles['title']}>{brandInfo?.name}</Text>

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

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

@ -6,6 +6,7 @@ import styles from './health.module.scss'
import play from '@/static/img/play.png' import play from '@/static/img/play.png'
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner"; import Spin from "@/components/spinner";
import Img from "@/components/image/image";
const Health: FC = () => { const Health: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
@ -43,7 +44,7 @@ const Health: FC = () => {
{ {
data.length > 0 data.length > 0
? data.map(d => <View key={d.id} className={styles.health} onClick={() => jump(d)}> ? 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'/> <Image src={play} className={styles.play} mode='aspectFit'/>
<View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View> <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> <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 Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import {illnessApi} from "@/api/illness"; import {illnessApi} from "@/api/illness";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner";
const BrandList: FC = () => { const BrandList: FC = () => {
const params = useRouter().params as unknown as { id: number } const params = useRouter().params as unknown as { id: number }
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [articles, setArticles] = useState<any[]>([]) 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 [total, setTotal] = useState(0)
const [fetchDone, setFetchDone] = useState(false) const [fetchDone, setFetchDone] = useState(false)
const [enable, setEnable] = useState(true)
useEffect(() => { useEffect(() => {
Taro.showLoading({title: '加载中', mask: true})
getData().then() getData().then()
}, [page]) }, [page])
const getData = useCallback(async () => { const getData = useCallback(async () => {
try { try {
const data = await illnessApi.articleInfo(params.id, page, 20) const data = await illnessApi.articleInfo(params.id, page, 20)
Taro.setNavigationBarTitle({title:data.illness.name}) Taro.setNavigationBarTitle({title: data?.illness?.name || '暂无文章'})
setIllness(data.illness) // setIllness(data.illness)
setTotal(data.list.total) setTotal(data.list.total)
setArticles([...articles, ...data.list.list]) setArticles([...articles, ...data.list.list])
} catch (e) { } catch (e) {
} }
setEnable(false)
setFetchDone(true) setFetchDone(true)
Taro.hideLoading() Taro.hideLoading()
}, [page]) }, [page])
@ -44,12 +46,17 @@ const BrandList: FC = () => {
return ( 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 ? articles.length > 0 ?
articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}> <View className='bg-white'>
{index + 1} . {d.title} {
</View>) articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}>
{index + 1} . {d.title}
</View>)
}
</View>
: <Empty name='暂无文章'/> : <Empty name='暂无文章'/>
} }
</View> </View>

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

@ -1,4 +1,4 @@
import {Image, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components";
import {HomeApi} from "@/api"; import {HomeApi} from "@/api";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
@ -6,6 +6,7 @@ import Empty from "@/components/empty/empty";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import styles from './profession.module.scss' import styles from './profession.module.scss'
import Spin from "@/components/spinner"; import Spin from "@/components/spinner";
import Img from "@/components/image/image";
interface KillData { interface KillData {
data: Kill[] data: Kill[]
@ -18,7 +19,6 @@ const Profession = () => {
const [categoryId, setCategoryId] = useState<number | null>(null) const [categoryId, setCategoryId] = useState<number | null>(null)
const [data, setData] = useState<Map<number, KillData>>(new Map) const [data, setData] = useState<Map<number, KillData>>(new Map)
const [enable, setEnable] = useState(true) const [enable, setEnable] = useState(true)
const [loading, setLoading] = useState(false)
/** /**
* more * more
@ -35,7 +35,6 @@ const Profession = () => {
} }
try { try {
setLoading(true)
const res = await HomeApi.skillList(categoryId!, page, 10) const res = await HomeApi.skillList(categoryId!, page, 10)
const dataList = res.data.reduce((pre, cur) => { const dataList = res.data.reduce((pre, cur) => {
const index = pre.findIndex(d => d.id === cur.id) const index = pre.findIndex(d => d.id === cur.id)
@ -55,7 +54,6 @@ const Profession = () => {
setData(oldData) setData(oldData)
} catch (e) { } catch (e) {
} }
setLoading(false)
} }
useEffect(() => { useEffect(() => {
@ -101,12 +99,11 @@ const Profession = () => {
{ {
data.data.map(d => data.data.map(d =>
<View className={styles.killBox} onClick={() => jump(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 className='text-ellipsis flex-1'>{d?.resource?.name}</View>
</View> </View>
) )
} }
<Spin enable={loading}/>
</ScrollView> </ScrollView>
) )
} }

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

Loading…
Cancel
Save