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),
}
}))
}
......
......@@ -6,7 +6,7 @@
display: flex;
flex-direction: column;
height: 100vh;
.wrapper {
position: relative;
z-index: 10;
......@@ -15,7 +15,7 @@
background-size: 100%;
background-image: url(https://cdn.jkwljy.com/pk-math/4K3EkZMaNtrrAwyxpsqiLbV4GkNC/750x1648);
background-repeat: no-repeat;
.pkFlash {
position: relative;
display: flex;
......@@ -50,7 +50,7 @@
opacity: 1;
}
}
.flash {
position: absolute;
width: 360px;
......@@ -84,35 +84,35 @@
height: 80px;
}
}
.inner {
display: flex;
flex-direction: column;
align-items: center;
.userSection {
display: flex;
gap: 12px;
font-weight: 600;
margin-bottom: 12px;
align-items: flex-end;
.userName {
font-size: 48px;
}
.challenge {
font-size: 40px;
}
}
}
.avatar {
width: 248px;
height: 248px;
margin: 48px 0 30px;
}
.record {
width: 440px;
background: linear-gradient(270deg, rgba(83,55,170,0) 0%, #5134A9 46%, rgba(82,53,169,0) 100%);
......@@ -123,29 +123,41 @@
gap: 8px;
letter-spacing: 2px;
padding: 12px 0;
.rank {
display: flex;
align-items: center;
gap: 6px;
.badgeIcon {
width: 60px;
height: 60px;
}
}
}
.bottom {
bottom: 24px;
position: fixed;
left: 50%;
transform: translateX(-50%);
.clickImage {
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}>
<Image
className={styles.clickImage}
onClick={handleClick}
src={assetsPk['accept-click.png'].u}
/>
{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