diff --git a/src/components/image/image.tsx b/src/components/image/image.tsx index 80abee8..552ba71 100644 --- a/src/components/image/image.tsx +++ b/src/components/image/image.tsx @@ -14,15 +14,24 @@ interface Props extends ImageProps { errorType?: ImgErrType } -const Img: FC = ({src, mode = 'aspectFill', width, height, fallback = shard, ...props}) => { +const Img: FC = ({src, mode = 'aspectFill', width, fallback = shard, ...props}) => { const [isError, setIsError] = useState(false) const [loading, setLoading] = useState(true) const [errorUrl, setErrorUrl] = useState(fallback) - + const [height, setHeight] = useState(props.height) const imgAnimation = Taro.createAnimation({duration: 0}).opacity(0).step() const [animationData, setAnimationData] = useState(imgAnimation.export()) + useEffect(() => { + if (!height && !isError && mode !== 'heightFix') { + Taro.getImageInfo({ + src, + success() { + setHeight(undefined) + } + }) + } setIsError(!src) setLoading(!!src) }, [src]) diff --git a/src/components/videoList/videoList.tsx b/src/components/videoList/videoList.tsx index 942390f..a202346 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/feature_recommended.tsx b/src/pages/home/components/feature_recommended.tsx index ddcdb2e..b7218f1 100644 --- a/src/pages/home/components/feature_recommended.tsx +++ b/src/pages/home/components/feature_recommended.tsx @@ -2,7 +2,6 @@ import {FC, useEffect, useState} from "react"; import {Image, Swiper, SwiperItem, View} from "@tarojs/components"; import styles from '../home.module.scss' import Taro from "@tarojs/taro"; -import {HomeApi} from "@/api"; import first from '@/static/img/first.png' import second from '@/static/img/second.png' import third from '@/static/img/third.png' @@ -27,7 +26,6 @@ interface Data { detailsUrl: string data: DataContent[] errorType: ImgErrType - type?: 'health' | 'kill' } interface Props { @@ -51,7 +49,6 @@ const FeatureRecommended: FC = (props) => { url: '/pages/preview/health/health', detailsUrl: '/pages/preview/videoFull/videoFull', data: [], - type: "health", errorType: 'health' }, { @@ -59,7 +56,6 @@ const FeatureRecommended: FC = (props) => { url: '/pages/preview/profession/profession', detailsUrl: '/pages/preview/videoFull/videoFull', data: [], - type: 'kill', errorType: 'profession' }, { @@ -94,7 +90,7 @@ const FeatureRecommended: FC = (props) => { title: d.title, imageUrl: d.url_path, description: d.introduction, - path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.title}` + path: `?id=${d.id}`, })) } catch (e) { } @@ -109,7 +105,7 @@ const FeatureRecommended: FC = (props) => { imageUrl: d.url_path, description: d.introduction, title: d.title, - path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.title}` + path: `?id=${d.id}`, })) } catch (e) { } @@ -142,15 +138,8 @@ const FeatureRecommended: FC = (props) => { }) }, [props]) - // TODO 后续增加播放量使用公共接口 - function jump(url: string, playId?: number, type?: 'health' | 'kill') { - if (playId && type) { - if (type === 'health') { - HomeApi.healthSetPlay(playId) - } else if (type === 'kill') { - HomeApi.skillSetPlay(playId) - } - } + function jump(url: string, data: any) { + Taro.preload(data) Taro.navigateTo({url}) } @@ -162,13 +151,13 @@ const FeatureRecommended: FC = (props) => { jump(d.url)} src={d.titleUrl}/> + onClick={() => jump(d.url, d)} src={d.titleUrl}/> { d.data.length > 0 && d.data.map((c, index) => jump(d.detailsUrl + c.path, c.id, d.type)}> + onClick={() => jump(d.detailsUrl + c.path, d)}> diff --git a/src/pages/home/components/search.tsx b/src/pages/home/components/search.tsx index e1ee676..34a80d9 100644 --- a/src/pages/home/components/search.tsx +++ b/src/pages/home/components/search.tsx @@ -13,7 +13,7 @@ export const Search: FC = () => { return ( - + {/**/} 点击搜索 diff --git a/src/pages/home/home.module.scss b/src/pages/home/home.module.scss index a373175..ae798de 100644 --- a/src/pages/home/home.module.scss +++ b/src/pages/home/home.module.scss @@ -61,17 +61,13 @@ display: flex; align-items: center; box-sizing: border-box; - justify-content: center; + //justify-content: center; height: 68rpx; margin-bottom: 40rpx; font-size: 28rpx; font-family: PingFang SC-Medium, PingFang SC; color: #909795; line-height: 1; - - view { - margin-left: 8rpx; - } } .adware { diff --git a/src/pages/manage/courseAdmin/courseAdmin.module.scss b/src/pages/manage/courseAdmin/courseAdmin.module.scss index de29a19..f35b762 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.module.scss +++ b/src/pages/manage/courseAdmin/courseAdmin.module.scss @@ -42,8 +42,6 @@ } .curImage { - width: 280rpx; - height: 164rpx; border-radius: 10rpx; margin: 0 20px 0 0; background: #eee; diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index 4799fc6..ea00eff 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/health/health.tsx b/src/pages/preview/health/health.tsx index d07188e..7ff82e3 100644 --- a/src/pages/preview/health/health.tsx +++ b/src/pages/preview/health/health.tsx @@ -18,7 +18,7 @@ const Health: FC = () => { const res = await HomeApi.health(page, 10) setData([ ...data, - ...res.data + ...res.data, ]) setTotal(res.total) } catch (e) { diff --git a/src/pages/preview/videoFull/videoFull.module.scss b/src/pages/preview/videoFull/videoFull.module.scss index 59613a0..27da24d 100644 --- a/src/pages/preview/videoFull/videoFull.module.scss +++ b/src/pages/preview/videoFull/videoFull.module.scss @@ -10,7 +10,7 @@ page { top: 0; left: 0; right: 0; - bottom: calc(env(safe-area-inset-bottom) + 250rpx); + bottom: calc(env(safe-area-inset-bottom) + 320rpx); margin: auto; background: #000; } @@ -21,7 +21,7 @@ page { bottom: env(safe-area-inset-bottom); width: 100%; color: #fff; - padding: 0 30rpx; + padding:20rpx 30rpx; box-sizing: border-box; background: #000; width: 100%;