1.修改弹窗居中动画

2.修改收藏多次触发
v2
king 1 year ago
parent 358c3ee95c
commit aa4e006b00
  1. 21
      src/components/collect/collect.tsx
  2. 4
      src/components/custom-page-container/custom-page-container.module.scss
  3. 10
      src/components/custom-page-container/custom-page-container.tsx
  4. 2
      src/components/textCollapse/collapse.module.scss
  5. 76
      src/components/textCollapse/collapse.tsx
  6. 29
      src/components/videoList/videoList.tsx
  7. 4
      src/pages/preview/brand/article/article.module.scss
  8. 4
      src/pages/preview/brand/info/info.tsx
  9. 24
      src/pages/preview/health/health.module.scss
  10. BIN
      src/static/img/palyWhite.png
  11. BIN
      src/static/img/starWhite.png

@ -18,6 +18,17 @@ interface Props {
onUpdate?: (v: boolean) => void 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> = (props) => { const Collect: FC<Props> = (props) => {
const {token} = Profile.useContainer() const {token} = Profile.useContainer()
@ -33,12 +44,16 @@ const Collect: FC<Props> = (props) => {
Taro.navigateTo({url: '/pages/login/login'}) Taro.navigateTo({url: '/pages/login/login'})
return return
} }
if (loading) return;
props.onClick?.() props.onClick?.()
await userApi.create({owner_id: props.owner_id, owner_type: props.owner_type})
setSelect(!select) setSelect(!select)
setLoading(true) 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(() => { setTimeout(() => {
setLoading(false) setLoading(false)
}, 300) }, 300)

@ -84,11 +84,11 @@
@keyframes childrenCenter { @keyframes childrenCenter {
from { from {
transform: scale(0); transform: scale(0) translateY(calc(-50% - 100px));
padding: 0; padding: 0;
} }
to { to {
transform: scale(1); transform: scale(1) translateY(calc(-50% - 100px));
padding: 0 30px; padding: 0 30px;
} }
} }

@ -49,7 +49,9 @@ export const PageContainerInner: FC<PageContainerProps> = (props) => {
case 'center': case 'center':
style.width = '90%' style.width = '90%'
style.borderRadius = '10px' style.borderRadius = '10px'
style.padding = '0' style.padding = '0 !important'
style.top = '50%'
// style.transform = 'translateY(-100px) !important'
break break
} }
@ -89,14 +91,14 @@ export const PageContainerInner: FC<PageContainerProps> = (props) => {
const CustomPageContainer: FC<PageContainerProps> = (props) => { const CustomPageContainer: FC<PageContainerProps> = (props) => {
if (props.position === 'center') { if (props.position === 'center') {
return <PageContainerInner {...props} /> return <PageContainerInner {...props} onAfterLeave={props.onClickOverlay}/>
} }
if (process.env.TARO_ENV !== 'h5') { if (process.env.TARO_ENV !== 'h5') {
return (<PageContainer {...props} round> return (<PageContainer {...props} round onAfterLeave={props.onClickOverlay}>
<View className={styles.content} style={{position: 'relative'}}>{props.children}</View> <View className={styles.content} style={{position: 'relative'}}>{props.children}</View>
</PageContainer>) </PageContainer>)
} }
return (<PageContainerInner {...props} />); return (<PageContainerInner {...props} onAfterLeave={props.onClickOverlay}/>);
} }
export default CustomPageContainer export default CustomPageContainer

@ -1,4 +1,4 @@
.expansion{ .expansion {
display: inline-block; display: inline-block;
padding: 0 10rpx; padding: 0 10rpx;
color: #00d6ac; color: #00d6ac;

@ -8,44 +8,43 @@ interface Props {
text: string text: string
} }
const LineEllipsis:FC<Props> = ({text}:Props) => { const LineEllipsis: FC<Props> = ({text}: Props) => {
const [disabled, setDisabled] = useState(false) const [disabled, setDisabled] = useState(false)
const [isExpansioned, setIsExpansioned] = useState(false) const [isExpansioned, setIsExpansioned] = useState(false)
const [overflow, setOverflow] = useState(false) const [overflow, setOverflow] = useState(false)
useEffect(()=>{ useEffect(() => {
init() init()
},[text]) }, [text])
function init () { function init() {
Taro.nextTick(() => { Taro.nextTick(() => {
const query = Taro.createSelectorQuery() const query = Taro.createSelectorQuery()
query.select('#Text').boundingClientRect() query.select('#Text').boundingClientRect()
query.exec((res) => { query.exec((res) => {
console.log({res})
const height = res[0].height const height = res[0].height
if(height <= 30) { if (height <= 105) {
setDisabled(true) setDisabled(true)
}else{ } else {
setOverflow(true) setOverflow(true)
} }
}) })
}) })
} }
function handleExpend (e?: ITouchEvent) { function handleExpend(e?: ITouchEvent) {
e && e.stopPropagation(); e && e.stopPropagation();
setOverflow(false) setOverflow(false)
setIsExpansioned(true) setIsExpansioned(true)
} }
function handleHide (e?: ITouchEvent) { function handleHide(e?: ITouchEvent) {
e && e.stopPropagation(); e && e.stopPropagation();
setOverflow(true) setOverflow(true)
setIsExpansioned(false) setIsExpansioned(false)
}; }
function toggle () { function toggle() {
if (disabled) return; if (disabled) return;
if (isExpansioned) { if (isExpansioned) {
handleHide(); handleHide();
@ -54,37 +53,36 @@ const LineEllipsis:FC<Props> = ({text}:Props) => {
} }
} }
return ( return (
<View <View
id="wrap" id="wrap"
style={{ style={{
position: 'relative', position: 'relative',
color: '#999795', color: '#999795',
fontSize: '25rpx', fontSize: '25rpx',
overflow: overflow ? 'hidden' : 'unset', overflow: overflow ? 'hidden' : 'unset',
height: overflow ? '35rpx' : 'unset', height: overflow ? '105rpx' : 'unset',
lineHeight: overflow ? '35rpx' : '35rpx', lineHeight: overflow ? '35rpx' : '35rpx',
marginTop:'24rpx', marginTop: '24rpx',
}}> }}>
<View id='Text' onClick={toggle}> <View id='Text' onClick={toggle}>
{text} {text}
{!overflow && isExpansioned && ( {!overflow && isExpansioned && (
<Text className={styles.expansion} onClick={handleHide}> <Text className={styles.expansion} onClick={handleHide}>
</Text>
)}
</View>
{overflow && (
<Text
className={styles.expansion}
onClick={handleExpend}
style={{position: 'absolute', top: '0', right: '0', background: '#fff'}}>
...
</Text> </Text>
)} )}
</View> </View>
); {overflow && (
// } <Text
style={{position: "absolute", top: "70rpx", right: "0", background: "#fff"}}
className={styles.expansion}
onClick={handleExpend}>
. . .
</Text>
)}
</View>
)
} }
export default LineEllipsis; export default LineEllipsis;

@ -2,10 +2,10 @@ import {FC, useEffect, useState} from "react";
import styles from "@/pages/preview/health/health.module.scss"; import styles from "@/pages/preview/health/health.module.scss";
import {Image, Text, View} from "@tarojs/components"; import {Image, Text, View} from "@tarojs/components";
import Img from "@/components/image/image"; 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 Taro from "@tarojs/taro";
import videoEvent from "@/hooks/videoEvent"; import videoEvent from "@/hooks/videoEvent";
import palyWhite from '@/static/img/palyWhite.png'
import starWhite from '@/static/img/starWhite.png'
interface Props { interface Props {
data: VideList data: VideList
@ -40,13 +40,24 @@ const VideoList: FC<Props> = (props) => {
return ( return (
<View key={data.id} className={styles.health} onClick={jump}> <View key={data.id} className={styles.health} onClick={jump}>
<Img src={data.url_path} mode='widthFix' errorType={props.errorType} height={346}/> <Img src={data.url_path} mode='widthFix' errorType={props.errorType} height={346}/>
<Image src={play} className={styles.play} mode='aspectFit'/> <View className='p-2 relative'>
<View className='p-1'> <View className='text-ellipsis-1 font-28 text-dark'>{data.title}</View>
<View className='text-ellipsis-2 text-dark'>{data.title}</View> <View className='text-ellipsis-2 mt-2 font-24 text-secondary'>{data.introduction}</View>
<View className='text-ellipsis-2 mt-1 font-26 text-secondary'>{data.introduction}</View>
<View className='font-24 text-muted my-2 flex justify-between'> <View className={styles.info}>
<Text>{formatDate(new Date(data.publish_time), "YY-MM-dd")}</Text> <View className='flex'>
<Text>{(data.video_view || 0)}</Text> <View className='flex align-center mr-3'>
<Image src={palyWhite}/>
<Text>{(data.video_view || 0)}</Text>
</View>
<View className='flex align-center'>
<Image src={starWhite}/>
<Text>{(data.video_view || 0)}</Text>
</View>
</View>
<View>1:00</View>
</View> </View>
</View> </View>
</View>) </View>)

@ -46,9 +46,9 @@ page{
z-index: 99; z-index: 99;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
width: 690rpx; width: 650rpx;
height: 100rpx; height: 100rpx;
padding: 0 30rpx env(safe-area-inset-bottom); padding: 0 50rpx env(safe-area-inset-bottom);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;

@ -1,6 +1,6 @@
import {FC, useCallback, useEffect, useState} from "react"; import {FC, useCallback, useEffect, useState} from "react";
import {Swiper, SwiperItem, Text, Video, View} from "@tarojs/components"; 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 styles from './info.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import LineEllipsis from "@/components/textCollapse/collapse"; import LineEllipsis from "@/components/textCollapse/collapse";
@ -112,7 +112,7 @@ const BrandInfo: FC = () => {
<View className={styles['top']}> <View className={styles['top']}>
<View className='flex justify-between'> <View className='flex justify-between'>
<Text className={`${styles['title']} flex-1`}>{brandInfo?.name}</Text> <Text className={`${styles['title']} flex-1`}>{brandInfo?.name}</Text>
<Collect owner_type={4} owner_id={id} select={brandInfo?.collect}/> <Collect owner_type={4} owner_id={id} select={brandInfo?.collect} styles={{width: 'auto'}}/>
</View> </View>
<LineEllipsis text={brandInfo?.graphic_introduction || '暂无简介'}/> <LineEllipsis text={brandInfo?.graphic_introduction || '暂无简介'}/>
</View> </View>

@ -25,3 +25,27 @@
right: 20rpx; right: 20rpx;
background: transparent !important; 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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Loading…
Cancel
Save