Commit 971a0708 authored by hewenhao's avatar hewenhao

feat: pk获取积分显示

parent 32858340
...@@ -63,8 +63,10 @@ export type SettintType = { ...@@ -63,8 +63,10 @@ export type SettintType = {
aPoint?: number, aPoint?: number,
bPoint?: number, bPoint?: number,
sPoint?: number, sPoint?: number,
createGroupPoint?: number createGroupPoint?: number;
joinGroupPoint?: number joinGroupPoint?: number;
personalPkLosePoint?: number;
personalPkWinPoint?: number;
} }
export function getSetting () { export function getSetting () {
......
...@@ -2,9 +2,9 @@ import { View, Image, Button } from '@tarojs/components' ...@@ -2,9 +2,9 @@ import { View, Image, Button } from '@tarojs/components'
import assetsGame from '@/assets/oss/assets-game' import assetsGame from '@/assets/oss/assets-game'
import assetsPrepare from '@/assets/oss/assets-prepare' import assetsPrepare from '@/assets/oss/assets-prepare'
import classNames from 'classnames' import classNames from 'classnames'
import { useMemo } from 'react' import { useMemo, useEffect } from 'react'
import { reLaunch } from '@tarojs/taro' import { reLaunch } from '@tarojs/taro'
import { useStoreActions } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import { getUserRank } from '@/utils' import { getUserRank } from '@/utils'
import { getUserLevelIcon, getUserLevelName, getUserLevelSubName } from '@/constants' import { getUserLevelIcon, getUserLevelName, getUserLevelSubName } from '@/constants'
import { PkResult } from '@/api' import { PkResult } from '@/api'
...@@ -17,6 +17,8 @@ type BattleCompleteProps = { ...@@ -17,6 +17,8 @@ type BattleCompleteProps = {
const BattleComplete = ({ pkResult }: BattleCompleteProps) => { const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
const updateState = useStoreActions(actions => actions.mainModel.updateState) const updateState = useStoreActions(actions => actions.mainModel.updateState)
const setting = useStoreState(state => state.userModel.setting)
const getSetting = useStoreActions(actions => actions.userModel.getSetting)
const upSelf = () => { const upSelf = () => {
updateState({ isCreatePkShow: false, currentPkStage: null }) updateState({ isCreatePkShow: false, currentPkStage: null })
...@@ -38,6 +40,19 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => { ...@@ -38,6 +40,19 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return pkResult?.result === 'LOSE' return pkResult?.result === 'LOSE'
}, [pkResult]) }, [pkResult])
useEffect(() => {
if (pkResult) {
getSetting()
}
}, [getSetting, pkResult])
const score = useMemo(() => {
if (isWin) {
return setting?.personalPkWinPoint ?? 0
}
return setting?.personalPkLosePoint ?? 0
}, [setting, isWin])
if (!pkResult) { if (!pkResult) {
return null return null
} }
...@@ -48,7 +63,7 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => { ...@@ -48,7 +63,7 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
<Image src={isWin ? assetsGame['pk-success.png'].u : assetsGame['pk-fail.png'].u} className={styles.pk_result} mode="heightFix"></Image> <Image src={isWin ? assetsGame['pk-success.png'].u : assetsGame['pk-fail.png'].u} className={styles.pk_result} mode="heightFix"></Image>
<View className={styles.game_bonus}> <View className={styles.game_bonus}>
<Image src={assetsPrepare['diamond.png'].u} className={styles.diamond}></Image> <Image src={assetsPrepare['diamond.png'].u} className={styles.diamond}></Image>
水晶 +5 水晶 +{score}
</View> </View>
<View className={styles.game_role}> <View className={styles.game_role}>
......
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