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
80507fe6
Commit
80507fe6
authored
Jun 20, 2023
by
raca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
971a0708
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
143 additions
and
44 deletions
+143
-44
global.d.ts
global.d.ts
+4
-1
index.ts
src/native-components/pk-record/index.ts
+49
-9
index.wxml
src/native-components/pk-record/index.wxml
+8
-8
modal-name.module.scss
src/pages/accept-pk/components/modal-name.module.scss
+2
-0
modal-name.tsx
src/pages/accept-pk/components/modal-name.tsx
+6
-2
top-header.module.scss
src/pages/accept-pk/components/top-header.module.scss
+1
-0
battles-modal.module.scss
src/pages/battles/components/battles-modal.module.scss
+0
-1
battles-modal.tsx
src/pages/battles/components/battles-modal.tsx
+56
-20
index.tsx
src/pages/battles/index.tsx
+17
-3
No files found.
global.d.ts
View file @
80507fe6
...
...
@@ -41,7 +41,10 @@ declare namespace JSX {
>
,
'pk-record'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
list
:
any
[],
userId
:
number
,
winPoint
:
number
,
losePoint
:
number
},
HTMLElement
>
,
...
...
src/native-components/pk-record/index.ts
View file @
80507fe6
...
...
@@ -9,15 +9,18 @@ const PageSize = 10
// @ts-ignore
Component
({
properties
:
{
userId
:
Number
,
winPoint
:
Number
,
losePoint
:
Number
,
list
:
{
type
:
Array
,
value
:
[],
},
},
observers
:
{
'list'
(
val
)
{
list
(
val
)
{
this
.
reset
()
}
}
,
},
data
:
{
styles
,
...
...
@@ -61,14 +64,51 @@ Component({
}
const
start
=
currentPage
*
PageSize
const
newList
=
list
.
slice
(
start
,
max
).
map
((
item
)
=>
({
const
determineStyle
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
styles
.
statsWin
:
styles
.
statsLose
}
const
determinePoint
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
this
.
data
.
winPoint
:
this
.
data
.
losePoint
}
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
)
return
{
...
item
,
wined
:
item
.
result
===
'WIN'
,
initiatorLevel
:
rankTranslate
(
item
.
initiatorLevel
),
recipientLevel
:
rankTranslate
(
item
.
recipientLevel
),
initiatorBadge
:
getImageForRank
(
item
.
initiatorLevel
),
recipientBadge
:
getImageForRank
(
item
.
recipientLevel
),
}))
isWin
,
initiatorStyle
,
initiatorPoint
,
initiatorBadge
,
initiatorLevel
,
recipientPoint
,
recipientStyle
,
recipientLevel
,
recipientBadge
,
}
})
const
opts
=
{}
as
any
newList
.
forEach
((
item
,
index
)
=>
{
...
...
src/native-components/pk-record/index.wxml
View file @
80507fe6
<template name="pkItem">
<view class="{{styles.gameResult}}">
<!-- levelInfo -->
<view class="{{styles.levelInfo}} {{item.
wined
? styles.win : styles.lose}}">
<view class="{{styles.levelInfo}} {{item.
isWin
? styles.win : styles.lose}}">
<text class="{{styles.levelName}}">{{item.stageName}}</text>
<image mode="widthFix" src="{{assets[item.
wined
? 'win.png' : 'lose.png'].u}}" class="{{styles.levelResult}}"></image>
<image mode="widthFix" src="{{assets[item.
isWin
? '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}}"
...
...
@@ -36,12 +36,12 @@
</view>
<!-- gameStats -->
<view class="{{styles.gameStats}}">
<view class="{{styles.stats}} {{item.
wined ? styles.statsWin : styles.statsLos
e}}">
<view class="{{styles.stats}} {{item.
initiatorStyl
e}}">
<text class="{{styles.value}}">{{item.initiatorErrNum > 0 ? '错'+item.initiatorErrNum+'题' : '全对'}}</text>
<text class="{{styles.value}}">{{item.initiatorResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+
10
</text>
<text>+
{{item.initiatorPoint}}
</text>
</view>
</view>
<!-- stats -->
...
...
@@ -51,12 +51,12 @@
<text class="{{styles.value}}">PK奖励</text>
</view>
<!-- stats -->
<view class="{{styles.stats}} {{
!item.wined ? styles.statsWin : styles.statsLos
e}}">
<view class="{{styles.stats}} {{
item.recipientStyl
e}}">
<text class="{{styles.value}}">{{item.recipientErrNum > 0 ? '错'+item.recipientErrNum+'题' : '全对'}}</text>
<text class="{{styles.value}}">{{item.recipientResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+
15
</text>
<text>+
{{item.recipientPoint}}
</text>
</view>
</view>
</view>
...
...
src/pages/accept-pk/components/modal-name.module.scss
View file @
80507fe6
...
...
@@ -65,8 +65,10 @@
background
:
#F4F6F8
;
border-radius
:
56px
;
}
.inputName
{
flex
:
1
;
text-align
:
left
;
font-size
:
36px
;
font-weight
:
600
;
color
:
#465164
;
...
...
src/pages/accept-pk/components/modal-name.tsx
View file @
80507fe6
import
{
View
,
RootPortal
,
Image
,
Button
,
ButtonProps
,
CommonEventFunction
}
from
'@tarojs/components'
import
{
View
,
RootPortal
,
Image
,
Button
,
ButtonProps
,
CommonEventFunction
,
Input
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
{
useCallback
,
useRef
,
useState
}
from
'react'
import
{
EyeProtectionView
}
from
'@/components'
...
...
@@ -98,7 +98,11 @@ const ModalName = ({
请输入您的角色名(7字以内)
</
View
>
<
View
className=
{
styles
.
input
}
>
<
View
className=
{
styles
.
inputName
}
>
{
name
}
</
View
>
<
Input
className=
{
styles
.
inputName
}
value=
{
name
as
string
}
onInput=
{
(
e
)
=>
setName
(
e
.
detail
.
value
)
}
/>
<
Image
src=
{
assetsGuide
[
'touzi.png'
].
u
}
className=
{
classNames
(
...
...
src/pages/accept-pk/components/top-header.module.scss
View file @
80507fe6
...
...
@@ -13,6 +13,7 @@
.arrow
{
position
:
absolute
;
z-index
:
999
;
left
:
10
PX
;
width
:
30
PX
;
height
:
30
PX
;
...
...
src/pages/battles/components/battles-modal.module.scss
View file @
80507fe6
...
...
@@ -81,7 +81,6 @@
display
:
flex
;
flex-direction
:
column
;
text-align
:
center
;
gap
:
16px
;
max-height
:
500px
;
}
...
...
src/pages/battles/components/battles-modal.tsx
View file @
80507fe6
...
...
@@ -13,15 +13,23 @@ import gameResultStyles from './game-result.module.scss'
import
{
rankTranslate
,
getImageForRank
}
from
'../utils'
const
BattlesModal
=
()
=>
{
const
isVisible
=
useStoreState
(
state
=>
state
.
battlesModel
.
modalIsVisible
)
const
setModalIsVisible
=
useStoreActions
(
actions
=>
actions
.
battlesModel
.
setModalIsVisible
)
const
fetchAccount
=
useStoreActions
(
actions
=>
actions
.
userModel
.
fetchAccount
)
const
isVisible
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
modalIsVisible
)
const
setModalIsVisible
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
setModalIsVisible
)
const
fetchAccount
=
useStoreActions
(
(
actions
)
=>
actions
.
userModel
.
fetchAccount
)
const
pkDetails
=
useStoreState
((
state
)
=>
state
.
userModel
.
pkDetails
)
const
pkGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
pkGuideActive
)
const
groupGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
groupGuideActive
)
const
mainGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
mainGuideActive
)
const
joinDeferred
=
useStoreState
(
state
=>
state
.
userModel
.
joinDefered
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
pkGuideActive
=
useStoreState
((
state
)
=>
state
.
guideModel
.
pkGuideActive
)
const
groupGuideActive
=
useStoreState
(
(
state
)
=>
state
.
guideModel
.
groupGuideActive
)
const
mainGuideActive
=
useStoreState
(
(
state
)
=>
state
.
guideModel
.
mainGuideActive
)
const
joinDeferred
=
useStoreState
((
state
)
=>
state
.
userModel
.
joinDefered
)
const
userInfo
=
useStoreState
((
state
)
=>
state
.
userModel
.
userInfo
)
const
[
enable
,
setEnable
]
=
useState
(
false
)
...
...
@@ -45,7 +53,10 @@ const BattlesModal = () => {
}
},
[
pkDetails
,
setModalIsVisible
])
const
hasAreaAndGrad
=
useMemo
(()
=>
!!
userInfo
.
city
&&
!!
userInfo
.
grade
,
[
userInfo
])
const
hasAreaAndGrad
=
useMemo
(
()
=>
!!
userInfo
.
city
&&
!!
userInfo
.
grade
,
[
userInfo
]
)
const
onClose
=
useCallback
(()
=>
{
receivePkPrize
().
finally
(()
=>
{
...
...
@@ -61,7 +72,14 @@ const BattlesModal = () => {
return
(
<
Modal
maskClosable=
{
false
}
isVisible=
{
hasAreaAndGrad
&&
enable
&&
!
pkGuideActive
&&
!
groupGuideActive
&&
!
mainGuideActive
&&
isVisible
}
isVisible=
{
hasAreaAndGrad
&&
enable
&&
!
pkGuideActive
&&
!
groupGuideActive
&&
!
mainGuideActive
&&
isVisible
}
wrapClassName=
{
styles
.
modalWrap
}
bodyClassName=
{
styles
.
modalBody
}
onClose=
{
onClose
}
...
...
@@ -81,10 +99,12 @@ const BattlesModal = () => {
</
View
>
<
View
className=
{
styles
.
details
}
>
{
getImageForBadge
&&
<
Image
{
getImageForBadge
&&
(
<
Image
src=
{
assets
[
getImageForBadge
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
/>
}
/>
)
}
<
View
className=
{
styles
.
detailsRight
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
pkDetails
?.
userRanks
.
level
)
}
...
...
@@ -108,7 +128,11 @@ const BattlesModal = () => {
<
ScrollView
className=
{
styles
.
gameResult
}
scrollY
>
{
pkDetails
&&
pkDetails
?.
pkList
.
length
>
0
?
(
pkDetails
?.
pkList
.
map
((
item
)
=>
(
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>
<
GameResult
userId=
{
userInfo
.
userId
!
}
key=
{
item
.
id
}
record=
{
item
}
/>
))
)
:
(
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
...
...
@@ -119,20 +143,32 @@ const BattlesModal = () => {
)
}
const
GameResult
=
({
record
}:
GameResultProps
)
=>
{
const
wined
=
record
.
result
===
'WIN'
const
determineStyle
=
(
isPlayer
:
boolean
,
isWin
:
boolean
)
=>
{
return
(
isWin
&&
isPlayer
)
||
(
!
isWin
&&
!
isPlayer
)
?
styles
.
win
:
styles
.
lose
}
const
GameResult
=
({
record
,
userId
,
}:
GameResultProps
&
{
userId
:
number
})
=>
{
const
isInitiator
=
record
.
initiator
===
userId
const
isRecipient
=
record
.
recipient
===
userId
const
isWin
=
(
record
.
result
===
'WIN'
&&
isInitiator
)
||
(
record
.
result
===
'LOSE'
&&
isRecipient
)
const
initiatorStyle
=
determineStyle
(
isInitiator
,
isWin
)
const
recipientStyle
=
determineStyle
(
isRecipient
,
isWin
)
return
(
<
View
className=
{
gameResultStyles
.
gameResult
}
>
<
View
className=
{
gameResultStyles
.
gameResult
}
style=
{
{
marginBottom
:
12
}
}
>
<
View
className=
{
classNames
(
gameResultStyles
.
levelInfo
,
wined
?
gameResultStyles
.
win
:
gameResultStyles
.
lose
isWin
?
gameResultStyles
.
win
:
gameResultStyles
.
lose
)
}
>
<
Text
className=
{
gameResultStyles
.
levelName
}
>
{
record
.
stageName
}
</
Text
>
<
Image
mode=
"widthFix"
src=
{
wined
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
src=
{
isWin
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
className=
{
gameResultStyles
.
levelResult
}
/>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
...
...
@@ -145,7 +181,7 @@ const GameResult = ({ record }: GameResultProps) => {
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
los
e
initiatorStyl
e
)
}
>
<
UserInfo
...
...
@@ -157,7 +193,7 @@ const GameResult = ({ record }: GameResultProps) => {
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
los
e
recipientStyl
e
)
}
>
<
UserInfo
...
...
src/pages/battles/index.tsx
View file @
80507fe6
...
...
@@ -2,7 +2,8 @@ import { useMemo, useRef } from 'react'
import
{
getCurrentInstance
,
getMenuButtonBoundingClientRect
,
useDidShow
,
navigateBack
,
useDidShow
,
navigateBack
,
useReachBottom
,
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
...
...
@@ -17,7 +18,13 @@ 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
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
...
...
@@ -30,6 +37,7 @@ const Battles = () => {
useDidShow
(()
=>
{
fetchUserSummary
({})
getSetting
()
})
const
page
=
useMemo
(()
=>
getCurrentInstance
()?.
page
,
[])
...
...
@@ -68,7 +76,13 @@ const Battles = () => {
</
View
>
<
View
className=
{
styles
.
gameResult
}
>
<
pk
-
record
list=
{
summary
?.
records
||
[]
}
ref=
{
pkRecords
}
/>
<
pk
-
record
userId=
{
userInfo
.
userId
!
}
winPoint=
{
setting
.
personalPkWinPoint
||
0
}
losePoint=
{
setting
.
personalPkLosePoint
||
0
}
list=
{
summary
?.
records
||
[]
}
ref=
{
pkRecords
}
/>
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
>
...
...
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