diff --git a/src/components/collect/collect.module.scss b/src/components/collect/collect.module.scss index 5ac8c34..8608a6f 100644 --- a/src/components/collect/collect.module.scss +++ b/src/components/collect/collect.module.scss @@ -1,4 +1,5 @@ .collect { + width: 130rpx; display: flex; align-items: center; color: #909795; diff --git a/src/components/image/image.tsx b/src/components/image/image.tsx index 552ba71..1bffc13 100644 --- a/src/components/image/image.tsx +++ b/src/components/image/image.tsx @@ -6,12 +6,14 @@ import avatar from '@/static/img/avatar.png' import healthShard from '@/static/img/healthShard.png' import professionShard from '@/static/img/professionShard.png' import brandSecond from '@/static/img/brandSecond.png' +import courseShard from '@/static/img/courseShard.png' interface Props extends ImageProps { width?: number | string height?: number | string fallback?: string errorType?: ImgErrType + fit?: boolean // 当网络图片加载完成后高度自动 } const Img: FC = ({src, mode = 'aspectFill', width, fallback = shard, ...props}) => { @@ -24,7 +26,7 @@ const Img: FC = ({src, mode = 'aspectFill', width, fallback = shard, ...p useEffect(() => { - if (!height && !isError && mode !== 'heightFix') { + if (!isError && props.fit) { Taro.getImageInfo({ src, success() { @@ -54,6 +56,9 @@ const Img: FC = ({src, mode = 'aspectFill', width, fallback = shard, ...p case 'brand': setErrorUrl(brandSecond) break + case 'course': + setErrorUrl(courseShard) + break } }, [props.errorType]) @@ -71,16 +76,15 @@ const Img: FC = ({src, mode = 'aspectFill', width, fallback = shard, ...p } return ( - + {!isError && - + = ({src, mode = 'aspectFill', width, fallback = shard, ...p { isError && !loading && + style={{width: "100%", height: '100%'}}/> } ) diff --git a/src/components/videoList/videoList.tsx b/src/components/videoList/videoList.tsx index a202346..c1ece50 100644 --- a/src/components/videoList/videoList.tsx +++ b/src/components/videoList/videoList.tsx @@ -19,7 +19,7 @@ const VideoList: FC = ({data, errorType}) => { return ( - + {data.title} diff --git a/src/pages/home/components/search.tsx b/src/pages/home/components/search.tsx index 34a80d9..fae43f7 100644 --- a/src/pages/home/components/search.tsx +++ b/src/pages/home/components/search.tsx @@ -14,7 +14,6 @@ export const Search: FC = () => { return ( - {/**/} 点击搜索 ) diff --git a/src/pages/home/home.module.scss b/src/pages/home/home.module.scss index ae798de..50e2569 100644 --- a/src/pages/home/home.module.scss +++ b/src/pages/home/home.module.scss @@ -61,7 +61,7 @@ display: flex; align-items: center; box-sizing: border-box; - //justify-content: center; + justify-content: center; height: 68rpx; margin-bottom: 40rpx; font-size: 28rpx; diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index ea00eff..eaa2445 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.tsx +++ b/src/pages/manage/courseAdmin/courseAdmin.tsx @@ -163,7 +163,7 @@ const CourseAdmin: FC = () => { checked={curs.includes(d.id)} style={{marginTop: '30px'}} onClick={() => addCurs(d.id)}/>} - + {d.title} diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index ca1e76e..3f0fe97 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -64,7 +64,7 @@ const article: FC = () => { } const onCollect = (v: boolean | undefined) => { - setArticleInfo((s) => ({...s, collect: v} as ArticleRecord)) + setArticleInfo((s) => ({...s, collect: v} as ArticleRecord)) } Taro.useReady(() => { @@ -87,26 +87,24 @@ const article: FC = () => { function helloWorld() { return ( <> - - - + { + headings.length > 0 && + + + + setShow(true)}> + + 目录 + - { - headings.length > 0 && ( - setShow(true)}> - - 目录 - - ) - } - + } { {articleInfo?.title} { - articleInfo?.brands.map(d => ( + articleInfo?.brands?.map(d => ( @@ -175,12 +173,13 @@ const article: FC = () => { > - setShow(false)}> - + setShow(false)}> + 目录 - + { headings.length > 0 && headings.map((d) => { fontSize: '28rpx', fontWeight: '500', color: maoId === d.id ? '#45D4A8' : '#323635', - marginLeft: 24*(d.level-1) + 'px', + marginLeft: 24 * (d.level - 1) + 'px', }} onClick={() => mao(d.id)}> {d.text} diff --git a/src/pages/preview/brand/info/info.module.scss b/src/pages/preview/brand/info/info.module.scss index eb2bc6f..f92c90d 100644 --- a/src/pages/preview/brand/info/info.module.scss +++ b/src/pages/preview/brand/info/info.module.scss @@ -57,6 +57,7 @@ page{ height:128rpx; background-color: #eee; border-radius: 8rpx; + overflow: hidden; } .leftBox{ padding-right: 24rpx; diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx index f8d2413..26cf4c7 100644 --- a/src/pages/preview/brand/info/info.tsx +++ b/src/pages/preview/brand/info/info.tsx @@ -126,7 +126,7 @@ const BrandInfo: FC = () => { {rfc33392time(i.created_at)} {i.page_view}阅读 - + )} diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx index 01ce6e1..5f3d28f 100644 --- a/src/pages/preview/search/search/components/list.tsx +++ b/src/pages/preview/search/search/components/list.tsx @@ -4,17 +4,17 @@ import styles from './list.module.scss' import Taro from "@tarojs/taro"; import Empty from "@/components/empty/empty"; import Img from "@/components/image/image"; -import { SearchApi } from "@/api/search"; -import { AtLoadMore } from 'taro-ui' +import {SearchApi} from "@/api/search"; +import {AtLoadMore} from 'taro-ui' import {rfc33392time} from "@/utils/day"; -import play from "@/static/img/play.png"; +import play from "@/static/img/play-back.png"; type Props = { - name:string - clear:boolean + name: string + clear: boolean } -const SearchList: FC = ({name,clear}) => { - console.log(name,'name') +const SearchList: FC = ({name, clear}) => { + console.log(name, 'name') const globalData = Taro.getApp().globalData const [page, setPage] = useState(1) const [brands, setBrands] = useState([]) @@ -22,21 +22,21 @@ const SearchList: FC = ({name,clear}) => { const [text, setText] = useState('') const [loading, setLoading] = useState(true) - useEffect(()=>{ - if(!clear){ + useEffect(() => { + if (!clear) { setBrands([]) setLoading(true) } - },[clear]) + }, [clear]) useEffect(() => { - if(name && clear){ + if (name && clear) { getData() } - }, [page,name,clear]) + }, [page, name, clear]) const getData = useCallback(async () => { try { - const data = await SearchApi.list(page, 10,name) + const data = await SearchApi.list(page, 10, name) if (page === 1) { if (data.data.length < 10) { setText('没有更多了~') @@ -46,7 +46,7 @@ const SearchList: FC = ({name,clear}) => { setBrands([ ...data.data ]) - }else{ + } else { setBrands([ ...brands, ...data.data @@ -57,13 +57,13 @@ const SearchList: FC = ({name,clear}) => { } catch (e) { } setLoading(false) - }, [page,name]) + }, [page, name]) - function jumpInfo(id: number,type:string) { - console.log(type,'type') + function jumpInfo(id: number, type: string) { + console.log(type, 'type') let url = '' - switch (type){ + switch (type) { case 'brand': url = '/pages/preview/brand/info/info'; break; @@ -81,13 +81,13 @@ const SearchList: FC = ({name,clear}) => { } - function onScrollToLower(){ - if (brands?.length < total) { - setPage(page + 1) - getData().then() - } else { - setText('没有更多了~') - } + function onScrollToLower() { + if (brands?.length < total) { + setPage(page + 1) + getData().then() + } else { + setText('没有更多了~') + } } return ( @@ -95,65 +95,71 @@ const SearchList: FC = ({name,clear}) => { className='scrollview' scrollY scrollWithAnimation - style={{height:`${globalData.screenHeight-140}px`,backgroundColor:`#f5f5f5`}} + style={{height: `${globalData.screenHeight - 140}px`, backgroundColor: `#f5f5f5`}} onScrollToLower={onScrollToLower} > - { loading && } + {loading && } { brands.length >= 1 && !loading && - <> - {brands.map((d) => - jumpInfo(d.data.id,d.data.table)} className={styles.box} key={d.data.id}> - { - d.data.table === 'brand' && - <> - - - {d.data.title} - {d.data.content || '暂无品牌简介'} - - - } - { - d.data.table === 'article' && - <> - - {d.data['@data'].title} - {rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}阅读 - - - - } - { - d.data.table === 'video_records' && - <> - - - - {d.data['@data'].title} - {d.data['@data'].introduction} - 播放量: {d.data['@data'].video_view} - - - } - { - d.data.table === 'courses' && - <> - - - {d.data['@data'].title} - 课时:{d.data['@data'].class_hour}节 销量:{d.data['@data'].charge} - - - } - - - ) - } - {text} - + <> + {brands.map((d) => + jumpInfo(d.data.id, d.data.table)} className={styles.box} key={d.data.id}> + { + d.data.table === 'brand' && + <> + + + {d.data.title} + {d.data.content || '暂无品牌简介'} + + + } + { + d.data.table === 'article' && + <> + + {d.data['@data'].title} + {rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}阅读 + + + + } + { + d.data.table === 'video_records' && + <> + + + + {d.data['@data'].title} + {d.data['@data'].introduction} + 播放量: {d.data['@data'].video_view} + + + } + { + d.data.table === 'courses' && + <> + + + {d.data['@data'].title} + 课时:{d.data['@data'].class_hour}节 + 销量:{d.data['@data'].charge} + + + } + + ) + } + {text} + } - { !loading && brands.length === 0 && } + {!loading && brands.length === 0 && } ) } diff --git a/src/pages/preview/search/search/index.tsx b/src/pages/preview/search/search/index.tsx index f68dbaa..a2138c6 100644 --- a/src/pages/preview/search/search/index.tsx +++ b/src/pages/preview/search/search/index.tsx @@ -142,7 +142,7 @@ const Search: FC = () => { round overlay overlayStyle={'background:rgba(0,0,0,0)'}> - + {show && } ) diff --git a/src/static/img/组 498@2x.png b/src/static/img/组 498@2x.png deleted file mode 100644 index 5b31ee2..0000000 Binary files a/src/static/img/组 498@2x.png and /dev/null differ diff --git a/types/user.d.ts b/types/user.d.ts index bf03a84..9541359 100644 --- a/types/user.d.ts +++ b/types/user.d.ts @@ -114,5 +114,6 @@ type ImgErrType = "acquiesce" // 默认 | 'health' // 健康 | 'profession' // 技能 | 'brand' // 品牌 + | 'course' // 课程