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
09fc26af
Commit
09fc26af
authored
Jun 20, 2023
by
raca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化
parent
59847ac9
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
491 additions
and
92 deletions
+491
-92
global.d.ts
global.d.ts
+66
-43
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-1
index.json
src/native-components/pk-record/index.json
+3
-0
index.module.scss
src/native-components/pk-record/index.module.scss
+188
-0
index.ts
src/native-components/pk-record/index.ts
+73
-0
index.wxml
src/native-components/pk-record/index.wxml
+76
-0
index.tsx
src/pages/accept-pk/index.tsx
+8
-5
battles-modal.tsx
src/pages/battles/components/battles-modal.tsx
+8
-5
game-result.tsx
src/pages/battles/components/game-result.tsx
+2
-3
player-details.tsx
src/pages/battles/components/player-details.tsx
+9
-5
top-header.module.scss
src/pages/battles/components/top-header.module.scss
+1
-1
const.ts
src/pages/battles/const.ts
+0
-22
index.config.ts
src/pages/battles/index.config.ts
+3
-0
index.tsx
src/pages/battles/index.tsx
+20
-7
utils.ts
src/pages/battles/utils.ts
+33
-0
No files found.
global.d.ts
View file @
09fc26af
/// <reference types="@tarojs/taro" />
/// <reference types="@tarojs/taro" />
declare
module
'*.png'
;
declare
module
'*.png'
declare
module
'*.gif'
;
declare
module
'*.gif'
declare
module
'*.jpg'
;
declare
module
'*.jpg'
declare
module
'*.jpeg'
;
declare
module
'*.jpeg'
declare
module
'*.svg'
;
declare
module
'*.svg'
declare
module
'*.css'
;
declare
module
'*.css'
declare
module
'*.less'
;
declare
module
'*.less'
declare
module
'*.scss'
;
declare
module
'*.scss'
declare
module
'*.sass'
;
declare
module
'*.sass'
declare
module
'*.styl'
;
declare
module
'*.styl'
type
CountUpTime
=
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
type
CountUpTime
=
React
.
DetailedHTMLProps
<
'maxValue'
?:
number
;
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'isDown'
?:
boolean
;
maxValue
?:
number
'startValue'
:
number
;
isDown
?:
boolean
exceedTime
:
number
;
startValue
:
number
onTimeup
?:
()
=>
void
;
exceedTime
:
number
onExceed
?:
()
=>
void
;
onTimeup
?:
()
=>
void
},
HTMLElement
>
onExceed
?:
()
=>
void
},
HTMLElement
>
declare
namespace
JSX
{
declare
namespace
JSX
{
interface
IntrinsicElements
{
interface
IntrinsicElements
{
// 扩展 IntrinsicElements 否则无法识别自定义标签
// 扩展 IntrinsicElements 否则无法识别自定义标签
'count-up-time'
:
CountUpTime
;
'count-up-time'
:
CountUpTime
'number-keyboard'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'number-keyboard'
:
React
.
DetailedHTMLProps
<
onType
?:
(
a
:
{
detail
:
string
})
=>
void
;
React
.
HTMLAttributes
<
HTMLElement
>
&
{
},
HTMLElement
>
;
onType
?:
(
a
:
{
detail
:
string
})
=>
void
'game-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
},
HTMLElement
>
'game-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
list
:
any
[]
},
HTMLElement
>
;
},
HTMLElement
>
,
'pk-record'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
},
HTMLElement
>
,
}
}
}
}
declare
namespace
NodeJS
{
declare
namespace
NodeJS
{
interface
ProcessEnv
{
interface
ProcessEnv
{
TARO_ENV
:
'weapp'
|
'swan'
|
'alipay'
|
'h5'
|
'rn'
|
'tt'
|
'quickapp'
|
'qq'
|
'jd'
TARO_ENV
:
|
'weapp'
|
'swan'
|
'alipay'
|
'h5'
|
'rn'
|
'tt'
|
'quickapp'
|
'qq'
|
'jd'
}
}
}
}
declare
module
'html-parse-stringify'
{
declare
module
'html-parse-stringify'
{
export
interface
TagNode
{
export
interface
TagNode
{
type
:
'tag'
;
type
:
'tag'
name
:
string
;
name
:
string
voidElement
:
boolean
;
voidElement
:
boolean
attrs
:
Record
<
string
,
string
|
undefined
>
;
attrs
:
Record
<
string
,
string
|
undefined
>
children
:
Node
[]
;
children
:
Node
[]
}
}
export
interface
TextNode
{
export
interface
TextNode
{
type
:
'text'
;
type
:
'text'
content
:
string
;
content
:
string
}
}
export
interface
ComponentNode
{
export
interface
ComponentNode
{
type
:
'component'
;
type
:
'component'
name
:
string
;
name
:
string
attrs
:
Record
<
string
,
string
|
undefined
>
;
attrs
:
Record
<
string
,
string
|
undefined
>
voidElement
:
boolean
;
voidElement
:
boolean
children
:
[]
;
children
:
[]
}
}
export
type
Node
=
TagNode
|
TextNode
|
ComponentNode
;
export
type
Node
=
TagNode
|
TextNode
|
ComponentNode
export
interface
ParseOptions
{
export
interface
ParseOptions
{
components
:
Record
<
string
,
boolean
>
;
components
:
Record
<
string
,
boolean
>
}
}
namespace
HtmlParseStringify
{
namespace
HtmlParseStringify
{
function
parse
(
html
:
string
,
options
?:
ParseOptions
):
Node
[]
;
function
parse
(
html
:
string
,
options
?:
ParseOptions
):
Node
[]
function
stringify
(
doc
:
Node
[]):
string
;
function
stringify
(
doc
:
Node
[]):
string
}
}
export
default
HtmlParseStringify
export
default
HtmlParseStringify
...
...
scripts/app.config.ts.tpl
View file @
09fc26af
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
export default {
export default {
pages: [
pages: [
'pages/main/main',
'pages/main/main',
'pages/market/index',
'pages/accept-pk/index',
'pages/accept-pk/index',
'pages/battles/index',
'pages/battles/index',
'pages/market/index',
'pages/prepare/index',
'pages/prepare/index',
'pages/group/index',
'pages/group/index',
'pages/game/play/index',
'pages/game/play/index',
...
...
src/native-components/pk-record/index.json
0 → 100644
View file @
09fc26af
{
"component"
:
true
}
src/native-components/pk-record/index.module.scss
0 → 100644
View file @
09fc26af
@import
'@/styles/mixins.scss'
;
.gameResult
{
color
:
#fff
;
margin-bottom
:
24px
;
}
.gameBody
{
border-bottom-left-radius
:
20px
;
border-bottom-right-radius
:
20px
;
padding
:
24px
30px
;
background-color
:
#fff
;
}
.win
{
background-color
:
#009AFB
;
}
.lose
{
background-color
:
#FE4E52
;
}
.levelInfo
{
border-top-left-radius
:
20px
;
border-top-right-radius
:
20px
;
padding
:
0
24px
;
height
:
72px
;
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
font-size
:
24px
;
position
:
relative
;
}
.levelResult
{
position
:
absolute
;
left
:
50%
;
transform
:
translateX
(
-50%
);
width
:
80px
;
height
:
50px
;
}
.playerSection
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
position
:
relative
;
}
.vs
{
position
:
absolute
;
left
:
50%
;
transform
:
translateX
(
-50%
);
width
:
80px
;
height
:
80px
;
}
.userInfo
{
display
:
flex
;
flex-direction
:
column
;
gap
:
10px
;
color
:
#465164
;
}
.userName
{
font-weight
:
600
;
max-width
:
220px
;
height
:
44px
;
line-height
:
44px
;
@include
ellipsis
();
}
.userBadge
{
display
:
flex
;
gap
:
6px
;
align-items
:
center
;
}
.userIcon
{
width
:
60px
;
height
:
60px
;
}
.userLevel
{
font-size
:
28px
;
}
.gameStats
{
display
:
flex
;
margin-top
:
20px
;
}
.stats
{
position
:
relative
;
display
:
flex
;
flex-direction
:
column
;
flex
:
1
;
gap
:
16px
;
.value
{
height
:
46px
;
line-height
:
46px
;
flex
:
1
;
font-weight
:
500
;
text-align
:
center
;
font-size
:
28px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
6px
;
}
&
:nth-child
(
2
)
{
z-index
:
2
;
position
:
absolute
;
left
:
50%
;
transform
:
translateX
(
-50%
);
text-align
:
center
;
width
:
112px
;
.value
{
font-size
:
24px
;
color
:
#fff
;
background
:
#93A0B7
;
border-radius
:
24px
;
}
}
}
.statsWin
.value
{
color
:
#009AFB
;
background-color
:
#E5F4FE
;
}
.statsLose
.value
{
color
:
#FE4E52
;
background-color
:
#FEEDED
;
}
.diamond
{
width
:
30px
;
height
:
30px
;
}
.emptyText
{
margin-top
:
48px
;
text-align
:
center
;
font-size
:
14
PX
;
color
:
rgba
(
70
,
81
,
100
,
0
.50
);
}
.spinWrap
{
color
:
#9999
;
padding
:
12
PX
0
;
text-align
:
center
;
}
.spin
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
z-index
:
9999
;
}
.spinIcon
{
border
:
4px
solid
#1786F7
;
border-top-color
:
inherit
;
border-radius
:
50%
;
animation
:
spin
1s
linear
infinite
;
width
:
18
PX
;
height
:
18
PX
;
}
.spinText
{
font-size
:
14
PX
;
margin-left
:
12
PX
;
}
@keyframes
spin
{
0
%
{
transform
:
rotate
(
0deg
);
}
100
%
{
transform
:
rotate
(
360deg
);
}
}
\ No newline at end of file
src/native-components/pk-record/index.ts
0 → 100644
View file @
09fc26af
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
import
{
rankTranslate
,
getImageForRank
}
from
'@/pages/battles/utils'
import
assets
from
'@/assets/oss/assets-pk'
import
assets2
from
'@/assets/oss/assets-prepare'
import
styles
from
'./index.module.scss'
const
PageSize
=
10
// @ts-ignore
Component
({
properties
:
{
list
:
{
type
:
Array
,
value
:
[],
},
},
data
:
{
styles
,
assets
,
assets2
,
realList
:
[],
loading
:
false
,
},
attached
()
{
this
.
_hasNextPage
=
true
this
.
_loading
=
false
this
.
_currentPage
=
0
this
.
loadMore
()
},
methods
:
{
async
loadMore
()
{
if
(
this
.
_loading
||
!
this
.
_hasNextPage
)
return
this
.
_loading
=
true
this
.
setData
({
loading
:
true
})
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
300
))
const
{
list
}
=
this
.
data
const
currentPage
=
this
.
_currentPage
const
nextPage
=
currentPage
+
1
let
max
=
nextPage
*
PageSize
let
hasNextPage
=
true
if
(
max
>=
list
.
length
)
{
max
=
list
.
length
hasNextPage
=
false
}
const
start
=
currentPage
*
PageSize
const
newList
=
list
.
slice
(
start
,
max
).
map
((
item
)
=>
({
...
item
,
wined
:
item
.
result
===
'WIN'
,
initiatorLevel
:
rankTranslate
(
item
.
initiatorLevel
),
recipientLevel
:
rankTranslate
(
item
.
recipientLevel
),
initiatorBadge
:
getImageForRank
(
item
.
initiatorLevel
),
recipientBadge
:
getImageForRank
(
item
.
recipientLevel
),
}))
const
opts
=
{}
as
any
newList
.
forEach
((
item
,
index
)
=>
{
opts
[
`realList[
${
index
+
start
}
]`
]
=
item
})
opts
.
loading
=
false
this
.
setData
(
opts
,
()
=>
{
this
.
_loading
=
false
this
.
_currentPage
=
nextPage
this
.
_hasNextPage
=
hasNextPage
})
},
},
})
src/native-components/pk-record/index.wxml
0 → 100644
View file @
09fc26af
<template name="pkItem">
<view class="{{styles.gameResult}}">
<!-- levelInfo -->
<view class="{{styles.levelInfo}} {{item.wined ? 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>
<text class="{{styles.levelDate}}">{{item.createTime}}</text>
</view>
<!-- gameBody -->
<view class="{{styles.gameBody}}">
<view class="{{styles.playerSection}}">
<!-- userInfo -->
<view class="{{styles.userInfo}}">
<text class="{{styles.userName}}">{{item.initiatorName}}</text>
<view class="{{styles.userBadge}}">
<image
class="{{styles.userIcon}}"
src="{{assets[item.initiatorBadge.small].u}}"
/>
<text class="{{styles.userLevel}}">{{item.initiatorLevel}}</text>
</view>
</view>
<!-- 战斗png -->
<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>
<view class="{{styles.userBadge}}">
<image
class="{{styles.userIcon}}"
src="{{assets[item.recipientBadge.small].u}}"
/>
<text class="{{styles.userLevel}}">{{item.recipientLevel}}</text>
</view>
</view>
</view>
<!-- gameStats -->
<view class="{{styles.gameStats}}">
<view class="{{styles.stats}} {{item.wined ? styles.statsWin : styles.statsLose}}">
<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>
</view>
</view>
<!-- stats -->
<view class="{{styles.stats}}">
<text class="{{styles.value}}">答题对错</text>
<text class="{{styles.value}}">答题用时</text>
<text class="{{styles.value}}">PK奖励</text>
</view>
<!-- stats -->
<view class="{{styles.stats}} {{!item.wined ? styles.statsWin : styles.statsLose}}">
<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>
</view>
</view>
</view>
</view>
</view>
</template>
<block wx:for="{{ realList }}" wx:key="userId">
<template is="pkItem" data="{{ styles, item, assets, assets2, rankTranslate }}" />
</block>
<view class="{{styles.spinWrap}}" wx:if="{{loading}}">
<view class="{{styles.spin}}">
<view class="{{styles.spinIcon}}"></view>
<View class="{{styles.spinText}}">加载中</View>
</view>
</view>
<view class="{{styles.emptyText}}" wx:if="{{list.length < 1}}">暂无数据</view>
\ No newline at end of file
src/pages/accept-pk/index.tsx
View file @
09fc26af
...
@@ -6,11 +6,10 @@ import assetsPk from '@/assets/oss/assets-pk'
...
@@ -6,11 +6,10 @@ import assetsPk from '@/assets/oss/assets-pk'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
{
useRef
,
useMemo
}
from
'react'
import
{
useRef
,
useMemo
}
from
'react'
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'
import
ModalName
from
'./components/modal-name'
import
ModalName
from
'./components/modal-name'
import
{
rankTranslate
}
from
'../battles/utils'
import
{
getImageForRank
,
rankTranslate
}
from
'../battles/utils'
const
AcceptPk
=
()
=>
{
const
AcceptPk
=
()
=>
{
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
...
@@ -61,6 +60,10 @@ const AcceptPk = () => {
...
@@ -61,6 +60,10 @@ const AcceptPk = () => {
return
userInfo
.
userId
!==
details
?.
userId
return
userInfo
.
userId
!==
details
?.
userId
},
[
userInfo
,
details
])
},
[
userInfo
,
details
])
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
details
?.
userRanks
.
level
)
},
[
details
?.
userRanks
.
level
])
return
(
return
(
<
View
className=
{
styles
.
container
}
>
<
View
className=
{
styles
.
container
}
>
<
TopHeader
/>
<
TopHeader
/>
...
@@ -108,10 +111,10 @@ const AcceptPk = () => {
...
@@ -108,10 +111,10 @@ const AcceptPk = () => {
<
View
className=
{
styles
.
record
}
>
<
View
className=
{
styles
.
record
}
>
<
View
className=
{
styles
.
rank
}
>
<
View
className=
{
styles
.
rank
}
>
<
Image
{
getImageForBadge
&&
<
Image
src=
{
assetsPk
[
badgeImages
.
bronz
e
.
default
].
u
}
src=
{
assetsPk
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
className=
{
styles
.
badgeIcon
}
/>
/>
}
<
Text
className=
{
styles
.
rankText
}
>
<
Text
className=
{
styles
.
rankText
}
>
{
rankTranslate
(
details
?.
userRanks
.
level
)
}
{
rankTranslate
(
details
?.
userRanks
.
level
)
}
</
Text
>
</
Text
>
...
...
src/pages/battles/components/battles-modal.tsx
View file @
09fc26af
...
@@ -6,12 +6,11 @@ import { useStoreState, useStoreActions } from '@/store/hooks'
...
@@ -6,12 +6,11 @@ import { useStoreState, useStoreActions } from '@/store/hooks'
import
{
convertDateTime
}
from
'@/utils/day'
import
{
convertDateTime
}
from
'@/utils/day'
import
{
receivePkPrize
}
from
'@/api/pk'
import
{
receivePkPrize
}
from
'@/api/pk'
import
assets
from
'@/assets/oss/assets-pk'
import
assets
from
'@/assets/oss/assets-pk'
import
{
badgeImages
}
from
'../const'
import
{
UserInfo
,
GameResultProps
}
from
'./game-result'
import
{
UserInfo
,
GameResultProps
}
from
'./game-result'
import
styles
from
'./battles-modal.module.scss'
import
styles
from
'./battles-modal.module.scss'
import
gameResultStyles
from
'./game-result.module.scss'
import
gameResultStyles
from
'./game-result.module.scss'
import
{
rankTranslate
}
from
'../utils'
import
{
rankTranslate
,
getImageForRank
}
from
'../utils'
const
BattlesModal
=
()
=>
{
const
BattlesModal
=
()
=>
{
const
isVisible
=
useStoreState
(
state
=>
state
.
battlesModel
.
modalIsVisible
)
const
isVisible
=
useStoreState
(
state
=>
state
.
battlesModel
.
modalIsVisible
)
...
@@ -55,6 +54,10 @@ const BattlesModal = () => {
...
@@ -55,6 +54,10 @@ const BattlesModal = () => {
})
})
},
[
setModalIsVisible
])
},
[
setModalIsVisible
])
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
pkDetails
?.
userRanks
.
level
)
},
[
pkDetails
?.
userRanks
.
level
])
return
(
return
(
<
Modal
<
Modal
maskClosable=
{
false
}
maskClosable=
{
false
}
...
@@ -78,10 +81,10 @@ const BattlesModal = () => {
...
@@ -78,10 +81,10 @@ const BattlesModal = () => {
</
View
>
</
View
>
<
View
className=
{
styles
.
details
}
>
<
View
className=
{
styles
.
details
}
>
<
Image
{
getImageForBadge
&&
<
Image
src=
{
assets
[
badgeImages
.
bronz
e
.
default
].
u
}
src=
{
assets
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
className=
{
styles
.
badgeIcon
}
/>
/>
}
<
View
className=
{
styles
.
detailsRight
}
>
<
View
className=
{
styles
.
detailsRight
}
>
<
Text
className=
{
styles
.
badgeText
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
pkDetails
?.
userRanks
.
level
)
}
{
rankTranslate
(
pkDetails
?.
userRanks
.
level
)
}
...
...
src/pages/battles/components/game-result.tsx
View file @
09fc26af
...
@@ -6,9 +6,8 @@ import assets from '@/assets/oss/assets-pk'
...
@@ -6,9 +6,8 @@ import assets from '@/assets/oss/assets-pk'
import
assets2
from
'@/assets/oss/assets-prepare'
import
assets2
from
'@/assets/oss/assets-prepare'
import
{
PkRecord
}
from
'@/api/pk'
import
{
PkRecord
}
from
'@/api/pk'
import
{
badgeImages
}
from
'../const'
import
styles
from
'./game-result.module.scss'
import
styles
from
'./game-result.module.scss'
import
{
rankTranslate
}
from
'../utils'
import
{
getImageForRank
,
rankTranslate
}
from
'../utils'
export
interface
GameResultProps
{
export
interface
GameResultProps
{
record
:
PkRecord
record
:
PkRecord
...
@@ -71,7 +70,7 @@ export const UserInfo = (user: {
...
@@ -71,7 +70,7 @@ export const UserInfo = (user: {
<
View
className=
{
styles
.
userBadge
}
>
<
View
className=
{
styles
.
userBadge
}
>
<
Image
<
Image
className=
{
styles
.
userIcon
}
className=
{
styles
.
userIcon
}
src=
{
assets
[
badgeImages
.
diamond
.
small
].
u
}
src=
{
assets
[
getImageForRank
(
user
.
level
).
default
].
u
}
/>
/>
<
Text
className=
{
styles
.
userLevel
}
>
{
rankTranslate
(
user
.
level
)
}
</
Text
>
<
Text
className=
{
styles
.
userLevel
}
>
{
rankTranslate
(
user
.
level
)
}
</
Text
>
</
View
>
</
View
>
...
...
src/pages/battles/components/player-details.tsx
View file @
09fc26af
import
{
useMemo
}
from
'react'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
useStoreState
}
from
'@/store/hooks'
import
assets
from
'@/assets/oss/assets-pk'
import
assets
from
'@/assets/oss/assets-pk'
import
styles
from
'./player-details.module.scss'
import
styles
from
'./player-details.module.scss'
import
{
badgeImages
}
from
'../const'
import
{
rankTranslate
,
getImageForRank
}
from
'../utils'
import
{
rankTranslate
}
from
'../utils'
const
PlayerDetails
=
()
=>
{
const
PlayerDetails
=
()
=>
{
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
summary
?.
userRanks
.
level
)
},
[
summary
?.
userRanks
.
level
])
return
(
return
(
<
View
className=
{
styles
.
player
}
>
<
View
className=
{
styles
.
player
}
>
<
View
className=
{
styles
.
playerHeader
}
>
<
View
className=
{
styles
.
playerHeader
}
>
<
Image
{
getImageForBadge
&&
<
Image
src=
{
assets
[
badgeImages
.
bronz
e
.
default
].
u
}
src=
{
assets
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
className=
{
styles
.
badgeIcon
}
></
Image
>
></
Image
>
}
<
Text
className=
{
styles
.
badgeText
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
</
Text
>
</
Text
>
...
...
src/pages/battles/components/top-header.module.scss
View file @
09fc26af
.header
{
.header
{
position
:
fixed
;
position
:
fixed
;
z-index
:
2
;
z-index
:
100
;
left
:
0
;
left
:
0
;
top
:
0
;
top
:
0
;
right
:
0
;
right
:
0
;
...
...
src/pages/battles/const.ts
deleted
100644 → 0
View file @
59847ac9
export
const
badgeImages
=
{
bronze
:
{
default
:
'bronze.png'
,
small
:
'bronze-small.png'
},
silver
:
{
default
:
'silver.png'
,
small
:
'silver-small.png'
},
gold
:
{
default
:
'gold.png'
,
small
:
'gold-small.png'
},
platinum
:
{
default
:
'platinum.png'
,
small
:
'platinum-small.png'
},
diamond
:
{
default
:
'diamond.png'
,
small
:
'diamond-small.png'
}
}
src/pages/battles/index.config.ts
View file @
09fc26af
...
@@ -3,4 +3,7 @@ export default definePageConfig({
...
@@ -3,4 +3,7 @@ export default definePageConfig({
navigationStyle
:
'custom'
,
navigationStyle
:
'custom'
,
navigationBarTextStyle
:
'white'
,
navigationBarTextStyle
:
'white'
,
enableShareAppMessage
:
true
,
enableShareAppMessage
:
true
,
usingComponents
:
{
'pk-record'
:
'@/native-components/pk-record/index'
}
})
})
src/pages/battles/index.tsx
View file @
09fc26af
import
{
useMemo
}
from
'react'
import
{
useMemo
,
useRef
}
from
'react'
import
{
getMenuButtonBoundingClientRect
,
useDidShow
}
from
'@tarojs/taro'
import
{
getCurrentInstance
,
getMenuButtonBoundingClientRect
,
useDidShow
,
useReachBottom
,
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
Button
from
'@/components/Button'
import
Button
from
'@/components/Button'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
assets
from
'@/assets/oss/assets-pk'
import
assets
from
'@/assets/oss/assets-pk'
import
TopHeader
from
'./components/top-header'
import
TopHeader
from
'./components/top-header'
import
PlayerDetails
from
'./components/player-details'
import
PlayerDetails
from
'./components/player-details'
import
GameResult
from
'./components/game-result'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
...
@@ -22,6 +26,18 @@ const Battles = () => {
...
@@ -22,6 +26,18 @@ const Battles = () => {
fetchUserSummary
({})
fetchUserSummary
({})
})
})
const
page
=
useMemo
(()
=>
getCurrentInstance
()?.
page
,
[])
const
pkRecords
=
useRef
(
null
)
useReachBottom
(()
=>
{
if
(
pkRecords
.
current
)
{
;(
page
?.
selectComponent
?.(
`#
${(
pkRecords
.
current
as
any
).
uid
}
`
)
as
any
)?.
loadMore
()
}
})
return
(
return
(
<
View
className=
{
styles
.
wrapper
}
>
<
View
className=
{
styles
.
wrapper
}
>
<
TopHeader
/>
<
TopHeader
/>
...
@@ -46,10 +62,7 @@ const Battles = () => {
...
@@ -46,10 +62,7 @@ const Battles = () => {
</
View
>
</
View
>
<
View
className=
{
styles
.
gameResult
}
>
<
View
className=
{
styles
.
gameResult
}
>
{
summary
&&
summary
.
records
.
length
>
0
<
pk
-
record
list=
{
summary
?.
records
||
[]
}
ref=
{
pkRecords
}
/>
?
summary
.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
</
View
>
</
View
>
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
>
<
View
className=
{
styles
.
bottom
}
>
...
...
src/pages/battles/utils.ts
View file @
09fc26af
...
@@ -25,3 +25,36 @@ export function rankTranslate (rankWithLevel: string | undefined): string {
...
@@ -25,3 +25,36 @@ export function rankTranslate (rankWithLevel: string | undefined): string {
return
`
${
rankName
[
rank
as
Rank
]}
${
toRomanNumeral
(
Number
(
level
))}
`
return
`
${
rankName
[
rank
as
Rank
]}
${
toRomanNumeral
(
Number
(
level
))}
`
}
}
const
badgeImages
=
{
bronze
:
{
default
:
'bronze.png'
,
small
:
'bronze-small.png'
,
},
silver
:
{
default
:
'silver.png'
,
small
:
'silver-small.png'
,
},
gold
:
{
default
:
'gold.png'
,
small
:
'gold-small.png'
,
},
platinum
:
{
default
:
'platinum.png'
,
small
:
'platinum-small.png'
,
},
diamond
:
{
default
:
'diamond.png'
,
small
:
'diamond-small.png'
,
},
}
export
function
getImageForRank
(
rankWithLevel
:
string
|
undefined
)
{
if
(
!
rankWithLevel
)
{
return
null
}
const
[
rank
]
=
rankWithLevel
.
split
(
'_'
)
return
badgeImages
[
rank
.
toLowerCase
()]
}
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