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