Commit e1145a9c authored by hewenhao's avatar hewenhao

feat: 发起pk

parent 0daa1323
.wrap { .close_wrap {
position: fixed; position: fixed;
z-index: 2199999;
left: 0; left: 0;
top: 0; top: 0;
bottom: 0; z-index: 2200000;
right: 0; display: none;
background-color: rgba(0, 0, 0, .5);
&.is_show {
display: block;
}
}
.pk_history {
position: absolute;
top: 20px;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; right: 32px;
font-size: 28px;
font-weight: 500;
color: #FFFFFF;
padding: 10px 24px;
margin-right: -24px;
.pk_history_arrow {
width: 20px;
height: 20px;
display: block;
}
}
.close {
margin-top: -20px;
padding: 20px;
}
.close_icon {
width: 60px;
height: 60px;
} }
.top, .bottom { .top, .bottom {
flex: 1; flex: 1;
position: relative; position: relative;
width: 100%; width: 100%;
animation-timing-function: ease-out; transition: transform .5s ease-out;
animation-duration: .5s;
animation-fill-mode: backwards;
} }
.top { .top {
position: fixed;
z-index: 2199999;
left: 0;
right: 0;
top: 0;
bottom: 50%;
margin-bottom: -62px; margin-bottom: -62px;
animation-name: stepDown;
}
.bottom {
margin-top: -62px;
animation-name: stepUp;
}
@keyframes stepDown {
0% {
transform: translate3d(0, -100%, 0); transform: translate3d(0, -100%, 0);
}
100% { &.is_show {
transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
} }
} }
@keyframes stepUp { .bottom {
0% { position: fixed;
margin-top: -62px;
z-index: 2199999;
left: 0;
right: 0;
top: 50%;
bottom: 0;
transform: translate3d(0, 100%, 0); transform: translate3d(0, 100%, 0);
} &.is_show {
100% {
transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
} }
} }
...@@ -92,10 +116,11 @@ ...@@ -92,10 +116,11 @@
} }
.center { .center {
position: absolute; position: fixed;
left: 0; left: 0;
right: 0; right: 0;
top: 50%; top: 50%;
z-index: 2200000;
} }
.pk_flash_left, .pk_flash_right { .pk_flash_left, .pk_flash_right {
...@@ -142,7 +167,6 @@ ...@@ -142,7 +167,6 @@
.challenge_2 { .challenge_2 {
width: 248px; width: 248px;
height: 248px; height: 248px;
flex-shrink: 0;
} }
.share_btn { .share_btn {
......
import { View, Image, Button } from '@tarojs/components' import { View, Image, Button } from '@tarojs/components'
import assetsPk from '@/assets/oss/assets-pk' import assetsPk from '@/assets/oss/assets-pk'
import { useMemo } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import classNames from 'classnames'
import assetsMainNext from '@/assets/oss/assets-main-next' import assetsMainNext from '@/assets/oss/assets-main-next'
import { cs } from '@/styles' import { cs } from '@/styles'
import { useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import styles from './create-pk.module.scss' import styles from './create-pk.module.scss'
type CreatePkProps = { type CreatePkProps = {
...@@ -10,16 +13,41 @@ type CreatePkProps = { ...@@ -10,16 +13,41 @@ type CreatePkProps = {
} }
const CreatePk = (props: CreatePkProps) => { const CreatePk = (props: CreatePkProps) => {
const { visible } = props
const userInfo = useStoreState(states => states.userModel.userInfo) const userInfo = useStoreState(states => states.userModel.userInfo)
if (props.visible) { const nav = useMemo(getMenuButtonBoundingClientRect, [])
return null const updateState = useStoreActions(actions => actions.mainModel.updateState)
const closeModal = () => {
updateState({ isCreatePkShow: false })
}
const closeStyle = useMemo(() => {
return {
paddingTop: `${nav.top + 5}px`
}
}, [nav])
const historyStyle = useMemo(() => {
return {
marginTop: `${nav.height + nav.top + 5}px`
} }
}, [nav])
return ( return (
<View className={styles.wrap}> <>
<View className={styles.top}> <View className={classNames(styles.close_wrap, visible && styles.is_show)} style={closeStyle}>
<View className={styles.close} onClick={closeModal} data-name="关闭发起PK">
<Image src={assetsMainNext['pk-close.png'].u} className={styles.close_icon}></Image>
</View>
</View>
<View className={classNames(styles.top, visible && styles.is_show)}>
<Image src={assetsMainNext['pk-top.png'].u} className={styles.bg_top} mode="widthFix"></Image> <Image src={assetsMainNext['pk-top.png'].u} className={styles.bg_top} mode="widthFix"></Image>
<View className={styles.top_content}> <View className={styles.top_content}>
<Image src={assetsMainNext['challenge-avatar.png'].u} className={styles.challenge_2} /> <View className={styles.pk_history} style={historyStyle}>
PK记录 <Image src={assetsMainNext['pk-history-arrow.png'].u} className={styles.pk_history_arrow} />
</View>
<Image src={assetsMainNext['challenge-avatar.png'].u} className={styles.challenge_2} mode="heightFix" />
<View className={styles.me_info}> <View className={styles.me_info}>
<View>{userInfo.nickName}</View> <View>{userInfo.nickName}</View>
<View className={styles.info_detail}><Image src={assetsPk['bronze-small.png'].u} className={styles.pk_level} />青铜Ⅰ</View> <View className={styles.info_detail}><Image src={assetsPk['bronze-small.png'].u} className={styles.pk_level} />青铜Ⅰ</View>
...@@ -28,7 +56,7 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -28,7 +56,7 @@ const CreatePk = (props: CreatePkProps) => {
</View> </View>
</View> </View>
</View> </View>
<View className={styles.bottom}> <View className={classNames(styles.bottom, visible && styles.is_show)}>
<Image src={assetsMainNext['pk-slogen.png'].u} className={styles.pk_slogan}></Image> <Image src={assetsMainNext['pk-slogen.png'].u} className={styles.pk_slogan}></Image>
<Image src={assetsMainNext['pk-bottom.png'].u} className={styles.bg_bottom} mode="widthFix"></Image> <Image src={assetsMainNext['pk-bottom.png'].u} className={styles.bg_bottom} mode="widthFix"></Image>
<View className={styles.bottom_content}> <View className={styles.bottom_content}>
...@@ -42,6 +70,7 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -42,6 +70,7 @@ const CreatePk = (props: CreatePkProps) => {
<View className={styles.tips}>会以你的最佳表现与对方答题数据进行PK</View> <View className={styles.tips}>会以你的最佳表现与对方答题数据进行PK</View>
</View> </View>
</View> </View>
{visible && (
<View className={styles.center}> <View className={styles.center}>
<View className={styles.pk_flash}> <View className={styles.pk_flash}>
<Image src={assetsMainNext['pk-flash.png'].u} className={styles.pk_flash_left}></Image> <Image src={assetsMainNext['pk-flash.png'].u} className={styles.pk_flash_left}></Image>
...@@ -49,7 +78,8 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -49,7 +78,8 @@ const CreatePk = (props: CreatePkProps) => {
</View> </View>
<Image src={assetsMainNext['pk-logo.png'].u} className={styles.pk_logo} /> <Image src={assetsMainNext['pk-logo.png'].u} className={styles.pk_logo} />
</View> </View>
</View> )}
</>
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment