Commit 2c886170 authored by hewenhao's avatar hewenhao

feat: pk引导

parent 544a9de6
...@@ -220,5 +220,17 @@ ...@@ -220,5 +220,17 @@
"w": 28, "w": 28,
"h": 28, "h": 28,
"ossName": "/pk-math/4XkYj9WTFiTnpmcctcdW3eExWJPD/28x28" "ossName": "/pk-math/4XkYj9WTFiTnpmcctcdW3eExWJPD/28x28"
},
"arrow_down.png": {
"u": "https://cdn.jkwljy.com/pk-math/3j2dYWwyY7mbcgzDVT1xhqqC7YuA/128x128",
"w": 128,
"h": 128,
"ossName": "/pk-math/3j2dYWwyY7mbcgzDVT1xhqqC7YuA/128x128"
},
"longpress.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WGCCkeCq5NEozVvFri9NUgrbbJt/170x170",
"w": 170,
"h": 170,
"ossName": "/pk-math/2WGCCkeCq5NEozVvFri9NUgrbbJt/170x170"
} }
} }
...@@ -4,5 +4,11 @@ ...@@ -4,5 +4,11 @@
"w": 420, "w": 420,
"h": 336, "h": 336,
"ossName": "/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336" "ossName": "/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336"
},
"pk-poster.png": {
"u": "https://cdn.jkwljy.com/pk-math/3w3nmexHnq3y6EpmjKHPfiLfHe54/420x336",
"w": 420,
"h": 336,
"ossName": "/pk-math/3w3nmexHnq3y6EpmjKHPfiLfHe54/420x336"
} }
} }
...@@ -54,6 +54,8 @@ export const enum StageLevel { ...@@ -54,6 +54,8 @@ export const enum StageLevel {
export interface Stage { export interface Stage {
isHead?: boolean; isHead?: boolean;
index: number; index: number;
/** 首页用 */
$stageIndex: number;
content: string; content: string;
gear: number; gear: number;
id: number; id: number;
......
...@@ -185,5 +185,15 @@ export default { ...@@ -185,5 +185,15 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/4XkYj9WTFiTnpmcctcdW3eExWJPD/28x28", "u": "https://cdn.jkwljy.com/pk-math/4XkYj9WTFiTnpmcctcdW3eExWJPD/28x28",
"w": 28, "w": 28,
"h": 28 "h": 28
},
"arrow_down.png": {
"u": "https://cdn.jkwljy.com/pk-math/3j2dYWwyY7mbcgzDVT1xhqqC7YuA/128x128",
"w": 128,
"h": 128
},
"longpress.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WGCCkeCq5NEozVvFri9NUgrbbJt/170x170",
"w": 170,
"h": 170
} }
} as const } as const
...@@ -5,5 +5,10 @@ export default { ...@@ -5,5 +5,10 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336", "u": "https://cdn.jkwljy.com/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336",
"w": 420, "w": 420,
"h": 336 "h": 336
},
"pk-poster.png": {
"u": "https://cdn.jkwljy.com/pk-math/3w3nmexHnq3y6EpmjKHPfiLfHe54/420x336",
"w": 420,
"h": 336
} }
} as const } as const
.contentWrap { .contentWrap {
position: absolute; position: absolute;
z-index: 9999998; z-index: 99999996;
opacity: 1; opacity: 1;
box-shadow: rgba(0,0,0, .6) 0px 0px 0px 5000PX; box-shadow: rgba(0,0,0, .6) 0px 0px 0px 5000PX;
animation-name: fadeIn_2; animation-name: fadeIn_2;
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
right: 0; right: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
z-index: 9999997; z-index: 99999995;
animation-name: fadeIn_2; animation-name: fadeIn_2;
animation-duration: .5s; animation-duration: .5s;
animation-timing-function: ease-out; animation-timing-function: ease-out;
......
...@@ -13,14 +13,21 @@ type UserGuideProps<T extends ComponentType<any>> = { ...@@ -13,14 +13,21 @@ type UserGuideProps<T extends ComponentType<any>> = {
component?: T; component?: T;
guideViewId?: string; guideViewId?: string;
onClickConent?: () => void; onClickConent?: () => void;
onContentLongPress?: () => void;
verticalPadding?: number; verticalPadding?: number;
horizonPadding?: number; horizonPadding?: number;
guideContent?: ReactNode; guideContent?: ReactNode;
wrapClass?: string; wrapClass?: string;
placeholderContent?: ReactNode;
} & GetProps<T> } & GetProps<T>
function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserGuideProps<T>) { function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserGuideProps<T>) {
const { isActive, wrapClass, guideViewId, guideContent, verticalPadding = 0, horizonPadding = 0, onFinish, onClickConent, component: Comp = View, ...rest } = props const {
isActive, wrapClass, guideViewId,
guideContent, verticalPadding = 0, horizonPadding = 0, onFinish, onContentLongPress,
placeholderContent,
onClickConent, component: Comp = View, ...rest
} = props
const [rect, setRect] = useState({ width: 80, height: 80, top: 0, left: 0 }) const [rect, setRect] = useState({ width: 80, height: 80, top: 0, left: 0 })
const [_isActive, setIsActive] = useState(false) const [_isActive, setIsActive] = useState(false)
const scrollRef = useRef(0) const scrollRef = useRef(0)
...@@ -64,8 +71,10 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG ...@@ -64,8 +71,10 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
{_isActive && ( {_isActive && (
<RootPortal> <RootPortal>
<View className={classNames(styles.contentWrap, wrapClass)} catchMove style={style}> <View className={classNames(styles.contentWrap, wrapClass)} catchMove style={style}>
<View className={styles.content} onClick={onClickConent} id={guideViewId}> {placeholderContent || (
</View> <View className={styles.content} onLongPress={onContentLongPress} id={guideViewId} onClick={onClickConent}>
</View>
)}
{guideContent} {guideContent}
</View> </View>
<View className={styles.mask} catchMove></View> <View className={styles.mask} catchMove></View>
......
...@@ -5,6 +5,7 @@ import { preCreateShareSeeds, saveShare } from '@/api' ...@@ -5,6 +5,7 @@ import { preCreateShareSeeds, saveShare } from '@/api'
import { getCurrentShareId, qs, getSharePath } from '@/utils/share' import { getCurrentShareId, qs, getSharePath } from '@/utils/share'
import { getStorage, StorageKeys } from '@/utils/storage' import { getStorage, StorageKeys } from '@/utils/storage'
import { omit } from '@/utils' import { omit } from '@/utils'
import { useStoreState } from '@/store/hooks'
type UseShareParams<T extends object = {}> = (arg: ShareAppMessageObject, id: number) => ({ type UseShareParams<T extends object = {}> = (arg: ShareAppMessageObject, id: number) => ({
pageParams?: T; pageParams?: T;
...@@ -19,13 +20,13 @@ const defaultParamsFn = <T extends object = {}>() => ({ ...@@ -19,13 +20,13 @@ const defaultParamsFn = <T extends object = {}>() => ({
const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextIdIfShare?: boolean) => { const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextIdIfShare?: boolean) => {
const [shareIds, setShareIds] = useState<number[]>([]) const [shareIds, setShareIds] = useState<number[]>([])
const router = useRouter<{ scene?: string; shareId?: string }>() const router = useRouter<{ scene?: string; shareId?: string }>()
const userInfo = useStoreState(state => state.userModel.userInfo)
/** /**
* 获取分享种子 * 获取分享种子
*/ */
const getSeeds = useCallback(() => { const getSeeds = useCallback(() => {
const currentUser = getStorage(StorageKeys.userInfo) if (!userInfo.userId) return
if (!currentUser) return
preCreateShareSeeds(1) preCreateShareSeeds(1)
.then(({ data }) => { .then(({ data }) => {
setShareIds(Array.isArray(data) ? data : []) setShareIds(Array.isArray(data) ? data : [])
...@@ -33,7 +34,7 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId ...@@ -33,7 +34,7 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId
.catch((error) => { .catch((error) => {
console.log('get share seed occur error', error) console.log('get share seed occur error', error)
}) })
}, []) }, [userInfo.userId])
useEffect(() => { useEffect(() => {
getSeeds() getSeeds()
...@@ -46,19 +47,19 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId ...@@ -46,19 +47,19 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId
let sharePath = result.path ?? router.path let sharePath = result.path ?? router.path
// 如果shareId已经生成,则生成url; // 如果shareId已经生成,则生成url;
const userInfo = getStorage(StorageKeys.userInfo) const _userInfo = getStorage(StorageKeys.userInfo)
if (userInfo && userInfo.userId && defaultShareId > 0) { if (_userInfo && _userInfo.userId && defaultShareId > 0) {
const parentId = getCurrentShareId() const parentId = getCurrentShareId()
const safeParams = omit({ ...router.params, ...pageParams }, ['scene', 'shareId']) const safeParams = omit({ ...router.params, ...pageParams }, ['scene', 'shareId'])
// 调用记录接口 // 调用记录接口
saveShare({ saveShare({
id: defaultShareId, id: defaultShareId,
parentId, parentId,
sharerId: userInfo.userId, sharerId: _userInfo.userId,
sharerType: 'INLET_USER', sharerType: 'INLET_USER',
shareType: 'URL', shareType: 'URL',
sharePath, sharePath,
operatorId: userInfo.userId, operatorId: _userInfo.userId,
shareParams: JSON.stringify(safeParams), shareParams: JSON.stringify(safeParams),
}).catch((error) => { }).catch((error) => {
console.log('save share occur error', error) console.log('save share occur error', error)
...@@ -71,7 +72,7 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId ...@@ -71,7 +72,7 @@ const useShare = <T extends object = {}>(paramsFn?: UseShareParams<T>, getNextId
const queryString = qs(safeParams) const queryString = qs(safeParams)
sharePath = `${sharePath}?scene=${encodeURIComponent(`shareId=${defaultShareId}`)}${queryString ? `&${queryString}` : ''}` sharePath = `${sharePath}?scene=${encodeURIComponent(`shareId=${defaultShareId}`)}${queryString ? `&${queryString}` : ''}`
} else { } else {
sharePath = getSharePath(sharePath, router.params) sharePath = getSharePath(sharePath, pageParams)
} }
console.log('generated share path:', sharePath) console.log('generated share path:', sharePath)
return { return {
......
...@@ -23,6 +23,7 @@ type LazyImageProps = { ...@@ -23,6 +23,7 @@ type LazyImageProps = {
lazyLoad?: boolean | undefined; lazyLoad?: boolean | undefined;
paddingHorizontal?: number; paddingHorizontal?: number;
contentClass?: string; contentClass?: string;
wrapClass?: string;
source: { source: {
w: number; w: number;
h: number; h: number;
...@@ -31,7 +32,7 @@ type LazyImageProps = { ...@@ -31,7 +32,7 @@ type LazyImageProps = {
} }
const LazeImage = (props: PropsWithChildren<LazyImageProps>) => { const LazeImage = (props: PropsWithChildren<LazyImageProps>) => {
const { source, lazyLoad = false, paddingHorizontal = 0 } = props const { source, lazyLoad = false, paddingHorizontal = 0, wrapClass } = props
const [isRender, setIsRender] = useState(!lazyLoad) const [isRender, setIsRender] = useState(!lazyLoad)
const observerRef = useRef<IntersectionObserver | null>(null) const observerRef = useRef<IntersectionObserver | null>(null)
...@@ -76,7 +77,7 @@ const LazeImage = (props: PropsWithChildren<LazyImageProps>) => { ...@@ -76,7 +77,7 @@ const LazeImage = (props: PropsWithChildren<LazyImageProps>) => {
} }
return ( return (
<View className={styles.wrap}> <View className={classNames(styles.wrap, wrapClass)}>
{renderContent()} {renderContent()}
<View className={classNames(styles.content, props.contentClass)}> <View className={classNames(styles.content, props.contentClass)}>
{props.children} {props.children}
......
...@@ -8,6 +8,7 @@ import ModalArea from './modal-area' ...@@ -8,6 +8,7 @@ import ModalArea from './modal-area'
import ModalGrade from './modal-grade' import ModalGrade from './modal-grade'
import ModalResult from './modal-result' import ModalResult from './modal-result'
import ModalGroupGuide from './modal-group-guide' import ModalGroupGuide from './modal-group-guide'
import ModalPk from './pk'
let isLoad = false let isLoad = false
const preloadGuideImages = () => { const preloadGuideImages = () => {
...@@ -132,6 +133,7 @@ const Tutorial = () => { ...@@ -132,6 +133,7 @@ const Tutorial = () => {
return ( return (
<> <>
<ModalPk />
{step === 1 && <ModalArea options={data.areas} onConfirm={handleConfirmArea} loading={updating} />} {step === 1 && <ModalArea options={data.areas} onConfirm={handleConfirmArea} loading={updating} />}
{step === 2 && !userInfo.grade && <ModalGrade options={data.grades} onConfirm={handleConfirmGrade} loading={updating} />} {step === 2 && !userInfo.grade && <ModalGrade options={data.grades} onConfirm={handleConfirmGrade} loading={updating} />}
{step === 3 && <ModalResult grade={selected.grade} onConfirm={handleConfirm} />} {step === 3 && <ModalResult grade={selected.grade} onConfirm={handleConfirm} />}
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
.continue { .continue {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
padding-top: 56px;
} }
.continue_btn { .continue_btn {
......
import { View, Image, Text } from '@tarojs/components' import { View, Image } from '@tarojs/components'
import assetsGuide from '@/assets/oss/assets-guide' import assetsGuide from '@/assets/oss/assets-guide'
import { useMemo, useEffect } from 'react'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useRouter, navigateBack } from '@tarojs/taro'
import styles from './scene.module.scss' import styles from './pk.module.scss'
const Scene = () => { const Scene = () => {
const stageList = useStoreState(state => state.mainModel.stageList)
const router = useRouter<{ id: string }>()
/** 第二关 */
const isSecondStage = useMemo(() => stageList.findIndex(stage => stage.id === +router.params.id) === 1, [stageList, router])
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const stageDetailPre = useStoreState(state => state.gameModel.stageDetailPre)
const updatePkGuideActive = useStoreActions(actions => actions.guideModel.updatePkGuideActive)
const nextPkGuide = useStoreActions(actions => actions.guideModel.nextPkGuide) const nextPkGuide = useStoreActions(actions => actions.guideModel.nextPkGuide)
const pkGuideActive = useStoreState(state => state.guideModel.pkGuideActive) const pkGuideActive = useStoreState(state => state.guideModel.pkGuideActive)
const pkGuideStep = useStoreState(state => state.guideModel.pkGuideStep) const pkGuideStep = useStoreState(state => state.guideModel.pkGuideStep)
useEffect(() => {
/** 第二关过关了显示 */
if (isSecondStage && !!stageDetail?.level && !stageDetailPre?.level) {
updatePkGuideActive(true)
}
}, [isSecondStage, stageDetail, stageDetailPre, updatePkGuideActive])
const handleClick = () => { const handleClick = () => {
nextPkGuide() nextPkGuide()
navigateBack()
} }
if (!pkGuideActive || pkGuideStep !== 0) { if (!pkGuideActive || pkGuideStep !== 1) {
return null return null
} }
return ( return (
<View className={styles.wrap}> <View className={styles.wrap}>
<Image src={assetsGuide['cat-4.png'].u} className={styles.cat}> </Image> <Image src={assetsGuide['cat-2.png'].u} className={styles.cat} />
<View className={styles.dialog}> <View className={styles.dialog}>
<View> <View>
你的表现不错哦,看来已经可以进入<Text className={styles.em}>竞技场</Text>了! PK是展示我们实力,和好友一起成长的好机会。
什么是竞技场?来给我一起去看看~
</View> </View>
<View className={styles.continue}> <View className={styles.continue}>
<View className={styles.continue_btn} onClick={handleClick}> <View className={styles.continue_btn} onTouchStart={handleClick}>
继续<Image src={assetsGuide['continue-purple.png'].u} className={styles.continue_icon} /> 继续<Image src={assetsGuide['continue-purple.png'].u} className={styles.continue_icon} />
</View> </View>
</View> </View>
......
...@@ -224,6 +224,63 @@ ...@@ -224,6 +224,63 @@
flex-shrink: 0; flex-shrink: 0;
} }
.guide_wrap {
border-radius: 50px;
}
.guide_placeholder {
width: 100%;
height: 100%;
background-color: transparent;
border: none;
&::after {
display: none;
}
}
.tutorial {
position: absolute;
top: 0;
left: -90px;
right: -90px;
transform: translateY(-100%);
display: flex;
flex-direction: column;
align-items: center;
.tutorial_arrow {
width: 128px;
height: 128px;
margin-bottom: -26px;
animation-name: bounce;
animation-duration: 1s;
animation-timing-function: ease-in;
animation-iteration-count: infinite;
}
.tutorial_text {
font-size: 36px;
font-weight: 600;
color: #FFFFFF;
line-height: 50px;
margin-bottom: 24px;
}
}
@keyframes bounce {
0% {
transform: translate3d(-20px, 20px, 0);
}
50% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-20px, 20px, 0);
}
}
.wechat_logo { .wechat_logo {
width: 80px; width: 80px;
height: 80px; height: 80px;
......
import { View, Image, Button } from '@tarojs/components' import { View, Image, Button } from '@tarojs/components'
import { useMemo, useCallback, useEffect } from 'react' import { useMemo, useCallback, useEffect, useState } from 'react'
import { getMenuButtonBoundingClientRect, navigateTo } from '@tarojs/taro' import { getMenuButtonBoundingClientRect, navigateTo } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import assetsMainNext from '@/assets/oss/assets-main-next' import assetsMainNext from '@/assets/oss/assets-main-next'
...@@ -8,7 +8,10 @@ import { useStoreActions, useStoreState } from '@/store/hooks' ...@@ -8,7 +8,10 @@ import { useStoreActions, useStoreState } from '@/store/hooks'
import { useFetch } from '@/hooks' import { useFetch } from '@/hooks'
import { fetchUserDetails } from '@/api' import { fetchUserDetails } from '@/api'
import { getUserRank } from '@/utils' import { getUserRank } from '@/utils'
import { UserGuideView } from '@/components'
import { getUserLevelIcon, getUserLevelName, getUserLevelSubName } from '@/constants' import { getUserLevelIcon, getUserLevelName, getUserLevelSubName } from '@/constants'
import assetsGuide from '@/assets/oss/assets-guide'
import PkGuide from './pk-guide/pk'
import styles from './create-pk.module.scss' import styles from './create-pk.module.scss'
type CreatePkProps = { type CreatePkProps = {
...@@ -21,11 +24,21 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -21,11 +24,21 @@ const CreatePk = (props: CreatePkProps) => {
const currentPkStage = useStoreState(states => states.mainModel.currentPkStage) const currentPkStage = useStoreState(states => states.mainModel.currentPkStage)
const nav = useMemo(getMenuButtonBoundingClientRect, []) const nav = useMemo(getMenuButtonBoundingClientRect, [])
const updateState = useStoreActions(actions => actions.mainModel.updateState) const updateState = useStoreActions(actions => actions.mainModel.updateState)
const completePkGuide = useStoreActions(actions => actions.guideModel.completePkGuide)
const pkGuideActive = useStoreState(state => state.guideModel.pkGuideActive)
const pkGuideStep = useStoreState(state => state.guideModel.pkGuideStep)
const [isActive, setIsActive] = useState(false)
const isGuideActive = useMemo(() => pkGuideActive && pkGuideStep === 4 && isActive, [pkGuideActive, pkGuideStep, isActive])
const closeModal = () => { const closeModal = () => {
updateState({ isCreatePkShow: false, currentPkStage: null }) updateState({ isCreatePkShow: false, currentPkStage: null })
} }
const handleTouch = () => {
completePkGuide()
}
const [dataSource, loadData] = useFetch(fetchUserDetails, useCallback(() => { const [dataSource, loadData] = useFetch(fetchUserDetails, useCallback(() => {
if (!currentPkStage) return null if (!currentPkStage) return null
return { return {
...@@ -34,6 +47,23 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -34,6 +47,23 @@ const CreatePk = (props: CreatePkProps) => {
} }
}, [currentPkStage, userInfo])) }, [currentPkStage, userInfo]))
useEffect(() => {
let timer
if (visible) {
timer = setTimeout(() => {
setIsActive(true)
}, 800)
} else {
setIsActive(false)
}
return () => {
if (timer) {
clearTimeout(timer)
}
}
}, [visible])
useEffect(() => { useEffect(() => {
if (currentPkStage && userInfo?.userId) { if (currentPkStage && userInfo?.userId) {
loadData() loadData()
...@@ -60,6 +90,7 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -60,6 +90,7 @@ const CreatePk = (props: CreatePkProps) => {
return ( return (
<> <>
{visible && (<PkGuide />)}
<View className={classNames(styles.close_wrap, visible && styles.is_show)} style={closeStyle}> <View className={classNames(styles.close_wrap, visible && styles.is_show)} style={closeStyle}>
<View className={styles.close} onClick={closeModal} data-name="关闭发起PK"> <View className={styles.close} onClick={closeModal} data-name="关闭发起PK">
<Image src={assetsMainNext['pk-close.png'].u} className={styles.close_icon}></Image> <Image src={assetsMainNext['pk-close.png'].u} className={styles.close_icon}></Image>
...@@ -91,10 +122,32 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -91,10 +122,32 @@ const CreatePk = (props: CreatePkProps) => {
<View className={cs.flex__item}></View> <View className={cs.flex__item}></View>
<Image src={assetsMainNext['challenge-2.png'].u} className={styles.challenge_2} mode="heightFix"></Image> <Image src={assetsMainNext['challenge-2.png'].u} className={styles.challenge_2} mode="heightFix"></Image>
<View className={cs.flex__item}></View> <View className={cs.flex__item}></View>
<Button openType="share" className={styles.share_btn}>
<UserGuideView
component={Button}
openType="share"
className={styles.share_btn}
isActive={isGuideActive}
wrapClass={styles.guide_wrap}
placeholderContent={(
<Button
openType="share"
className={styles.guide_placeholder}
onClick={handleTouch}
>
</Button>
)}
guideContent={(
<View className={styles.tutorial}>
<View className={styles.tutorial_text}>点击按钮,开始你的竞技之旅吧~</View>
<Image src={assetsGuide['arrow_down.png'].u} className={styles.tutorial_arrow}></Image>
</View>
)}
>
<Image src={assetsMainNext['pk-wechat-logo.png'].u} className={styles.wechat_logo}></Image> <Image src={assetsMainNext['pk-wechat-logo.png'].u} className={styles.wechat_logo}></Image>
<View>发给同学好友进行Pk</View> <View>发给同学好友进行Pk</View>
</Button> </UserGuideView>
<View className={styles.tips}>会以你的最佳表现与对方答题数据进行PK</View> <View className={styles.tips}>会以你的最佳表现与对方答题数据进行PK</View>
</View> </View>
</View> </View>
......
.wrap {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 3200000;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
background: rgba(0,0,0,0.7);
}
.dialog {
width: 690px;
height: 260px;
margin-bottom: 260px;
background-image: url(https://cdn.jkwljy.com/pk-math/q4n5KnANG9viqaH81CXFTnTP9A7/690x260);
background-size: 100% 100%;
padding: 44px 48px 0 48px;
box-sizing: border-box;
font-weight: 500;
color: #465164;
line-height: 44px;
font-size: 28px;
.em {
color: #FF8137;
}
}
.cat {
width: 300px;
height: 300px;
align-self: flex-start;
margin-bottom: -100px;
}
.continue {
display: flex;
justify-content: flex-end;
}
.continue_btn {
display: flex;
justify-content: flex-end;
align-items: center;
font-size: 28px;
font-weight: 500;
color: #6B54BE;
padding: 2px 8px 2px 20px;
margin-right: -8px;
line-height: 40px;
}
.continue_icon {
width: 28px;
height: 28px;
display: block;
margin-left: 4px;
}
import { View, Image, Text } from '@tarojs/components'
import assetsGuide from '@/assets/oss/assets-guide'
import { useStoreState, useStoreActions } from '@/store/hooks'
import styles from './pk.module.scss'
const Scene = () => {
const nextPkGuide = useStoreActions(actions => actions.guideModel.nextPkGuide)
const pkGuideActive = useStoreState(state => state.guideModel.pkGuideActive)
const pkGuideStep = useStoreState(state => state.guideModel.pkGuideStep)
const handleClick = () => {
nextPkGuide()
}
console.log(pkGuideStep, 11111111)
if (!pkGuideActive || pkGuideStep !== 3) {
return null
}
return (
<View className={styles.wrap}>
<Image src={assetsGuide['cat-2.png'].u} className={styles.cat} />
<View className={styles.dialog}>
<View>
分享给你的同学和好友。对方完成后,就会和你的本关最佳表现进行PK,<Text className={styles.em}>获胜后将获得段位提升与水晶奖励</Text>哦。
</View>
<View className={styles.continue}>
<View className={styles.continue_btn} onTouchStart={handleClick}>
继续<Image src={assetsGuide['continue-purple.png'].u} className={styles.continue_icon} />
</View>
</View>
</View>
</View>
)
}
export default Scene
...@@ -41,7 +41,11 @@ export type StagePartNext = { ...@@ -41,7 +41,11 @@ export type StagePartNext = {
} }
function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList: Stage[]} { function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList: Stage[]} {
const newList = stageList.slice().sort((a, b) => (a.part ?? 0) - (b.part ?? 0)) const newList = stageList
.slice()
.sort((a, b) => (a.part ?? 0) - (b.part ?? 0))
.map((c, index) => ({ ...c, $stageIndex: index }))
const ret: StageNext[] = [] const ret: StageNext[] = []
const currentIndex = newList.findIndex(c => c.status === StageStatus.CURRENT) const currentIndex = newList.findIndex(c => c.status === StageStatus.CURRENT)
......
...@@ -2,6 +2,7 @@ import { View, Image } from '@tarojs/components' ...@@ -2,6 +2,7 @@ import { View, Image } from '@tarojs/components'
import { nextTick, createSelectorQuery } from '@tarojs/taro' import { nextTick, createSelectorQuery } from '@tarojs/taro'
import { useEffect, useMemo, useRef, useState } from 'react' import { useEffect, useMemo, useRef, useState } from 'react'
import assetsMainNext from '@/assets/oss/assets-main-next' import assetsMainNext from '@/assets/oss/assets-main-next'
import { useStoreState } from '@/store/hooks'
import classNames from 'classnames' import classNames from 'classnames'
import { stageToStagePartNext, type Stage, isPartHead, StageStatus } from './constants' import { stageToStagePartNext, type Stage, isPartHead, StageStatus } from './constants'
import ScenePart from './part' import ScenePart from './part'
......
...@@ -21,7 +21,7 @@ const getClassName = (index) => { ...@@ -21,7 +21,7 @@ const getClassName = (index) => {
} }
type ScenePartProps = { type ScenePartProps = {
part: StagePartNext part: StagePartNext;
} }
const ScenePart = (props: ScenePartProps) => { const ScenePart = (props: ScenePartProps) => {
......
...@@ -22,6 +22,49 @@ ...@@ -22,6 +22,49 @@
border-radius: 50%; border-radius: 50%;
} }
} }
.pk_guide_wrap {
border-radius: 50%;
&::after {
content: " ";
position: absolute;
left: -16px;
right: -16px;
top: -16px;
bottom: -16px;
pointer-events: none;
border: 8px dashed #fff;
border-radius: 50%;
}
}
.pk_guide {
position: absolute;
left: 20px;
top: 102px;
pointer-events: none;
}
.pk_guide_finger {
width: 170px;
height: 170px;
margin-left: 60px;
}
.pk_guide_text {
font-size: 36px;
font-weight: 600;
color: #FFFFFF;
line-height: 50px;
white-space: nowrap;
.em {
font-size: 48px;
font-weight: 600;
color: #FFFFFF;
line-height: 66px;
margin-right: 8px;
}
}
.tutorial { .tutorial {
position: absolute; position: absolute;
......
import { View, Image } from '@tarojs/components' import { View, Image, Text } from '@tarojs/components'
import assets from '@/assets/oss/assets-round' import assets from '@/assets/oss/assets-round'
import assetsRoundNext from '@/assets/oss/assets-round-next' import assetsRoundNext from '@/assets/oss/assets-round-next'
import { useMemo } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import { cs } from '@/styles' import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro' import { navigateTo } from '@tarojs/taro'
...@@ -8,6 +9,7 @@ import type { ImageSource } from '@/types' ...@@ -8,6 +9,7 @@ import type { ImageSource } from '@/types'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import { UserGuideView } from '@/components' import { UserGuideView } from '@/components'
import tutorial from '@/assets/oss/assets-tutorial' import tutorial from '@/assets/oss/assets-tutorial'
import assetsGuide from '@/assets/oss/assets-guide'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId } from './constants' import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId } from './constants'
import StageTag from './stage-tag' import StageTag from './stage-tag'
...@@ -145,6 +147,13 @@ const StageComp = (props: StageProps) => { ...@@ -145,6 +147,13 @@ const StageComp = (props: StageProps) => {
const player = useStoreState(state => state.mainModel.player) const player = useStoreState(state => state.mainModel.player)
const updateMainModelState = useStoreActions(state => state.mainModel.updateState) const updateMainModelState = useStoreActions(state => state.mainModel.updateState)
const mainGuideActive = useStoreState(state => state.guideModel.mainGuideActive) const mainGuideActive = useStoreState(state => state.guideModel.mainGuideActive)
const pkGuideActive = useStoreState(state => state.guideModel.pkGuideActive)
const pkGuideStep = useStoreState(state => state.guideModel.pkGuideStep)
const nextPkGuide = useStoreActions(state => state.guideModel.nextPkGuide)
const isPkGuideShow = useMemo(() => {
return pkGuideStep === 2 && pkGuideActive && stage.$stageIndex === 1
}, [pkGuideActive, pkGuideStep, stage])
const handleClick = () => { const handleClick = () => {
if (stage.status !== StageStatus.DISABLED || !isProduction) { if (stage.status !== StageStatus.DISABLED || !isProduction) {
...@@ -161,6 +170,11 @@ const StageComp = (props: StageProps) => { ...@@ -161,6 +170,11 @@ const StageComp = (props: StageProps) => {
} }
} }
const handlePk = () => {
nextPkGuide()
handleLongPress()
}
const handleCompleteGuide = () => { const handleCompleteGuide = () => {
handleClick() handleClick()
completeMainGuide() completeMainGuide()
...@@ -200,7 +214,21 @@ const StageComp = (props: StageProps) => { ...@@ -200,7 +214,21 @@ const StageComp = (props: StageProps) => {
const tag = getTagIcon(stage.gear) const tag = getTagIcon(stage.gear)
const starNum = getStarNum(stage.level) const starNum = getStarNum(stage.level)
return ( return (
<View className={styles.clear}> <UserGuideView
className={styles.clear}
onContentLongPress={handlePk}
isActive={isPkGuideShow}
wrapClass={styles.pk_guide_wrap}
verticalPadding={0}
horizonPadding={0}
guideViewId="first_pk_guide"
guideContent={(
<View className={styles.pk_guide}>
<Image src={assetsGuide['longpress.png'].u} className={styles.pk_guide_finger}></Image>
<View className={styles.pk_guide_text}><Text className={styles.em}>长按</Text>已通关的关卡,启动PK模式~</View>
</View>
)}
>
<StageTag url={tag?.u} className={styles.tag} id={stage.id} ready={ready} /> <StageTag url={tag?.u} className={styles.tag} id={stage.id} ready={ready} />
<Image src={getScoreIcon(stage.level).u} className={styles.score} /> <Image src={getScoreIcon(stage.level).u} className={styles.score} />
<Image src={getClearIcon(stage.type).u} className={getIconClassNames(stage.type, [styles.clearIcon])} /> <Image src={getClearIcon(stage.type).u} className={getIconClassNames(stage.type, [styles.clearIcon])} />
...@@ -211,7 +239,7 @@ const StageComp = (props: StageProps) => { ...@@ -211,7 +239,7 @@ const StageComp = (props: StageProps) => {
<View className={styles.pk_item}>{stage.pkWinNum ?? 0}</View> <View className={styles.pk_item}>{stage.pkWinNum ?? 0}</View>
<View className={classNames(styles.pk_item, styles.is_right)}>{stage.pkLoseNum ?? 0}</View> <View className={classNames(styles.pk_item, styles.is_right)}>{stage.pkLoseNum ?? 0}</View>
</View> </View>
</View> </UserGuideView>
) )
} }
} }
...@@ -228,7 +256,7 @@ const StageComp = (props: StageProps) => { ...@@ -228,7 +256,7 @@ const StageComp = (props: StageProps) => {
id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined} id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined}
onClick={handleClick} onClick={handleClick}
data-name={`关卡-${stage.id}`} data-name={`关卡-${stage.id}`}
onLongPress={handleLongPress} onLongPress={!isPkGuideShow ? handleLongPress : undefined}
> >
{renderRound(isReady)} {renderRound(isReady)}
<View className={styles.roundName}> <View className={styles.roundName}>
......
...@@ -28,7 +28,7 @@ const MainPage = () => { ...@@ -28,7 +28,7 @@ const MainPage = () => {
return { return {
title: '听说你的能力不错,我们battle一下', title: '听说你的能力不错,我们battle一下',
path: 'pages/accept-pk/index', path: 'pages/accept-pk/index',
imageUrl: 'https://cdn.jkwljy.com/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336', imageUrl: 'https://cdn.jkwljy.com/pk-math/3w3nmexHnq3y6EpmjKHPfiLfHe54/420x336',
pageParams: { pageParams: {
initiator: userInfo.userId, initiator: userInfo.userId,
stageId: currentPkStage.id stageId: currentPkStage.id
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
.continue { .continue {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
padding-top: 56px;
} }
.continue_btn { .continue_btn {
......
...@@ -43,7 +43,7 @@ const Scene = () => { ...@@ -43,7 +43,7 @@ const Scene = () => {
什么是竞技场?来给我一起去看看~ 什么是竞技场?来给我一起去看看~
</View> </View>
<View className={styles.continue}> <View className={styles.continue}>
<View className={styles.continue_btn} onClick={handleClick}> <View className={styles.continue_btn} onTouchStart={handleClick}>
继续<Image src={assetsGuide['continue-purple.png'].u} className={styles.continue_icon} /> 继续<Image src={assetsGuide['continue-purple.png'].u} className={styles.continue_icon} />
</View> </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