Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
GeekLearnMathWeapp
Commits
c6523e1b
Commit
c6523e1b
authored
Jun 20, 2023
by
raca
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/2023-06-12-v1.1' of…
Merge branch 'feature/2023-06-12-v1.1' of
https://118.24.71.244/hewenhao/GeekLearnMathWeapp
into feature/2023-06-12-v1.1
parents
80507fe6
a5e4db02
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
78 additions
and
86 deletions
+78
-86
global.d.ts
global.d.ts
+2
-4
game.ts
src/api/game.ts
+3
-0
index.module.scss
src/native-components/pk-record/index.module.scss
+3
-4
index.ts
src/native-components/pk-record/index.ts
+28
-39
index.wxml
src/native-components/pk-record/index.wxml
+7
-7
index.tsx
src/pages/battles/index.tsx
+3
-13
battle-complete.tsx
src/pages/game/play/components/battle-complete.tsx
+20
-7
pk.tsx
src/pages/main/components/tutorial/pk.tsx
+1
-1
create-pk.tsx
src/pages/main/main-underground/create-pk.tsx
+3
-3
pk.tsx
src/pages/main/main-underground/pk-guide/pk.tsx
+1
-1
constants.ts
src/pages/main/main-underground/scene/constants.ts
+1
-1
stage.tsx
src/pages/main/main-underground/scene/stage.tsx
+3
-4
guide.ts
src/store/modules/guide.ts
+3
-2
No files found.
global.d.ts
View file @
c6523e1b
...
...
@@ -41,10 +41,8 @@ declare namespace JSX {
>
,
'pk-record'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[],
userId
:
number
,
winPoint
:
number
,
losePoint
:
number
list
:
any
[];
config
:
any
;
},
HTMLElement
>
,
...
...
src/api/game.ts
View file @
c6523e1b
...
...
@@ -72,6 +72,9 @@ export interface Stage {
/** 星星限制数量 */
limitStar
:
number
;
/** 拥有星星数量 */
holdStar
:
number
;
/** pk负 */
pkLoseNum
:
number
|
null
;
/** pk胜场 */
...
...
src/native-components/pk-record/index.module.scss
View file @
c6523e1b
...
...
@@ -64,7 +64,7 @@
.userName
{
font-weight
:
600
;
max-width
:
2
2
0px
;
max-width
:
2
4
0px
;
height
:
44px
;
line-height
:
44px
;
@include
ellipsis
();
...
...
@@ -117,7 +117,7 @@
transform
:
translateX
(
-50%
);
text-align
:
center
;
width
:
112px
;
.value
{
font-size
:
24px
;
color
:
#fff
;
...
...
@@ -184,4 +184,4 @@
100
%
{
transform
:
rotate
(
360deg
);
}
}
\ No newline at end of file
}
src/native-components/pk-record/index.ts
View file @
c6523e1b
...
...
@@ -3,22 +3,29 @@
import
{
rankTranslate
,
getImageForRank
}
from
'@/pages/battles/utils'
import
assets
from
'@/assets/oss/assets-pk'
import
assets2
from
'@/assets/oss/assets-prepare'
import
{
getStorage
,
StorageKeys
}
from
'@/utils/storage'
import
styles
from
'./index.module.scss'
const
PageSize
=
10
const
determineStyle
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
styles
.
statsWin
:
styles
.
statsLose
}
// @ts-ignore
Component
({
properties
:
{
userId
:
Number
,
winPoint
:
Number
,
losePoint
:
Number
,
list
:
{
type
:
Array
,
value
:
[],
},
config
:
{
type
:
Object
,
value
:
{}
}
},
observers
:
{
list
(
val
)
{
'list'
(
)
{
this
.
reset
()
},
},
...
...
@@ -34,6 +41,7 @@ Component({
this
.
_loading
=
false
this
.
_currentPage
=
0
this
.
loadMore
()
this
.
_userInfo
=
getStorage
(
StorageKeys
.
userInfo
)
},
methods
:
{
reset
()
{
...
...
@@ -63,50 +71,31 @@ Component({
hasNextPage
=
false
}
const
start
=
currentPage
*
PageSize
const
determineStyle
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
styles
.
statsWin
:
styles
.
statsLose
}
const
userInfo
=
this
.
_userInfo
const
determinePoint
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
this
.
data
.
winPoint
:
this
.
data
.
losePoint
const
isWin
=
item
=>
{
if
(
item
.
initiator
===
userInfo
?.
userId
)
{
return
item
.
result
===
'WIN'
}
return
item
.
result
===
'LOSE'
}
const
start
=
currentPage
*
PageSize
const
newList
=
list
.
slice
(
start
,
max
).
map
((
item
)
=>
{
const
isInitiator
=
item
.
initiator
===
this
.
data
.
userId
const
isRecipient
=
item
.
recipient
===
this
.
data
.
userId
const
isWin
=
(
item
.
result
===
'WIN'
&&
isInitiator
)
||
(
item
.
result
===
'LOSE'
&&
isRecipient
)
const
initiatorStyle
=
determineStyle
(
isInitiator
,
isWin
)
const
recipientStyle
=
determineStyle
(
isRecipient
,
isWin
)
const
initiatorPoint
=
determinePoint
(
isInitiator
,
isWin
)
const
recipientPoint
=
determinePoint
(
isRecipient
,
isWin
)
const
initiatorLevel
=
rankTranslate
(
item
.
initiatorLevel
)
const
recipientLevel
=
rankTranslate
(
item
.
recipientLevel
)
const
initiatorBadge
=
getImageForRank
(
item
.
initiatorLevel
)
const
recipientBadge
=
getImageForRank
(
item
.
recipientLevel
)
const
isInitiator
=
item
.
initiator
===
userInfo
?.
userId
const
isRecipient
=
item
.
recipient
===
userInfo
?.
userId
const
initiatorStyle
=
determineStyle
(
isInitiator
,
isWin
(
item
))
const
recipientStyle
=
determineStyle
(
isRecipient
,
isWin
(
item
))
return
{
...
item
,
isWin
,
wined
:
isWin
(
item
)
,
initiatorStyle
,
initiatorPoint
,
initiatorBadge
,
initiatorLevel
,
recipientPoint
,
recipientStyle
,
recipientLevel
,
recipientBadge
,
initiatorLevel
:
rankTranslate
(
item
.
initiatorLevel
),
recipientLevel
:
rankTranslate
(
item
.
recipientLevel
),
initiatorBadge
:
getImageForRank
(
item
.
initiatorLevel
),
recipientBadge
:
getImageForRank
(
item
.
recipientLevel
),
}
})
const
opts
=
{}
as
any
...
...
src/native-components/pk-record/index.wxml
View file @
c6523e1b
<template name="pkItem">
<view class="{{styles.gameResult}}">
<!-- levelInfo -->
<view class="{{styles.levelInfo}} {{item.
isWin
? styles.win : styles.lose}}">
<view class="{{styles.levelInfo}} {{item.
wined
? styles.win : styles.lose}}">
<text class="{{styles.levelName}}">{{item.stageName}}</text>
<image mode="widthFix" src="{{assets[item.
isWin
? 'win.png' : 'lose.png'].u}}" class="{{styles.levelResult}}"></image>
<image mode="widthFix" src="{{assets[item.
wined
? 'win.png' : 'lose.png'].u}}" class="{{styles.levelResult}}"></image>
<text class="{{styles.levelDate}}">{{item.createTime}}</text>
</view>
<!-- gameBody -->
...
...
@@ -11,7 +11,7 @@
<view class="{{styles.playerSection}}">
<!-- userInfo -->
<view class="{{styles.userInfo}}">
<text class="{{styles.userName}}">{{item.initiatorName
|| '-'
}}</text>
<text class="{{styles.userName}}">{{item.initiatorName}}</text>
<view class="{{styles.userBadge}}">
<image
class="{{styles.userIcon}}"
...
...
@@ -24,7 +24,7 @@
<image class="{{styles.vs}}" src="{{assets['vs.png'].u}}" />
<!-- userInfo 2 -->
<view class="{{styles.userInfo}}">
<text class="{{styles.userName}}" style="text-align: right">{{item.recipientName
|| '-'
}}</text>
<text class="{{styles.userName}}" style="text-align: right">{{item.recipientName}}</text>
<view class="{{styles.userBadge}}">
<image
class="{{styles.userIcon}}"
...
...
@@ -41,7 +41,7 @@
<text class="{{styles.value}}">{{item.initiatorResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+{{
item.initiatorPoint
}}</text>
<text>+{{
item.result === 'WIN' ? config.personalPkWinPoint : config.personalPkLosePoint
}}</text>
</view>
</view>
<!-- stats -->
...
...
@@ -56,7 +56,7 @@
<text class="{{styles.value}}">{{item.recipientResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+{{
item.recipientPoint
}}</text>
<text>+{{
item.result === 'WIN' ? config.personalPkLosePoint : config.personalPkWinPoint
}}</text>
</view>
</view>
</view>
...
...
@@ -64,7 +64,7 @@
</view>
</template>
<block wx:for="{{ realList }}" wx:key="userId">
<template is="pkItem" data="{{ styles, item, assets, assets2, rankTranslate }}" />
<template is="pkItem" data="{{ styles, item, assets, assets2, rankTranslate
, config
}}" />
</block>
<view class="{{styles.spinWrap}}" wx:if="{{loading}}">
<view class="{{styles.spin}}">
...
...
src/pages/battles/index.tsx
View file @
c6523e1b
...
...
@@ -18,13 +18,9 @@ import styles from './index.module.scss'
const
Battles
=
()
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
addPkGuideTimes
=
useStoreActions
((
state
)
=>
state
.
guideModel
.
addPkGuideTimes
)
const
getSetting
=
useStoreActions
((
state
)
=>
state
.
userModel
.
getSetting
)
const
setting
=
useStoreState
((
state
)
=>
state
.
userModel
.
setting
)
const
userInfo
=
useStoreState
((
state
)
=>
state
.
userModel
.
userInfo
)
const
addPkGuideTimes
=
useStoreActions
(
(
state
)
=>
state
.
guideModel
.
addPkGuideTimes
)
const
getSetting
=
useStoreActions
((
actions
)
=>
actions
.
userModel
.
getSetting
)
const
fetchUserSummary
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserSummary
...
...
@@ -76,13 +72,7 @@ const Battles = () => {
</
View
>
<
View
className=
{
styles
.
gameResult
}
>
<
pk
-
record
userId=
{
userInfo
.
userId
!
}
winPoint=
{
setting
.
personalPkWinPoint
||
0
}
losePoint=
{
setting
.
personalPkLosePoint
||
0
}
list=
{
summary
?.
records
||
[]
}
ref=
{
pkRecords
}
/>
<
pk
-
record
list=
{
summary
?.
records
||
[]
}
config=
{
setting
}
ref=
{
pkRecords
}
/>
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
>
...
...
src/pages/game/play/components/battle-complete.tsx
View file @
c6523e1b
...
...
@@ -19,6 +19,7 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
const
updateState
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
updateState
)
const
setting
=
useStoreState
(
state
=>
state
.
userModel
.
setting
)
const
getSetting
=
useStoreActions
(
actions
=>
actions
.
userModel
.
getSetting
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
upSelf
=
()
=>
{
updateState
({
isCreatePkShow
:
false
,
currentPkStage
:
null
})
...
...
@@ -35,11 +36,23 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return
getUserRank
(
pkResult
?.
recipientLevel
??
''
)
},
[
pkResult
])
const
isWin
=
useMemo
(()
=>
{
/** 从发起者角度算 */
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
isInitiatorFail
},
[
pkResult
,
isMySelf
,
isInitiatorFail
])
useEffect
(()
=>
{
if
(
pkResult
)
{
getSetting
()
...
...
@@ -47,11 +60,11 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
},
[
getSetting
,
pkResult
])
const
score
=
useMemo
(()
=>
{
if
(
is
Win
)
{
if
(
header
Win
)
{
return
setting
?.
personalPkWinPoint
??
0
}
return
setting
?.
personalPkLosePoint
??
0
},
[
setting
,
is
Win
])
},
[
setting
,
header
Win
])
if
(
!
pkResult
)
{
return
null
...
...
@@ -60,14 +73,14 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return
(
<
View
className=
{
styles
.
wrap
}
>
<
View
className=
{
styles
.
gap_1
}
></
View
>
<
Image
src=
{
is
Win
?
assetsGame
[
'pk-success.png'
].
u
:
assetsGame
[
'pk-fail.png'
].
u
}
className=
{
styles
.
pk_result
}
mode=
"heightFix"
></
Image
>
<
Image
src=
{
header
Win
?
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
,
!
is
Win
&&
styles
.
is_fail
)
}
>
<
View
className=
{
classNames
(
styles
.
game_role_left
,
!
is
InitiatorFail
&&
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
}
/>
...
...
@@ -79,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
,
is
Win
&&
styles
.
is_fail
)
}
>
<
View
className=
{
classNames
(
styles
.
game_role_right
,
is
InitiatorFail
&&
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
}
/>
...
...
src/pages/main/components/tutorial/pk.tsx
View file @
c6523e1b
...
...
@@ -18,7 +18,7 @@ const Scene = () => {
}
return
(
<
View
className=
{
styles
.
wrap
}
>
<
View
className=
{
styles
.
wrap
}
catchMove
>
<
Image
src=
{
assetsGuide
[
'cat-2.png'
].
u
}
className=
{
styles
.
cat
}
/>
<
View
className=
{
styles
.
dialog
}
>
<
View
>
...
...
src/pages/main/main-underground/create-pk.tsx
View file @
c6523e1b
...
...
@@ -91,13 +91,13 @@ const CreatePk = (props: CreatePkProps) => {
return
(
<>
{
visible
&&
(<
PkGuide
/>)
}
<
View
className=
{
classNames
(
styles
.
close_wrap
,
visible
&&
styles
.
is_show
)
}
style=
{
closeStyle
}
>
<
View
className=
{
classNames
(
styles
.
close_wrap
,
visible
&&
styles
.
is_show
)
}
style=
{
closeStyle
}
catchMove
>
<
View
className=
{
styles
.
close
}
onTouchStart=
{
closeModal
}
data
-
name=
"关闭发起PK"
>
<
Image
src=
{
assetsMainNext
[
'pk-close.png'
].
u
}
className=
{
styles
.
close_icon
}
></
Image
>
</
View
>
</
View
>
<
View
className=
{
classNames
(
styles
.
top
,
visible
&&
styles
.
is_show
)
}
>
<
View
className=
{
classNames
(
styles
.
top
,
visible
&&
styles
.
is_show
)
}
catchMove
>
<
Image
src=
{
assetsMainNext
[
'pk-top.png'
].
u
}
className=
{
styles
.
bg_top
}
mode=
"widthFix"
></
Image
>
<
View
className=
{
styles
.
top_content
}
>
<
View
className=
{
styles
.
pk_history
}
style=
{
historyStyle
}
onClick=
{
()
=>
navigateTo
({
url
:
'/pages/battles/index'
})
}
>
...
...
@@ -115,7 +115,7 @@ const CreatePk = (props: CreatePkProps) => {
</
View
>
</
View
>
<
View
className=
{
classNames
(
styles
.
bottom
,
visible
&&
styles
.
is_show
)
}
>
<
View
className=
{
classNames
(
styles
.
bottom
,
visible
&&
styles
.
is_show
)
}
catchMove
>
<
Image
src=
{
assetsMainNext
[
'pk-slogen.png'
].
u
}
className=
{
styles
.
pk_slogan
}
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-bottom.png'
].
u
}
className=
{
styles
.
bg_bottom
}
mode=
"widthFix"
></
Image
>
<
View
className=
{
styles
.
bottom_content
}
>
...
...
src/pages/main/main-underground/pk-guide/pk.tsx
View file @
c6523e1b
...
...
@@ -18,7 +18,7 @@ const Scene = () => {
}
return
(
<
View
className=
{
styles
.
wrap
}
>
<
View
className=
{
styles
.
wrap
}
catchMove
>
<
Image
src=
{
assetsGuide
[
'cat-2.png'
].
u
}
className=
{
styles
.
cat
}
/>
<
View
className=
{
styles
.
dialog
}
>
<
View
>
...
...
src/pages/main/main-underground/scene/constants.ts
View file @
c6523e1b
...
...
@@ -60,7 +60,7 @@ function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList
/** 设置pk历史页面返回后引导 */
if
(
currentIndex
!==
-
1
)
{
let
current
=
currentIndex
while
(
current
)
{
while
(
current
>=
0
)
{
const
currentItem
=
showList
[
current
]
if
(
currentItem
&&
currentItem
.
status
===
StageStatus
.
PASSED
&&
currentItem
.
type
!==
StageType
.
Special
)
{
currentItem
.
$lastPassedStage
=
true
...
...
src/pages/main/main-underground/scene/stage.tsx
View file @
c6523e1b
...
...
@@ -153,7 +153,6 @@ const StageComp = (props: StageProps) => {
const
nextPkGuide
=
useStoreActions
(
state
=>
state
.
guideModel
.
nextPkGuide
)
const
showPkGuideFromHis
=
useStoreState
(
state
=>
state
.
guideModel
.
showPkGuideFromHis
)
const
updateGuideState
=
useStoreActions
(
state
=>
state
.
guideModel
.
updateState
)
const
pkDetails
=
useStoreState
(
state
=>
state
.
userModel
.
pkDetails
)
const
isSpecialRound
=
useMemo
(()
=>
{
return
stage
.
type
===
StageType
.
Special
...
...
@@ -174,7 +173,7 @@ const StageComp = (props: StageProps) => {
const
handleClick
=
()
=>
{
if
(
stage
.
status
!==
StageStatus
.
DISABLED
||
!
isProduction
)
{
if
(
isSpecialRound
)
{
if
((
pkDetails
?.
stars
??
0
)
<
stage
.
limitStar
)
{
if
((
stage
.
holdStar
??
0
)
<
stage
.
limitStar
)
{
showToast
({
title
:
'星星数量不够,快去收集吧~'
,
icon
:
'none'
})
return
}
...
...
@@ -218,7 +217,7 @@ const StageComp = (props: StageProps) => {
}
case
StageStatus
.
CURRENT
:
{
if
(
isSpecialRound
&&
(
pkDetails
?.
stars
??
0
)
<
stage
.
limitStar
)
{
if
(
isSpecialRound
&&
(
stage
.
holdStar
??
0
)
<
stage
.
limitStar
)
{
return
(
<
Image
src=
{
getLockedIcon
(
stage
.
type
).
u
}
className=
{
getIconClassNames
(
stage
.
type
)
}
/>
)
...
...
@@ -301,7 +300,7 @@ const StageComp = (props: StageProps) => {
{
isSpecialRound
?
(
<
View
className=
{
styles
.
special_name
}
>
<
Image
src=
{
assetsMainNext
[
'star.png'
].
u
}
className=
{
styles
.
special_star
}
/>
星星
{
pkDetails
?.
stars
??
0
}
/
{
stage
.
limitStar
}
星星
{
stage
.
holdStar
??
0
}
/
{
stage
.
limitStar
}
</
View
>
)
:
(
<
View
>
{
!
isProduction
?
`${stage.id}.`
:
''
}{
stage
.
name
}
</
View
>
...
...
src/store/modules/guide.ts
View file @
c6523e1b
...
...
@@ -83,11 +83,12 @@ const guideModel: GuideModel = {
addPkGuideTimes
:
action
((
state
)
=>
{
let
next
if
(
state
.
pkGuideTimes
!==
null
)
{
if
(
state
.
pkGuideTimes
)
{
/** 只显示3次pk历史pk引导 */
if
(
state
.
pkGuideTimes
>=
3
)
{
return
}
next
=
state
.
pkGuideTimes
+
1
next
=
(
+
state
.
pkGuideTimes
)
+
1
}
else
{
next
=
1
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment