Commit 2155adb1 authored by hewenhao's avatar hewenhao

feat: 分享

parent 245d40da
......@@ -36,13 +36,22 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return getUserRank(pkResult?.recipientLevel ?? '')
}, [pkResult])
const isWin = useMemo(() => {
if (userInfo.userId && userInfo.userId === pkResult?.initiator) {
const isMySelf = useMemo(() => {
return userInfo.userId && userInfo.userId === pkResult?.initiator
}, [userInfo, pkResult])
/** 发起者输了 */
const isInitiatorFail = useMemo(() => {
return pkResult?.result === 'LOSE'
}, [pkResult])
const headerWin = useMemo(() => {
if (isMySelf) {
return pkResult?.result === 'WIN'
}
/** 从发起者角度算 */
return pkResult?.result === 'LOSE'
}, [pkResult, userInfo])
return isInitiatorFail
}, [pkResult, isMySelf, isInitiatorFail])
useEffect(() => {
if (pkResult) {
......@@ -51,11 +60,11 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
}, [getSetting, pkResult])
const score = useMemo(() => {
if (isWin) {
if (headerWin) {
return setting?.personalPkWinPoint ?? 0
}
return setting?.personalPkLosePoint ?? 0
}, [setting, isWin])
}, [setting, headerWin])
if (!pkResult) {
return null
......@@ -64,14 +73,14 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return (
<View className={styles.wrap}>
<View className={styles.gap_1}></View>
<Image src={isWin ? assetsGame['pk-success.png'].u : assetsGame['pk-fail.png'].u} className={styles.pk_result} mode="heightFix"></Image>
<Image src={headerWin ? assetsGame['pk-success.png'].u : assetsGame['pk-fail.png'].u} className={styles.pk_result} mode="heightFix"></Image>
<View className={styles.game_bonus}>
<Image src={assetsPrepare['diamond.png'].u} className={styles.diamond}></Image>
水晶 +{score}
</View>
<View className={styles.game_role}>
<View className={classNames(styles.game_role_left, !isWin && styles.is_fail)}>
<View className={classNames(styles.game_role_left, !isInitiatorFail && styles.is_fail)}>
<View className={styles.user_name}>{pkResult.recipientName}</View>
<View className={styles.user_level}>
<Image src={getUserLevelIcon(recipientLevel.level)} className={styles.level_icon} />
......@@ -83,7 +92,7 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
<View className={classNames(styles.info, styles.is_info_2)}>答题用时:{pkResult.recipientResultTime}s</View>
</View>
<View className={classNames(styles.game_role_right, isWin && styles.is_fail)}>
<View className={classNames(styles.game_role_right, isInitiatorFail && styles.is_fail)}>
<View className={styles.user_name}>{pkResult.initiatorName}</View>
<View className={styles.user_level}>
<Image src={getUserLevelIcon(initiatorLevel.level)} className={styles.level_icon} />
......
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