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
c6b40ab0
Commit
c6b40ab0
authored
Jun 19, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 分享结果页
parent
179e9441
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
95 additions
and
9 deletions
+95
-9
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-0
pk.ts
src/api/pk.ts
+11
-2
index.config.ts
src/pages/game/battle/index.config.ts
+5
-0
index.tsx
src/pages/game/battle/index.tsx
+43
-0
battle-complete.module.scss
src/pages/game/play/components/battle-complete.module.scss
+1
-0
battle-complete.tsx
src/pages/game/play/components/battle-complete.tsx
+9
-5
index.config.ts
src/pages/game/play/index.config.ts
+1
-0
index.tsx
src/pages/game/play/index.tsx
+24
-2
No files found.
scripts/app.config.ts.tpl
View file @
c6b40ab0
...
...
@@ -15,6 +15,7 @@ export default {
'pages/game/play/index',
'pages/game/wrong/index',
'pages/game/complete/index',
'pages/game/battle/index',
],
subPackages: {
{
packages
}
},
resizable: true,
...
...
src/api/pk.ts
View file @
c6b40ab0
import
{
requestAfterSilentLogin
}
from
'@/utils/request'
import
{
handleShare
}
from
'@/utils/share'
export
type
PkParams
=
{
stageId
?:
number
,
...
...
@@ -97,12 +98,20 @@ export type PkResult = SubmitPkResultParams & {
recipientStar
:
number
;
result
:
string
;
stageName
:
string
;
battleId
:
number
;
}
export
function
getPkResult
(
params
:
number
)
{
return
requestAfterSilentLogin
<
PkResult
,
{
id
:
number
}
>
(()
=>
({
export
async
function
getPkShareResult
(
params
:
{
battleId
:
string
})
{
const
pp
=
await
handleShare
(
params
)
return
await
getPkResult
(
+
pp
.
battleId
)
}
export
async
function
getPkResult
(
params
:
number
)
{
const
r
=
await
requestAfterSilentLogin
<
PkResult
,
{
id
:
number
}
>
(()
=>
({
url
:
'/service-idea/pk/personal/pkDetail'
,
method
:
'GET'
,
data
:
{
id
:
params
}
}))
r
.
data
.
battleId
=
params
return
r
}
src/pages/game/battle/index.config.ts
0 → 100644
View file @
c6b40ab0
export
default
definePageConfig
({
navigationBarTitleText
:
'pk-math'
,
navigationStyle
:
'custom'
,
enableShareAppMessage
:
true
,
})
src/pages/game/battle/index.tsx
0 → 100644
View file @
c6b40ab0
import
{
useRouter
,
useDidShow
}
from
'@tarojs/taro'
import
{
useFetch
,
useShare
}
from
'@/hooks'
import
{
useCallback
,
}
from
'react'
import
{
getPkShareResult
}
from
'@/api'
import
BattleComplete
from
'../play/components/battle-complete'
const
BattleIndex
=
()
=>
{
const
router
=
useRouter
<
{
battleId
:
string
}
>
()
const
[
dataSource
,
loadData
]
=
useFetch
(
getPkShareResult
,
useCallback
(()
=>
{
return
router
.
params
},
[
router
.
params
]))
useDidShow
(()
=>
{
loadData
()
})
const
shareParams
=
useCallback
(()
=>
{
if
(
dataSource
.
detail
)
{
return
{
title
:
'听说你的能力不错,我们battle一下'
,
path
:
'/pages/game/battle/index'
,
pageParams
:
{
battleId
:
dataSource
.
detail
.
battleId
}
}
}
return
{
title
:
'邀请你来一起PKmath,快乐提升哦'
,
path
:
'pages/main/main'
,
imageUrl
:
'https://cdn.jkwljy.com/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336'
,
}
},
[
dataSource
.
detail
])
useShare
(
shareParams
)
return
(
<
BattleComplete
pkResult=
{
dataSource
.
detail
}
></
BattleComplete
>
)
}
export
default
BattleIndex
src/pages/game/play/components/battle-complete.module.scss
View file @
c6b40ab0
...
...
@@ -219,6 +219,7 @@
font-weight
:
500
;
color
:
#FFFFFF
;
line-height
:
50px
;
background-color
:
transparent
;
}
.back_main
{
...
...
src/pages/game/play/components/battle-complete.tsx
View file @
c6b40ab0
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
,
Button
}
from
'@tarojs/components'
import
assetsGame
from
'@/assets/oss/assets-game'
import
assetsPrepare
from
'@/assets/oss/assets-prepare'
import
classNames
from
'classnames'
import
{
useMemo
}
from
'react'
import
{
reLaunch
}
from
'@tarojs/taro'
import
{
useStore
State
,
useStore
Actions
}
from
'@/store/hooks'
import
{
useStoreActions
}
from
'@/store/hooks'
import
{
getUserRank
}
from
'@/utils'
import
{
getUserLevelIcon
,
getUserLevelName
,
getUserLevelSubName
}
from
'@/constants'
import
{
PkResult
}
from
'@/api'
import
styles
from
'./battle-complete.module.scss'
const
BattleComplete
=
()
=>
{
const
pkResult
=
useStoreState
(
states
=>
states
.
gameModel
.
pkResult
)
type
BattleCompleteProps
=
{
pkResult
:
PkResult
|
null
}
const
BattleComplete
=
({
pkResult
}:
BattleCompleteProps
)
=>
{
const
updateState
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
updateState
)
const
upSelf
=
()
=>
{
...
...
@@ -75,7 +79,7 @@ const BattleComplete = () => {
<
View
className=
{
styles
.
gap_2
}
></
View
>
<
View
className=
{
styles
.
footer
}
>
<
View
className=
{
styles
.
share
}
>
分享结果
</
View
>
<
Button
className=
{
styles
.
share
}
openType=
"share"
>
分享结果
</
Button
>
<
View
className=
{
styles
.
back_main
}
onClick=
{
upSelf
}
>
提升自己
</
View
>
</
View
>
<
View
className=
{
styles
.
gap_3
}
></
View
>
...
...
src/pages/game/play/index.config.ts
View file @
c6b40ab0
export
default
definePageConfig
({
navigationBarTitleText
:
'pk-math'
,
navigationStyle
:
'custom'
,
enableShareAppMessage
:
true
,
// renderer: 'skyline',
usingComponents
:
{
'count-up-time'
:
'../../../native-components/count-up/index'
,
...
...
src/pages/game/play/index.tsx
View file @
c6b40ab0
import
{
ScrollView
,
Image
}
from
'@tarojs/components'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
preloadImage
}
from
'@/utils/preload-image'
import
{
useEffect
,
useMemo
}
from
'react'
import
{
useEffect
,
use
Callback
,
use
Memo
}
from
'react'
import
{
useDidShow
,
enableAlertBeforeUnload
,
disableAlertBeforeUnload
,
useRouter
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-complete'
import
{
EyeProtectionView
}
from
'@/components'
import
{
useShare
}
from
'@/hooks'
import
ModalContinue
from
'./components/modal-continue'
import
PageHead
from
'./components/page-head'
...
...
@@ -42,6 +43,7 @@ const GamePlay = () => {
},
[
questionList
,
currentQuestionIndex
])
const
clearUserAnswer
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
clearUserAnswer
)
const
handleGoNext
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
handleGoNext
)
const
pkResult
=
useStoreState
(
states
=>
states
.
gameModel
.
pkResult
)
const
router
=
useRouter
()
...
...
@@ -49,6 +51,26 @@ const GamePlay = () => {
return
router
.
params
.
isBattle
===
'true'
},
[
router
])
const
shareParams
=
useCallback
(()
=>
{
if
(
pkResult
)
{
return
{
title
:
'听说你的能力不错,我们battle一下'
,
path
:
'/pages/game/battle/index'
,
pageParams
:
{
battleId
:
pkResult
.
battleId
}
}
}
return
{
title
:
'邀请你来一起PKmath,快乐提升哦'
,
path
:
'pages/main/main'
,
imageUrl
:
'https://cdn.jkwljy.com/pk-math/4LHyu63hfeteRxAKNb2cj2uCrahf/420x336'
,
}
},
[
pkResult
])
useShare
(
shareParams
)
useEffect
(()
=>
{
enableAlertBeforeUnload
({
message
:
'还没有答完哦,确定要离开吗?'
,
...
...
@@ -97,7 +119,7 @@ const GamePlay = () => {
)
}
</
EyeProtectionView
>
<
ModalContinue
/>
<
BattleComplete
/>
<
BattleComplete
pkResult=
{
pkResult
}
/>
</>
)
}
...
...
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