diff --git a/src/components/collect/collect.tsx b/src/components/collect/collect.tsx index a1c57fb..974cf0e 100644 --- a/src/components/collect/collect.tsx +++ b/src/components/collect/collect.tsx @@ -18,6 +18,17 @@ interface Props { onUpdate?: (v: boolean) => void } +const versions = new Map() + +const collect = async (scope: string, params: Create, setSelect: (v: boolean) => void, value: boolean) => { + const localVersion = (versions.get(scope) || 0) + 1 + versions.set(scope, localVersion) + await userApi.create(params) + if (localVersion === versions.get(scope)) { + setSelect(value) + } +} + /** 收藏 */ const Collect: FC = (props) => { const {token} = Profile.useContainer() @@ -33,12 +44,16 @@ const Collect: FC = (props) => { Taro.navigateTo({url: '/pages/login/login'}) return } - if (loading) return; props.onClick?.() - await userApi.create({owner_id: props.owner_id, owner_type: props.owner_type}) setSelect(!select) setLoading(true) - props.onUpdate?.(!select) + collect(`${props.owner_id}#${props.owner_type}`, { + owner_id: props.owner_id, + owner_type: props.owner_type, + }, (v) => { + setSelect(v) + props.onUpdate?.(v) + }, !select) setTimeout(() => { setLoading(false) }, 300) diff --git a/src/components/custom-page-container/custom-page-container.module.scss b/src/components/custom-page-container/custom-page-container.module.scss index 7cce758..add4bf3 100644 --- a/src/components/custom-page-container/custom-page-container.module.scss +++ b/src/components/custom-page-container/custom-page-container.module.scss @@ -84,11 +84,11 @@ @keyframes childrenCenter { from { - transform: scale(0); + transform: scale(0) translateY(calc(-50% - 100px)); padding: 0; } to { - transform: scale(1); + transform: scale(1) translateY(calc(-50% - 100px)); padding: 0 30px; } } diff --git a/src/components/custom-page-container/custom-page-container.tsx b/src/components/custom-page-container/custom-page-container.tsx index 35140d0..9bb02d1 100644 --- a/src/components/custom-page-container/custom-page-container.tsx +++ b/src/components/custom-page-container/custom-page-container.tsx @@ -49,7 +49,9 @@ export const PageContainerInner: FC = (props) => { case 'center': style.width = '90%' style.borderRadius = '10px' - style.padding = '0' + style.padding = '0 !important' + style.top = '50%' + // style.transform = 'translateY(-100px) !important' break } @@ -89,14 +91,14 @@ export const PageContainerInner: FC = (props) => { const CustomPageContainer: FC = (props) => { if (props.position === 'center') { - return + return } if (process.env.TARO_ENV !== 'h5') { - return ( + return ( {props.children} ) } - return (); + return (); } export default CustomPageContainer diff --git a/src/components/textCollapse/collapse.module.scss b/src/components/textCollapse/collapse.module.scss index e937475..0d038b2 100644 --- a/src/components/textCollapse/collapse.module.scss +++ b/src/components/textCollapse/collapse.module.scss @@ -1,4 +1,4 @@ -.expansion{ +.expansion { display: inline-block; padding: 0 10rpx; color: #00d6ac; diff --git a/src/components/textCollapse/collapse.tsx b/src/components/textCollapse/collapse.tsx index dac317a..843ad6b 100644 --- a/src/components/textCollapse/collapse.tsx +++ b/src/components/textCollapse/collapse.tsx @@ -8,44 +8,43 @@ interface Props { text: string } -const LineEllipsis:FC = ({text}:Props) => { +const LineEllipsis: FC = ({text}: Props) => { const [disabled, setDisabled] = useState(false) const [isExpansioned, setIsExpansioned] = useState(false) const [overflow, setOverflow] = useState(false) - useEffect(()=>{ + useEffect(() => { init() - },[text]) + }, [text]) - function init () { + function init() { Taro.nextTick(() => { const query = Taro.createSelectorQuery() query.select('#Text').boundingClientRect() query.exec((res) => { - console.log({res}) const height = res[0].height - if(height <= 30) { + if (height <= 105) { setDisabled(true) - }else{ + } else { setOverflow(true) } }) }) } - function handleExpend (e?: ITouchEvent) { + function handleExpend(e?: ITouchEvent) { e && e.stopPropagation(); setOverflow(false) setIsExpansioned(true) } - function handleHide (e?: ITouchEvent) { + function handleHide(e?: ITouchEvent) { e && e.stopPropagation(); setOverflow(true) setIsExpansioned(false) - }; + } - function toggle () { + function toggle() { if (disabled) return; if (isExpansioned) { handleHide(); @@ -54,37 +53,36 @@ const LineEllipsis:FC = ({text}:Props) => { } } - return ( - - - {text} - {!overflow && isExpansioned && ( - - 收起 - - )} - - {overflow && ( - - ...展开 + return ( + + + {text} + {!overflow && isExpansioned && ( + + 收起 )} - ); - // } + {overflow && ( + + . . . 展开 + + )} + + ) } export default LineEllipsis; diff --git a/src/components/videoList/videoList.tsx b/src/components/videoList/videoList.tsx index cf0d7d9..baae6ce 100644 --- a/src/components/videoList/videoList.tsx +++ b/src/components/videoList/videoList.tsx @@ -2,10 +2,10 @@ import {FC, useEffect, useState} from "react"; import styles from "@/pages/preview/health/health.module.scss"; import {Image, Text, View} from "@tarojs/components"; import Img from "@/components/image/image"; -import play from "@/static/img/play-back.png"; -import {formatDate} from "@/utils/time"; import Taro from "@tarojs/taro"; import videoEvent from "@/hooks/videoEvent"; +import palyWhite from '@/static/img/palyWhite.png' +import starWhite from '@/static/img/starWhite.png' interface Props { data: VideList @@ -40,13 +40,24 @@ const VideoList: FC = (props) => { return ( - - - {data.title} - {data.introduction} - - {formatDate(new Date(data.publish_time), "YY-MM-dd")} - {(data.video_view || 0)}观看 + + {data.title} + {data.introduction} + + + + + + {(data.video_view || 0)} + + + + + {(data.video_view || 0)} + + + + 1:00 ) diff --git a/src/pages/preview/brand/article/article.module.scss b/src/pages/preview/brand/article/article.module.scss index 164b692..9a0dacc 100644 --- a/src/pages/preview/brand/article/article.module.scss +++ b/src/pages/preview/brand/article/article.module.scss @@ -46,9 +46,9 @@ page{ z-index: 99; position: fixed; bottom: 0; - width: 690rpx; + width: 650rpx; height: 100rpx; - padding: 0 30rpx env(safe-area-inset-bottom); + padding: 0 50rpx env(safe-area-inset-bottom); display: flex; justify-content: flex-end; align-items: center; diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx index 2c43491..84432da 100644 --- a/src/pages/preview/brand/info/info.tsx +++ b/src/pages/preview/brand/info/info.tsx @@ -1,6 +1,6 @@ import {FC, useCallback, useEffect, useState} from "react"; import {Swiper, SwiperItem, Text, Video, View} from "@tarojs/components"; -import { brandApi, BrandRecord} from "@/api"; +import {brandApi, BrandRecord} from "@/api"; import styles from './info.module.scss' import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; import LineEllipsis from "@/components/textCollapse/collapse"; @@ -112,7 +112,7 @@ const BrandInfo: FC = () => { {brandInfo?.name} - + diff --git a/src/pages/preview/health/health.module.scss b/src/pages/preview/health/health.module.scss index 2387711..5c28c7d 100644 --- a/src/pages/preview/health/health.module.scss +++ b/src/pages/preview/health/health.module.scss @@ -25,3 +25,27 @@ right: 20rpx; background: transparent !important; } + +.info { + font-size: 24rpx; + padding: 0 20rpx; + height: 52rpx; + display: flex; + align-items: center; + justify-content: space-between; + position: absolute; + top: 0; + left: 0; + width: 100%; + transform: translateY(-100%); + box-sizing: border-box; + color: #fff; + background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%); + + Image { + width: 24rpx; + height: 24rpx; + margin-right: 10rpx; + vertical-align: inherit; + } +} diff --git a/src/static/img/palyWhite.png b/src/static/img/palyWhite.png new file mode 100644 index 0000000..004820a Binary files /dev/null and b/src/static/img/palyWhite.png differ diff --git a/src/static/img/starWhite.png b/src/static/img/starWhite.png new file mode 100644 index 0000000..6c49c6b Binary files /dev/null and b/src/static/img/starWhite.png differ