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
341d45f2
Commit
341d45f2
authored
Jun 20, 2023
by
hewenhao
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 dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp into feature/2023-06-12-v1.1
parents
05d10e19
09fc26af
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
594 additions
and
120 deletions
+594
-120
global.d.ts
global.d.ts
+66
-43
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-1
auth.ts
src/api/auth.ts
+17
-0
pk.ts
src/api/pk.ts
+11
-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
+54
-19
game-result.module.scss
src/pages/battles/components/game-result.module.scss
+2
-0
game-result.tsx
src/pages/battles/components/game-result.tsx
+13
-6
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
header.tsx
src/pages/main/main-underground/header.tsx
+2
-2
top-bar.tsx
src/pages/prepare/components/top-bar.tsx
+2
-2
user.ts
src/store/modules/user.ts
+12
-6
No files found.
global.d.ts
View file @
341d45f2
/// <reference types="@tarojs/taro" />
declare
module
'*.png'
;
declare
module
'*.gif'
;
declare
module
'*.jpg'
;
declare
module
'*.jpeg'
;
declare
module
'*.svg'
;
declare
module
'*.css'
;
declare
module
'*.less'
;
declare
module
'*.scss'
;
declare
module
'*.sass'
;
declare
module
'*.styl'
;
declare
module
'*.png'
declare
module
'*.gif'
declare
module
'*.jpg'
declare
module
'*.jpeg'
declare
module
'*.svg'
declare
module
'*.css'
declare
module
'*.less'
declare
module
'*.scss'
declare
module
'*.sass'
declare
module
'*.styl'
type
CountUpTime
=
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'maxValue'
?:
number
;
'isDown'
?:
boolean
;
'startValue'
:
number
;
exceedTime
:
number
;
onTimeup
?:
()
=>
void
;
onExceed
?:
()
=>
void
;
},
HTMLElement
>
type
CountUpTime
=
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
maxValue
?:
number
isDown
?:
boolean
startValue
:
number
exceedTime
:
number
onTimeup
?:
()
=>
void
onExceed
?:
()
=>
void
},
HTMLElement
>
declare
namespace
JSX
{
declare
namespace
JSX
{
interface
IntrinsicElements
{
// 扩展 IntrinsicElements 否则无法识别自定义标签
'count-up-time'
:
CountUpTime
;
'number-keyboard'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
onType
?:
(
a
:
{
detail
:
string
})
=>
void
;
},
HTMLElement
>
;
'game-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'count-up-time'
:
CountUpTime
'number-keyboard'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
onType
?:
(
a
:
{
detail
:
string
})
=>
void
},
HTMLElement
>
'game-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
},
HTMLElement
>
;
},
HTMLElement
>
,
'pk-record'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
},
HTMLElement
>
,
}
}
declare
namespace
NodeJS
{
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'
{
export
interface
TagNode
{
type
:
'tag'
;
name
:
string
;
voidElement
:
boolean
;
attrs
:
Record
<
string
,
string
|
undefined
>
;
children
:
Node
[]
;
type
:
'tag'
name
:
string
voidElement
:
boolean
attrs
:
Record
<
string
,
string
|
undefined
>
children
:
Node
[]
}
export
interface
TextNode
{
type
:
'text'
;
content
:
string
;
type
:
'text'
content
:
string
}
export
interface
ComponentNode
{
type
:
'component'
;
name
:
string
;
attrs
:
Record
<
string
,
string
|
undefined
>
;
voidElement
:
boolean
;
children
:
[]
;
type
:
'component'
name
:
string
attrs
:
Record
<
string
,
string
|
undefined
>
voidElement
:
boolean
children
:
[]
}
export
type
Node
=
TagNode
|
TextNode
|
ComponentNode
;
export
type
Node
=
TagNode
|
TextNode
|
ComponentNode
export
interface
ParseOptions
{
components
:
Record
<
string
,
boolean
>
;
components
:
Record
<
string
,
boolean
>
}
namespace
HtmlParseStringify
{
function
parse
(
html
:
string
,
options
?:
ParseOptions
):
Node
[]
;
function
stringify
(
doc
:
Node
[]):
string
;
function
parse
(
html
:
string
,
options
?:
ParseOptions
):
Node
[]
function
stringify
(
doc
:
Node
[]):
string
}
export
default
HtmlParseStringify
...
...
scripts/app.config.ts.tpl
View file @
341d45f2
...
...
@@ -7,9 +7,9 @@
export default {
pages: [
'pages/main/main',
'pages/market/index',
'pages/accept-pk/index',
'pages/battles/index',
'pages/market/index',
'pages/prepare/index',
'pages/group/index',
'pages/game/play/index',
...
...
src/api/auth.ts
View file @
341d45f2
...
...
@@ -2,6 +2,7 @@ import { request, requestAfterSilentLogin } from '@/utils/request'
import
{
request
as
requesNative
}
from
'@tarojs/taro'
import
{
getCurrentShareId
}
from
'@/utils/share'
import
type
{
UserInfo
}
from
'@/types'
import
{
PkDetails
,
PkRecord
}
from
'./pk'
type
LoginResult
=
UserInfo
...
...
@@ -130,3 +131,19 @@ export function changeNickName (nickName: string) {
}
}))
}
export
type
AccountInfo
=
{
accounts
:
AccountOut
[];
pkList
:
PkRecord
[];
stars
:
number
;
}
&
Pick
<
PkDetails
,
'userRanks'
|
'winPkNum'
>
export
const
fetchAccountInfo
=
()
=>
{
return
requestAfterSilentLogin
<
AccountInfo
,
{
userId
?:
number
}
>
((
userInfo
)
=>
({
url
:
'/service-idea/home/index'
,
method
:
'GET'
,
data
:
{
userId
:
userInfo
?.
userId
,
},
}))
}
src/api/pk.ts
View file @
341d45f2
...
...
@@ -34,9 +34,10 @@ export async function fetchUserDetails (data: { initiator?: string; stageId?: st
}
export
type
PkRecord
=
{
createTime
:
string
;
createTime
:
string
,
id
:
number
,
initiator
:
number
,
initiatorLevel
:
string
,
initiatorAvatar
:
string
,
initiatorErrNum
:
number
,
initiatorName
:
string
,
...
...
@@ -47,6 +48,7 @@ export type PkRecord = {
recipientErrNum
:
number
,
recipientName
:
string
,
recipientResultTime
:
number
,
recipientLevel
:
string
,
result
:
'LOSE'
|
'WIN'
,
stageName
:
string
}
...
...
@@ -116,3 +118,11 @@ export async function getPkResult (params: number) {
r
.
data
.
battleId
=
params
return
r
}
export
async
function
receivePkPrize
()
{
return
requestAfterSilentLogin
((
userInfo
)
=>
({
url
:
'/service-idea/pk/personal/receivePkPrize'
,
method
:
'GET'
,
data
:
{
userId
:
userInfo
?.
userId
}
}))
}
src/native-components/pk-record/index.json
0 → 100644
View file @
341d45f2
{
"component"
:
true
}
src/native-components/pk-record/index.module.scss
0 → 100644
View file @
341d45f2
@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 @
341d45f2
/* 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 @
341d45f2
<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 @
341d45f2
...
...
@@ -6,11 +6,10 @@ import assetsPk from '@/assets/oss/assets-pk'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
classNames
from
'classnames'
import
{
useRef
,
useMemo
}
from
'react'
import
{
badgeImages
}
from
'../battles/const'
import
styles
from
'./index.module.scss'
import
TopHeader
from
'./components/top-header'
import
ModalName
from
'./components/modal-name'
import
{
rankTranslate
}
from
'../battles/utils'
import
{
getImageForRank
,
rankTranslate
}
from
'../battles/utils'
const
AcceptPk
=
()
=>
{
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
...
...
@@ -61,6 +60,10 @@ const AcceptPk = () => {
return
userInfo
.
userId
!==
details
?.
userId
},
[
userInfo
,
details
])
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
details
?.
userRanks
.
level
)
},
[
details
?.
userRanks
.
level
])
return
(
<
View
className=
{
styles
.
container
}
>
<
TopHeader
/>
...
...
@@ -108,10 +111,10 @@ const AcceptPk = () => {
<
View
className=
{
styles
.
record
}
>
<
View
className=
{
styles
.
rank
}
>
<
Image
src=
{
assetsPk
[
badgeImages
.
bronz
e
.
default
].
u
}
{
getImageForBadge
&&
<
Image
src=
{
assetsPk
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
/>
/>
}
<
Text
className=
{
styles
.
rankText
}
>
{
rankTranslate
(
details
?.
userRanks
.
level
)
}
</
Text
>
...
...
src/pages/battles/components/battles-modal.tsx
View file @
341d45f2
import
{
useEffect
,
useState
,
useMemo
}
from
'react'
import
{
useEffect
,
useState
,
useMemo
,
useCallback
}
from
'react'
import
{
View
,
Text
,
Image
,
ScrollView
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
Modal
from
'@/components/Modal'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
convertDateTime
}
from
'@/utils/day'
import
{
receivePkPrize
}
from
'@/api/pk'
import
assets
from
'@/assets/oss/assets-pk'
import
{
badgeImages
}
from
'../const'
import
{
UserInfo
,
GameResultProps
}
from
'./game-result'
import
styles
from
'./battles-modal.module.scss'
import
gameResultStyles
from
'./game-result.module.scss'
import
{
rankTranslate
}
from
'../utils'
import
{
rankTranslate
,
getImageForRank
}
from
'../utils'
const
BattlesModal
=
()
=>
{
const
isVisible
=
useStoreState
(
state
=>
state
.
battlesModel
.
modalIsVisible
)
const
setModalIsVisible
=
useStoreActions
(
actions
=>
actions
.
battlesModel
.
setModalIsVisible
)
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
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
)
...
...
@@ -48,12 +48,23 @@ const BattlesModal = () => {
const
hasAreaAndGrad
=
useMemo
(()
=>
!!
userInfo
.
city
&&
!!
userInfo
.
grade
,
[
userInfo
])
const
onClose
=
useCallback
(()
=>
{
receivePkPrize
().
finally
(()
=>
{
setModalIsVisible
(
false
)
})
},
[
setModalIsVisible
])
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
pkDetails
?.
userRanks
.
level
)
},
[
pkDetails
?.
userRanks
.
level
])
return
(
<
Modal
maskClosable=
{
false
}
isVisible=
{
hasAreaAndGrad
&&
enable
&&
!
pkGuideActive
&&
!
groupGuideActive
&&
!
mainGuideActive
&&
isVisible
}
wrapClassName=
{
styles
.
modalWrap
}
bodyClassName=
{
styles
.
modalBody
}
onClose=
{
()
=>
setModalIsVisible
(
false
)
}
onClose=
{
onClose
}
tilte=
{
<
Text
style=
{
{
marginLeft
:
10
}
}
>
· PK 战报
</
Text
>
}
>
<
View
className=
{
styles
.
inner
}
>
...
...
@@ -70,13 +81,13 @@ const BattlesModal = () => {
</
View
>
<
View
className=
{
styles
.
details
}
>
<
Image
src=
{
assets
[
badgeImages
.
bronz
e
.
default
].
u
}
{
getImageForBadge
&&
<
Image
src=
{
assets
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
/>
/>
}
<
View
className=
{
styles
.
detailsRight
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
{
rankTranslate
(
pkDetails
?.
userRanks
.
level
)
}
</
Text
>
<
View
className=
{
styles
.
badgeBar
}
>
{
[...
Array
(
3
)].
map
((
_
,
index
)
=>
(
...
...
@@ -84,7 +95,9 @@ const BattlesModal = () => {
key=
{
index
}
className=
{
classNames
(
styles
.
badgeBarItem
,
index
<
(
summary
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
index
<
(
pkDetails
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
)
}
></
Text
>
))
}
...
...
@@ -93,10 +106,13 @@ const BattlesModal = () => {
</
View
>
<
ScrollView
className=
{
styles
.
gameResult
}
scrollY
>
{
summary
&&
summary
?.
records
.
length
>
0
?
summary
?.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
{
pkDetails
&&
pkDetails
?.
pkList
.
length
>
0
?
(
pkDetails
?.
pkList
.
map
((
item
)
=>
(
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>
))
)
:
(
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
)
}
</
ScrollView
>
</
View
>
</
Modal
>
...
...
@@ -119,17 +135,36 @@ const GameResult = ({ record }: GameResultProps) => {
src=
{
wined
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
className=
{
gameResultStyles
.
levelResult
}
/>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
gameBody
}
>
<
View
className=
{
styles
.
playerSection
}
>
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
name=
{
record
.
initiatorName
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
level=
{
record
.
initiatorLevel
}
name=
{
record
.
initiatorName
}
/>
</
View
>
<
Image
className=
{
gameResultStyles
.
vs
}
src=
{
assets
[
'vs.png'
].
u
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
name=
{
record
.
recipientName
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
level=
{
record
.
recipientLevel
}
name=
{
record
.
recipientName
}
/>
</
View
>
</
View
>
</
View
>
...
...
src/pages/battles/components/game-result.module.scss
View file @
341d45f2
...
...
@@ -64,6 +64,8 @@
.userName
{
font-weight
:
600
;
max-width
:
220px
;
height
:
44px
;
line-height
:
44px
;
@include
ellipsis
();
}
...
...
src/pages/battles/components/game-result.tsx
View file @
341d45f2
...
...
@@ -6,8 +6,8 @@ import assets from '@/assets/oss/assets-pk'
import
assets2
from
'@/assets/oss/assets-prepare'
import
{
PkRecord
}
from
'@/api/pk'
import
{
badgeImages
}
from
'../const'
import
styles
from
'./game-result.module.scss'
import
{
getImageForRank
,
rankTranslate
}
from
'../utils'
export
interface
GameResultProps
{
record
:
PkRecord
...
...
@@ -29,15 +29,18 @@ const GameResult = ({ record }: GameResultProps) => {
src=
{
assets
[
wined
?
'win.png'
:
'lose.png'
].
u
}
className=
{
styles
.
levelResult
}
/>
<
Text
className=
{
styles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
<
Text
className=
{
styles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
gameBody
}
>
<
View
className=
{
styles
.
playerSection
}
>
<
UserInfo
name=
{
record
.
initiatorName
}
/>
<
UserInfo
level=
{
record
.
recipientLevel
}
name=
{
record
.
initiatorName
}
/>
<
Image
className=
{
styles
.
vs
}
src=
{
assets
[
'vs.png'
].
u
}
/>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
level=
{
record
.
recipientLevel
}
name=
{
record
.
recipientName
}
/>
</
View
>
...
...
@@ -57,15 +60,19 @@ const GameResult = ({ record }: GameResultProps) => {
)
}
export
const
UserInfo
=
(
user
:
{
name
:
string
;
style
?:
CSSProperties
})
=>
(
export
const
UserInfo
=
(
user
:
{
name
:
string
level
:
string
style
?:
CSSProperties
})
=>
(
<
View
style=
{
user
.
style
}
className=
{
styles
.
userInfo
}
>
<
Text
className=
{
styles
.
userName
}
>
{
user
.
name
}
</
Text
>
<
View
className=
{
styles
.
userBadge
}
>
<
Image
className=
{
styles
.
userIcon
}
src=
{
assets
[
badgeImages
.
diamond
.
small
].
u
}
src=
{
assets
[
getImageForRank
(
user
.
level
).
default
].
u
}
/>
<
Text
className=
{
styles
.
userLevel
}
>
{
user
.
name
}
</
Text
>
<
Text
className=
{
styles
.
userLevel
}
>
{
rankTranslate
(
user
.
level
)
}
</
Text
>
</
View
>
</
View
>
)
...
...
src/pages/battles/components/player-details.tsx
View file @
341d45f2
import
{
useMemo
}
from
'react'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
{
useStoreState
}
from
'@/store/hooks'
import
assets
from
'@/assets/oss/assets-pk'
import
styles
from
'./player-details.module.scss'
import
{
badgeImages
}
from
'../const'
import
{
rankTranslate
}
from
'../utils'
import
{
rankTranslate
,
getImageForRank
}
from
'../utils'
const
PlayerDetails
=
()
=>
{
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
getImageForBadge
=
useMemo
(()
=>
{
return
getImageForRank
(
summary
?.
userRanks
.
level
)
},
[
summary
?.
userRanks
.
level
])
return
(
<
View
className=
{
styles
.
player
}
>
<
View
className=
{
styles
.
playerHeader
}
>
<
Image
src=
{
assets
[
badgeImages
.
bronz
e
.
default
].
u
}
{
getImageForBadge
&&
<
Image
src=
{
assets
[
getImageForBadg
e
.
default
].
u
}
className=
{
styles
.
badgeIcon
}
></
Image
>
></
Image
>
}
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
</
Text
>
...
...
src/pages/battles/components/top-header.module.scss
View file @
341d45f2
.header
{
position
:
fixed
;
z-index
:
2
;
z-index
:
100
;
left
:
0
;
top
:
0
;
right
:
0
;
...
...
src/pages/battles/const.ts
deleted
100644 → 0
View file @
05d10e19
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 @
341d45f2
...
...
@@ -3,4 +3,7 @@ export default definePageConfig({
navigationStyle
:
'custom'
,
navigationBarTextStyle
:
'white'
,
enableShareAppMessage
:
true
,
usingComponents
:
{
'pk-record'
:
'@/native-components/pk-record/index'
}
})
src/pages/battles/index.tsx
View file @
341d45f2
import
{
useMemo
}
from
'react'
import
{
getMenuButtonBoundingClientRect
,
useDidShow
,
navigateBack
}
from
'@tarojs/taro'
import
{
useMemo
,
useRef
}
from
'react'
import
{
getCurrentInstance
,
getMenuButtonBoundingClientRect
,
useDidShow
,
navigateBack
,
useReachBottom
,
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
Button
from
'@/components/Button'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
assets
from
'@/assets/oss/assets-pk'
import
TopHeader
from
'./components/top-header'
import
PlayerDetails
from
'./components/player-details'
import
GameResult
from
'./components/game-result'
import
styles
from
'./index.module.scss'
...
...
@@ -28,6 +32,18 @@ const Battles = () => {
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
(
<
View
className=
{
styles
.
wrapper
}
>
<
TopHeader
/>
...
...
@@ -52,10 +68,7 @@ const Battles = () => {
</
View
>
<
View
className=
{
styles
.
gameResult
}
>
{
summary
&&
summary
.
records
.
length
>
0
?
summary
.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
<
pk
-
record
list=
{
summary
?.
records
||
[]
}
ref=
{
pkRecords
}
/>
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
>
...
...
src/pages/battles/utils.ts
View file @
341d45f2
...
...
@@ -25,3 +25,36 @@ export function rankTranslate (rankWithLevel: string | undefined): string {
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
()]
}
src/pages/main/main-underground/header.tsx
View file @
341d45f2
...
...
@@ -27,7 +27,7 @@ const MainHeader = () => {
}
},
[
sys
,
nav
])
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
pkDetails
=
useStoreState
(
state
=>
state
.
userModel
.
pkDetails
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
...
...
@@ -51,7 +51,7 @@ const MainHeader = () => {
</
View
>
<
View
className=
{
classNames
(
styles
.
ph
,
cs
.
bounce_btn
)
}
onClick=
{
goStore
}
hoverClass=
{
cs
.
bounce_btn_hover
}
id=
"main_header_ph"
>
<
Image
src=
{
assets
[
'star.png'
].
u
}
className=
{
styles
.
icon
}
/>
<
Text
>
{
cardNum
}
</
Text
>
<
Text
>
{
pkDetails
?.
stars
}
</
Text
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/prepare/components/top-bar.tsx
View file @
341d45f2
...
...
@@ -15,7 +15,7 @@ const goStore = () => {
export
default
({
isFirstStage
}:
{
isFirstStage
:
boolean
})
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
pkDetails
=
useStoreState
(
state
=>
state
.
userModel
.
pkDetails
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
sys
=
useMemo
(
getSystemInfoSync
,
[])
...
...
@@ -44,7 +44,7 @@ export default ({ isFirstStage }: { isFirstStage: boolean }) => {
</
Scene3
>
<
View
className=
{
styles
.
ph
}
onClick=
{
goStore
}
>
<
Image
src=
{
assets
[
'star.png'
].
u
}
className=
{
styles
.
icon
}
/>
<
Text
>
{
cardNum
}
</
Text
>
<
Text
>
{
pkDetails
?.
stars
}
</
Text
>
</
View
>
</
View
>
<
View
style=
{
rightStyle
}
className=
{
styles
.
right
}
></
View
>
...
...
src/store/modules/user.ts
View file @
341d45f2
import
{
action
,
Action
,
Thunk
,
thunk
,
State
}
from
'easy-peasy'
import
{
getAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
type
UpdateUserInfoIn
,
updateUserPhone
,
changeNickName
}
from
'@/api'
import
{
fetchAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
type
UpdateUserInfoIn
,
updateUserPhone
,
changeNickName
,
AccountInfo
}
from
'@/api'
import
type
{
UserInfo
}
from
'@/types'
import
{
ExchangeParams
,
accountExchange
,
pointToCard
}
from
'@/api/account'
import
{
showModal
,
show
Toast
,
show
Loading
,
hideLoading
}
from
'@tarojs/taro'
import
{
showModal
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
import
{
getStorage
,
StorageKeys
,
updateStorage
}
from
'@/utils/storage'
import
{
Deferred
}
from
'@/utils/deferred'
import
{
AppStoreModel
}
from
'../store-model'
...
...
@@ -13,6 +13,7 @@ export interface UserModel {
/** 加入部落 */
joinDefered
:
Deferred
|
null
;
userInfo
:
UserInfo
;
pkDetails
:
Omit
<
AccountInfo
,
'accounts'
>
|
null
;
cardNum
:
number
;
point
:
number
;
updating
:
boolean
;
...
...
@@ -33,6 +34,7 @@ export interface UserModel {
const
userModel
:
UserModel
=
{
joinDefered
:
null
,
pkDetails
:
null
,
userInfo
:
getStorage
(
StorageKeys
.
userInfo
)
!
,
isEyeProtectionMode
:
false
,
cardNum
:
0
,
...
...
@@ -162,11 +164,15 @@ const userModel: UserModel = {
fetchAccount
:
thunk
(
async
(
actions
)
=>
{
try
{
const
{
data
:
list
}
=
await
getAccountInfo
()
const
cardNum
=
list
.
find
(
c
=>
c
.
accountType
===
'CARD'
)?.
amount
??
0
const
point
=
list
.
find
(
c
=>
c
.
accountType
===
'POINT'
)?.
amount
??
0
actions
.
updateState
({
cardNum
,
point
})
const
{
data
,
code
}
=
await
fetchAccountInfo
()
if
(
code
===
0
)
{
const
{
accounts
,
...
pkDetails
}
=
data
const
cardNum
=
accounts
.
find
(
c
=>
c
.
accountType
===
'CARD'
)?.
amount
??
0
const
point
=
accounts
.
find
(
c
=>
c
.
accountType
===
'POINT'
)?.
amount
??
0
actions
.
updateState
({
cardNum
,
point
,
pkDetails
})
return
point
}
return
0
}
catch
(
err
)
{
actions
.
updateState
({
cardNum
:
0
,
point
:
0
})
return
0
...
...
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