Commit 862945e3 authored by hewenhao's avatar hewenhao

feat: pk math

parent c6b40ab0
...@@ -21,13 +21,14 @@ export type PkDetails = { ...@@ -21,13 +21,14 @@ export type PkDetails = {
winPkNum: number winPkNum: number
} }
export function fetchUserDetails (data: PkParams) { export async function fetchUserDetails (data: { initiator?: string; stageId?: string }) {
const pp = await handleShare(data)
return requestAfterSilentLogin<PkDetails, PkParams>((userInfo) => ({ return requestAfterSilentLogin<PkDetails, PkParams>((userInfo) => ({
method: 'GET', method: 'GET',
url: '/service-idea/pk/personal/stage/detail', url: '/service-idea/pk/personal/stage/detail',
data: { data: {
stageId: data.stageId, stageId: +(pp.stageId ?? '-1'),
userId: data.userId || userInfo?.userId, userId: +(pp.initiator ?? userInfo?.userId ?? -1),
} }
})) }))
} }
......
...@@ -146,6 +146,18 @@ ...@@ -146,6 +146,18 @@
width: 532px; width: 532px;
height: 112px; height: 112px;
margin-bottom: 50px; margin-bottom: 50px;
&.disabled {
background: #E2E6ED;
border-radius: 56px;
font-size: 40px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
color: #C2C8D1;
line-height: 56px;
}
} }
} }
} }
......
...@@ -4,7 +4,8 @@ import { useBoolean } from '@/hooks' ...@@ -4,7 +4,8 @@ import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import assetsPk from '@/assets/oss/assets-pk' import assetsPk from '@/assets/oss/assets-pk'
import assetsMainNext from '@/assets/oss/assets-main-next' import assetsMainNext from '@/assets/oss/assets-main-next'
import { useRef } from 'react' import classNames from 'classnames'
import { useRef, useMemo } from 'react'
import { badgeImages } from '../battles/const' import { badgeImages } from '../battles/const'
import styles from './index.module.scss' import styles from './index.module.scss'
import TopHeader from './components/top-header' import TopHeader from './components/top-header'
...@@ -26,10 +27,7 @@ const AcceptPk = () => { ...@@ -26,10 +27,7 @@ const AcceptPk = () => {
useDidShow(async () => { useDidShow(async () => {
if (router.params.initiator && router.params.stageId) { if (router.params.initiator && router.params.stageId) {
await fetchUserDetails({ await fetchUserDetails(router.params)
userId: +router.params.initiator,
stageId: +router.params.stageId,
})
} }
}) })
...@@ -59,6 +57,10 @@ const AcceptPk = () => { ...@@ -59,6 +57,10 @@ const AcceptPk = () => {
} }
} }
const canGoNext = useMemo(() => {
return userInfo.userId !== details?.userId
}, [userInfo, details])
return ( return (
<View className={styles.container}> <View className={styles.container}>
<TopHeader /> <TopHeader />
...@@ -124,11 +126,15 @@ const AcceptPk = () => { ...@@ -124,11 +126,15 @@ const AcceptPk = () => {
</View> </View>
<View className={styles.bottom}> <View className={styles.bottom}>
{canGoNext ? (
<Image <Image
className={styles.clickImage} className={styles.clickImage}
onClick={handleClick} onClick={handleClick}
src={assetsPk['accept-click.png'].u} src={assetsPk['accept-click.png'].u}
/> />
) : (
<View className={classNames(styles.clickImage, styles.disabled)}>无法和自己PK哦~</View>
)}
</View> </View>
</View> </View>
......
...@@ -8,7 +8,7 @@ interface BattlesModel { ...@@ -8,7 +8,7 @@ interface BattlesModel {
setModalIsVisible: Action<BattlesModel, boolean>; setModalIsVisible: Action<BattlesModel, boolean>;
setUserDetails: Action<BattlesModel, PkDetails>; setUserDetails: Action<BattlesModel, PkDetails>;
setUserSummary: Action<BattlesModel, PkSummary>; setUserSummary: Action<BattlesModel, PkSummary>;
fetchUserDetails: Thunk<BattlesModel, PkParams>; fetchUserDetails: Thunk<BattlesModel, { initiator?: string; stageId?: string }>;
fetchUserSummary: Thunk<BattlesModel, PkParams>; fetchUserSummary: Thunk<BattlesModel, PkParams>;
} }
......
...@@ -42,8 +42,8 @@ const CreatePk = (props: CreatePkProps) => { ...@@ -42,8 +42,8 @@ const CreatePk = (props: CreatePkProps) => {
const [dataSource, loadData] = useFetch(fetchUserDetails, useCallback(() => { const [dataSource, loadData] = useFetch(fetchUserDetails, useCallback(() => {
if (!currentPkStage) return null if (!currentPkStage) return null
return { return {
userId: userInfo.userId, initiator: `${userInfo.userId}`,
stageId: currentPkStage.id stageId: `${currentPkStage.id}`
} }
}, [currentPkStage, userInfo])) }, [currentPkStage, userInfo]))
......
...@@ -13,8 +13,6 @@ const Scene = () => { ...@@ -13,8 +13,6 @@ const Scene = () => {
nextPkGuide() nextPkGuide()
} }
console.log(pkGuideStep, 11111111)
if (!pkGuideActive || pkGuideStep !== 3) { if (!pkGuideActive || pkGuideStep !== 3) {
return null return null
} }
......
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