Commit 862945e3 authored by hewenhao's avatar hewenhao

feat: pk math

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