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
fa581ec1
Commit
fa581ec1
authored
Apr 05, 2023
by
m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
4fa13543
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
77 deletions
+93
-77
game.ts
src/api/game.ts
+6
-3
complete-achieve.tsx
src/pages/game/complete/components/complete-achieve.tsx
+1
-1
index.tsx
src/pages/group/index.tsx
+7
-3
main.tsx
src/pages/main/main.tsx
+6
-2
main-header.tsx
src/pages/prepare/components/main-header.tsx
+26
-24
constant.ts
src/pages/prepare/constant.ts
+0
-14
index.tsx
src/pages/prepare/index.tsx
+47
-30
No files found.
src/api/game.ts
View file @
fa581ec1
...
...
@@ -60,6 +60,11 @@ export type StageRank = {
userId
:
number
;
}
export
type
NextStep
=
{
nextStep
:
string
;
nextStepReward
:
number
;
nextStepTime
:
number
}
export
interface
StageDetail
extends
Stage
{
aTime
:
number
;
bTime
:
number
;
...
...
@@ -70,9 +75,7 @@ export interface StageDetail extends Stage {
ranks
?:
StageRank
[];
groupRanks
?:
StageRank
[];
questionNum
:
number
;
nextStep
:
string
;
nextStepReward
:
number
;
nextStepTime
:
number
nextSteps
?:
NextStep
[];
}
/** 获取关卡详情 */
...
...
src/pages/game/complete/components/complete-achieve.tsx
View file @
fa581ec1
...
...
@@ -80,7 +80,7 @@ const GameCompleteAchieve = () => {
hoverClass=
{
styles
.
is_active
}
onClick=
{
handleContinue
}
>
继续
继续
22
</
View
>
</
View
>
)
...
...
src/pages/group/index.tsx
View file @
fa581ec1
...
...
@@ -5,7 +5,7 @@ import { useMemo, useState } from 'react'
import
Modal
from
'@/components/Modal'
import
Button
from
'@/components/Button'
import
{
useBoolean
,
useRequest
}
from
'@/hooks'
import
{
createTribe
}
from
'@/api/group'
import
{
createTribe
,
queryTribePoint
}
from
'@/api/group'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
type
{
TabbarRef
}
from
'@/custom-tab-bar/index'
...
...
@@ -28,7 +28,7 @@ const Group = () => {
const
[
refresher
,
{
toggle
}]
=
useBoolean
(
false
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
{
tribeInfo
}
=
useStoreState
(
state
=>
state
.
groupModel
)
const
tribeInfo
=
useStoreState
(
state
=>
state
.
groupModel
.
tribeInfo
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
tabBarHeight
=
useMemo
(()
=>
{
...
...
@@ -56,6 +56,10 @@ const Group = () => {
}
})
const { run: refresh } = useRequest(queryTribePoint, {
immediate: false
})
const onConfirm = () => {
if (!groupNo) {
showModal({ title: '部落名不能为空' })
...
...
@@ -67,7 +71,7 @@ const Group = () => {
const onRefresher = async () => {
try {
toggle()
await
fetchTribeInfo(
)
await
Promise.all([fetchTribeInfo(), refresh()]
)
} finally {
setTimeout(() => toggle(), 600)
}
...
...
src/pages/main/main.tsx
View file @
fa581ec1
...
...
@@ -57,7 +57,7 @@ const MainPage = () => {
})
fetchTribeInfo
().
then
((
res
)
=>
{
if
(
!
res
.
id
||
!
res
)
{
if
(
!
res
||
!
res
.
id
)
{
joinTribeByCode
()
}
})
...
...
@@ -68,11 +68,15 @@ const MainPage = () => {
immediate
:
false
,
onSuccess
:
()
=>
{
showToast
({
title
:
'加入成功'
})
fetchTribeInfo
()
},
onError
:
()
=>
{
fetchTribeInfo
()
}
})
// 邀请弹框
const
joinTribeByCode
=
useCallback
(
async
()
=>
{
const
joinTribeByCode
=
useCallback
(()
=>
{
if
(
groupId
&&
inviteId
&&
+
inviteId
!==
userInfo
.
userId
)
{
// 邀请人是不是自己
showModal
({
title
:
'加入部落'
,
...
...
src/pages/prepare/components/main-header.tsx
View file @
fa581ec1
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
{
use
Callback
,
use
Memo
}
from
'react'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
StageType
,
StageLevel
,
StageDetail
}
from
'@/api'
import
{
StageType
,
StageLevel
,
type
StageDetail
,
type
NextStep
}
from
'@/api'
import
assets
from
'@/assets/oss/assets-prepare'
import
styles
from
'./main-header.module.scss'
...
...
@@ -59,25 +59,27 @@ const MainHeader = () => {
}
},
[
stageDetail
.
level
])
// const levelRequirement = useMemo(() => {
// switch (stageDetail.level) {
// case StageLevel.S:
// return {
// v: 10,
// u: assets['level-big-s.png'].u
// }
// case StageLevel.A:
// return {
// v: 5,
// u: assets['level-big-a.png'].u
// }
// case StageLevel.B:
// return {
// v: 1,
// u: assets['level-big-b.png'].u
// }
// }
// }, [stageDetail.level, stageDetail])
const
renderNextStep
=
useCallback
((
item
:
NextStep
)
=>
{
switch
(
item
.
nextStep
)
{
case
'S'
:
return
assets
[
'level-big-s.png'
].
u
case
'A'
:
return
assets
[
'level-big-a.png'
].
u
case
'B'
:
return
assets
[
'level-big-b.png'
].
u
case
'10'
:
return
assets
[
'top-big-10.png'
].
u
case
'20'
:
return
assets
[
'top-big-20.png'
].
u
case
'30'
:
return
assets
[
'top-big-30.png'
].
u
case
'upGear'
:
return
assets
[
'upgear-big.png'
].
u
default
:
return
''
}
},
[])
const
RequireItem
=
({
u
,
v
,
t
=
0
}:
{
u
:
string
,
v
:
number
,
t
:
number
})
=>
(
<
View
key=
{
u
}
className=
{
styles
.
detail
}
>
...
...
@@ -109,9 +111,9 @@ const MainHeader = () => {
const
renderAgain
=
()
=>
(
<
View
className=
{
styles
.
details
}
>
{
/* <RequireItem u={levelRequirement.u} v={levelRequirement.v} t={stageDetail.nextStepTime} /> */
}
{
/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */
}
{
/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */
}
{
stageDetail
.
nextSteps
?.
map
((
item
)
=>
(
<
RequireItem
u=
{
renderNextStep
(
item
)
}
v=
{
item
.
nextStepReward
}
t=
{
item
.
nextStepTime
}
/>
))
}
</
View
>
)
...
...
src/pages/prepare/constant.ts
deleted
100644 → 0
View file @
4fa13543
import
assets
from
'@/assets/oss/assets-prepare'
export
const
requirement
=
{
newcomer
:
{
title
:
'通关要求'
,
clock
:
assets
[
'clock.png'
].
u
,
text
:
'用时 ≤49s'
},
strive
:
{
title
:
'继续努力,赢更多成就'
,
clock
:
assets
[
'clock-up.png'
].
u
,
text
:
'用时需提高0.3s'
,
},
}
src/pages/prepare/index.tsx
View file @
fa581ec1
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
use
Effect
,
use
Memo
,
useState
}
from
'react'
import
{
useRouter
,
useDidShow
,
getMenuButtonBoundingClientRect
,
useShareAppMessage
,
navigateTo
}
from
'@tarojs/taro'
import
{
useMemo
,
useState
}
from
'react'
import
{
useRouter
,
redirectTo
,
useDidShow
,
getMenuButtonBoundingClientRect
,
useShareAppMessage
,
navigateTo
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
Button
from
'@/components/Button'
...
...
@@ -9,6 +9,7 @@ import ShareView from '@/pages/group/components/share-view'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useBoolean
,
useRequest
}
from
'@/hooks'
import
{
pointToCard
}
from
'@/api/account'
import
{
StageStatus
}
from
'@/api/game'
import
assets
from
'@/assets/oss/assets-prepare'
import
assetsGroup
from
'@/assets/oss/assets-group'
...
...
@@ -30,9 +31,13 @@ const Prepare = () => {
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
isSubmit
=
useStoreState
(
state
=>
state
.
gameModel
.
isSubmit
)
const
tribeInfo
=
useStoreState
(
state
=>
state
.
groupModel
.
tribeInfo
)
const
questionList
=
useStoreState
(
state
=>
state
.
gameModel
.
questionList
)
const
stageList
=
useStoreState
(
state
=>
state
.
mainModel
.
stageList
)
const
getStageDetail
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getStageDetail
)
const
getQuestionList
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getQuestionList
)
const
updateState
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
updateState
)
const
tabs
:
TabItem
[]
=
[
{
...
...
@@ -52,6 +57,7 @@ const Prepare = () => {
const
{
run
:
exchange
,
loading
}
=
useRequest
(
pointToCard
,
{
immediate
:
false
,
onSuccess
:
()
=>
{
setFalse
()
getQuestionList
(
+
router
.
params
.
id
||
1
).
then
(()
=>
{
navigateTo
({
url
:
`/pages/game/play/index?id=
${
router
.
params
.
id
}
`
...
...
@@ -75,16 +81,16 @@ const Prepare = () => {
return
{
title
:
'来看看这个有趣的页面!'
,
path
:
`pages/main/main?groupId=
${
tribeInfo
?.
id
}
&
inviteId
=
$
{
userInfo
.
userId
}
`,
imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
}
})
const handleClick = () => {
if (cardNum < 1) {
if (cardNum < 1
&& !stageDetail?.firstTime
) {
setTrue()
} else {
getQuestionList(+router.params.id || 1).then(() => {
console.log('questionList', questionList)
navigateTo({
url: `
/
pages
/
game
/
play
/
index
?
id
=
$
{
router
.
params
.
id
}
`
})
...
...
@@ -92,9 +98,42 @@ const Prepare = () => {
}
}
// const renderFisrtButton = () => (
const onNext = () => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const nextId = stageList[index + 1].id
if (nextId) {
navigateTo({ url: `
/
pages
/
prepare
/
index
?
id
=
$
{
nextId
}
` })
updateState({ isSubmit: false })
}
}
const renderFisrtActions = () => (
<Button size="large" onClick={handleClick} className={styles.challenge} image={styles.image} hoverImage={styles.hover_image}>
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card} style={{ position: 'absolute', right: 50 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
)
// )
const renderAgainActions = () => (
<View className={styles.challenge}>
<Button onClick={onNext} size="large" image={styles.short_image} hoverImage={styles.short_hover_image}>
下一关
</Button>
<Button size="large" onClick={handleClick} image={styles.long_image} hoverImage={styles.long_hover_image}>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
<Text className={styles.challenge_text}>再次提升</Text>
</Button>
</View>
)
return (
<View className={styles.wrapper}>
...
...
@@ -105,36 +144,14 @@ const Prepare = () => {
</View>
<View className={styles.footer_bar}>
{currentTab === 1 && <ShareView>
{currentTab === 1 &&
tribeInfo?.id &&
<ShareView>
<View className={styles.tribe_share}>
<Image style={{ width: 32, height: 32 }} src={assetsGroup['invite-small.png'].u} />
<Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text>
</View>
</ShareView>}
<Button size="large" onClick={handleClick} className={styles.challenge} image={styles.image} hoverImage={styles.hover_image}>
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card} style={{ position: 'absolute', right: 50 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
{/* <View className={styles.challenge}>
<Button size="large" image={styles.short_image} hoverImage={styles.short_hover_image}>
下一关
</Button>
<Button size="large" onClick={handleClick} image={styles.long_image} hoverImage={styles.long_hover_image}>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
<Text className={styles.challenge_text}>再次提升</Text>
</Button>
</View> */}
{isSubmit ? renderFisrtActions() : renderAgainActions()}
</View>
<AnswerCardModal isVisible={isVisible} onClose={setFalse}>
...
...
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