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
db3668b5
Commit
db3668b5
authored
Mar 28, 2023
by
666
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update 1
parent
446f3c2e
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
502 additions
and
272 deletions
+502
-272
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-1
index.module.scss
src/components/Modal/index.module.scss
+29
-0
index.tsx
src/components/Modal/index.tsx
+35
-0
index.module.scss
src/components/Tabs/index.module.scss
+41
-0
index.tsx
src/components/Tabs/index.tsx
+99
-0
useModal.ts
src/hooks/useModal.ts
+27
-0
index.tsx
src/pages/level-prepare/components/level-info/index.tsx
+0
-38
start-challenge-button.tsx
...-prepare/components/level-info/start-challenge-button.tsx
+0
-59
time-display.module.scss
...-prepare/components/ranking-list/time-display.module.scss
+0
-0
time-display.tsx
...es/level-prepare/components/ranking-list/time-display.tsx
+0
-20
user-info.module.scss
...vel-prepare/components/ranking-list/user-info.module.scss
+0
-19
index.tsx
src/pages/level-prepare/index.tsx
+0
-24
glory-badge.tsx
src/pages/prepare/components/overview/glory-badge.tsx
+15
-0
index.module.scss
src/pages/prepare/components/overview/index.module.scss
+19
-32
index.tsx
src/pages/prepare/components/overview/index.tsx
+44
-0
launch-quest.tsx
src/pages/prepare/components/overview/launch-quest.tsx
+30
-0
top-left-info.tsx
src/pages/prepare/components/overview/top-left-info.tsx
+2
-3
index.module.scss
src/pages/prepare/components/rank-list/index.module.scss
+41
-5
index.tsx
src/pages/prepare/components/rank-list/index.tsx
+22
-22
timing.tsx
src/pages/prepare/components/rank-list/timing.tsx
+17
-0
user-info.tsx
src/pages/prepare/components/rank-list/user-info.tsx
+2
-3
index.module.scss
src/pages/prepare/index.module.scss
+0
-0
index.tsx
src/pages/prepare/index.tsx
+37
-0
types.ts
src/pages/prepare/types.ts
+8
-9
utils.ts
src/pages/prepare/utils.ts
+1
-2
prepare.ts
src/store/modules/prepare.ts
+30
-33
store-model.ts
src/store/store-model.ts
+2
-2
No files found.
scripts/app.config.ts.tpl
View file @
db3668b5
...
...
@@ -6,10 +6,10 @@
export default {
pages: [
'pages/prepare/index',
'pages/main/main',
'pages/group/index',
'pages/game/play/index',
'pages/level-prepare/index',
],
subPackages: {
{
packages
}
},
resizable: true,
...
...
src/components/Modal/index.module.scss
0 → 100644
View file @
db3668b5
.wrapper
{
position
:
fixed
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
background-color
:
rgba
(
0
,
0
,
0
,
0
.5
);
opacity
:
0
;
transition
:
opacity
0
.3s
ease-in-out
;
z-index
:
100
;
pointer-events
:
none
;
}
.visible
{
opacity
:
1
;
z-index
:
999
;
pointer-events
:
auto
;
}
.inner
{
background-color
:
#ffffff
;
padding
:
16px
;
border-radius
:
4px
;
box-shadow
:
0
4px
16px
rgba
(
0
,
0
,
0
,
0
.1
);
}
\ No newline at end of file
src/components/Modal/index.tsx
0 → 100644
View file @
db3668b5
/** simple modal component */
import
{
View
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
styles
from
'./index.module.scss'
interface
ModalProps
{
isVisible
:
boolean
;
wrapClassName
?:
string
;
children
:
React
.
ReactNode
;
maskClosable
?:
boolean
;
onClose
:
()
=>
void
;
}
const
Modal
:
React
.
FC
<
ModalProps
>
=
({
isVisible
,
onClose
,
children
,
wrapClassName
,
maskClosable
=
true
})
=>
{
const
wrapClass
=
classNames
(
styles
.
wrapper
,
wrapClassName
,
isVisible
?
styles
.
visible
:
''
)
return
(
<
View
className=
{
wrapClass
}
onClick=
{
()
=>
maskClosable
&&
onClose
()
}
>
<
View
className=
{
classNames
(
styles
.
inner
)
}
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
{
children
}
</
View
>
</
View
>
)
}
export
default
Modal
src/components/Tabs/index.module.scss
0 → 100644
View file @
db3668b5
.tabs
{
display
:
flex
;
width
:
100%
;
flex-direction
:
column
;
}
.tabBar
{
display
:
flex
;
border-bottom
:
1px
solid
#ccc
;
}
.tab
{
padding
:
12px
16px
;
color
:
#888
;
border-bottom
:
2px
solid
transparent
;
transition
:
border-color
0
.3s
ease-in-out
,
color
0
.3s
ease-in-out
;
&
.active
{
color
:
#333
;
border-color
:
#333
;
}
&
.disabled
{
opacity
:
0
.5
;
}
}
.tabPanes
{
display
:
flex
;
flex-direction
:
column
;
padding
:
12px
16px
;
margin-top
:
16px
;
}
.tabPane
{
display
:
none
;
&
.active
{
display
:
block
;
}
}
src/components/Tabs/index.tsx
0 → 100644
View file @
db3668b5
import
{
useState
,
useEffect
,
useCallback
,
CSSProperties
,
ReactNode
}
from
'react'
import
{
View
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
styles
from
'./index.module.scss'
export
interface
TabItem
{
label
:
string
|
ReactNode
;
children
:
ReactNode
;
disabled
?:
boolean
;
hidden
?:
boolean
;
keepAlive
?:
boolean
;
}
interface
TabsProps
{
items
:
TabItem
[];
initialIndex
?:
number
;
tabBarStyle
?:
CSSProperties
;
tabBarGutter
?:
number
;
onChange
?:
(
index
:
number
)
=>
void
;
}
const
Tabs
:
React
.
FC
<
TabsProps
>
=
({
items
,
initialIndex
=
0
,
tabBarStyle
=
{},
tabBarGutter
=
16
,
onChange
,
})
=>
{
const
[
activeIndex
,
setActiveIndex
]
=
useState
(
initialIndex
)
useEffect
(()
=>
{
if
(
items
[
activeIndex
].
hidden
)
{
const
newIndex
=
items
.
findIndex
((
tab
,
index
)
=>
!
tab
.
hidden
&&
index
!==
activeIndex
)
setActiveIndex
(
newIndex
)
}
},
[
items
,
activeIndex
])
const
handleClick
=
useCallback
((
index
:
number
)
=>
{
if
(
!
items
[
index
].
disabled
&&
index
!==
activeIndex
)
{
setActiveIndex
(
index
)
onChange
?.(
index
)
}
},
[
items
,
activeIndex
,
onChange
])
const
renderTabs
=
()
=>
{
return
items
.
map
((
tab
,
index
)
=>
{
if
(
tab
.
hidden
)
return
null
const
cls
=
classNames
(
styles
.
tab
,
{
[
styles
.
active
]:
index
===
activeIndex
,
[
styles
.
disabled
]:
tab
.
disabled
,
})
return
(
<
View
key=
{
index
}
className=
{
cls
}
style=
{
{
marginRight
:
index
<
items
.
length
-
1
?
tabBarGutter
:
undefined
}
}
onClick=
{
()
=>
handleClick
(
index
)
}
>
{
tab
.
label
}
</
View
>
)
})
}
const
renderTabPanes
=
()
=>
{
return
items
.
map
((
tab
,
index
)
=>
{
if
(
tab
.
hidden
&&
!
tab
.
keepAlive
)
return
null
const
isActive
=
activeIndex
===
index
const
isHidden
=
tab
.
hidden
||
!
isActive
const
cls
=
classNames
(
styles
.
tabPane
,
{
[
styles
.
active
]:
isActive
,
})
return
(
<
View
key=
{
index
}
className=
{
cls
}
hidden=
{
isHidden
}
>
{
tab
.
children
}
</
View
>
)
})
}
return
(
<
View
className=
{
styles
.
tabs
}
>
<
View
className=
{
styles
.
tabBar
}
style=
{
tabBarStyle
}
>
{
renderTabs
()
}
</
View
>
<
View
className=
{
styles
.
tabPanes
}
>
{
renderTabPanes
()
}
</
View
>
</
View
>
)
}
export
default
Tabs
src/hooks/useModal.ts
0 → 100644
View file @
db3668b5
import
{
useState
}
from
'react'
interface
UseModalResult
{
isVisible
:
boolean
;
showModal
:
()
=>
void
;
closeModal
:
()
=>
void
;
}
const
useModal
=
():
UseModalResult
=>
{
const
[
isVisible
,
setIsVisible
]
=
useState
(
false
)
const
showModal
=
()
=>
{
setIsVisible
(
true
)
}
const
closeModal
=
()
=>
{
setIsVisible
(
false
)
}
return
{
isVisible
,
showModal
,
closeModal
,
}
}
export
default
useModal
src/pages/level-prepare/components/level-info/index.tsx
deleted
100644 → 0
View file @
446f3c2e
import
React
from
'react'
;
import
{
View
,
Text
}
from
'@tarojs/components'
;
import
{
useStoreState
}
from
'@/store/hooks'
;
import
TopLeftInfo
from
'./top-left-info'
;
// import StartChallengeButton from './start-challenge-button';
import
{
formatTime
}
from
'../../utils'
import
styles
from
'./index.module.scss'
;
const
LevelInfo
:
React
.
FC
=
()
=>
{
const
levelInfo
=
useStoreState
((
state
)
=>
state
.
levelPrepareModel
.
levelInfo
)
const
onStartChallenge
=
()
=>
{
console
.
log
(
'onStartChallenge'
)
}
return
(
<
View
className=
{
styles
.
wrapper
}
>
<
Text
className=
{
styles
.
title
}
>
{
levelInfo
.
title
}
</
Text
>
<
Text
className=
{
styles
.
totalQuestions
}
>
共
{
levelInfo
.
totalQuestions
}
题
</
Text
>
<
View
className=
{
styles
.
requirement
}
>
<
Text
className=
{
styles
.
passingRequirement
}
>
通过要求:
{
levelInfo
.
passingRequirement
}
</
Text
>
<
Text
className=
{
styles
.
duration
}
>
时间:
{
formatTime
(
levelInfo
.
duration
)
}
</
Text
>
</
View
>
{
/* <StartChallengeButton /> */
}
<
TopLeftInfo
/>
</
View
>
)
}
export
default
LevelInfo
;
src/pages/level-prepare/components/level-info/start-challenge-button.tsx
deleted
100644 → 0
View file @
446f3c2e
// import React, { useState, useEffect, useRef } from 'react'
// import { View, Text, Button } from '@tarojs/components'
// import Taro from '@tarojs/taro';
// import styles from './index.module.scss';
// const StartChallengeButton: React.FC = () => {
// const [showModal, setShowModal] = useState(false)
// const hasFreePass = false
// const modalRef = useRef(null)
// const [opacity, setOpacity] = useState(0)
// const [scale, setScale] = useState(0.8)
// const handleChallengeClick = () => {
// if (!hasFreePass) {
// setShowModal(true);
// } else {
// // Start the challenge
// }
// }
// useEffect(() => {
// if (showModal) {
// const animation = Taro.createAnimation({
// duration: 200,
// timingFunction: 'ease-out',
// });
// animation.opacity(1).scale(1).step();
// if (modalRef.current) {
// modalRef.current.animate(animation.export());
// }
// }
// }, [showModal]);
// return (
// <View className={styles.startChallenge}>
// <Button onClick={handleChallengeClick}>开始闯关</Button>
// <Text className={styles.tip}>
// {hasFreePass ? '首次免答题卡' : '-1答题卡'}
// </Text>
// {showModal && (
// <>
// <View className={styles.modalOverlay}>
// </View>
// <View ref={modalRef} className={styles.modal}>
// <Text>你的答题卡已经用完了</Text>
// <Button onClick={handleChallengeClick}>建设学习部落得更多答题卡</Button>
// <Button onClick={handleChallengeClick}>购买</Button>
// <Button onClick={() => setShowModal(false)}>关闭</Button>
// </View>
// </>
// )}
// </View>
// )
// }
// export default StartChallengeButton
\ No newline at end of file
src/pages/level-prepare/components/ranking-list/time-display.module.scss
deleted
100644 → 0
View file @
446f3c2e
src/pages/level-prepare/components/ranking-list/time-display.tsx
deleted
100644 → 0
View file @
446f3c2e
import
React
from
'react'
import
{
Text
}
from
'@tarojs/components'
;
import
{
TimeDisplayProps
}
from
'../../types'
const
formatTime
=
(
time
:
number
):
string
=>
{
const
minutes
=
Math
.
floor
(
time
/
60
);
const
seconds
=
time
%
60
;
return
`
${
minutes
}
分
${
seconds
}
秒`
;
}
const
TimeDisplay
:
React
.
FC
<
TimeDisplayProps
>
=
({
time
=
0
})
=>
{
return
(
<
Text
className=
'time-display'
>
{
formatTime
(
time
)
}
</
Text
>
)
}
export
default
TimeDisplay
\ No newline at end of file
src/pages/level-prepare/components/ranking-list/user-info.module.scss
deleted
100644 → 0
View file @
446f3c2e
.userInfo
{
display
:
flex
;
column-gap
:
16px
;
}
.avatar
{
width
:
60px
;
height
:
60px
;
border-radius
:
50%
;
background-color
:
pink
;
}
.userDetails
{
display
:
flex
;
flex-direction
:
column
;
row-gap
:
16px
;
line-height
:
1
;
}
\ No newline at end of file
src/pages/level-prepare/index.tsx
deleted
100644 → 0
View file @
446f3c2e
import
{
View
}
from
'@tarojs/components'
;
import
{
useEffect
}
from
'react'
;
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
;
import
LevelInfo
from
'./components/level-info/index'
;
import
Ranking
from
'./components/ranking-list/index'
const
StagePrepare
:
React
.
FC
=
()
=>
{
const
{
currentUser
,
list
}
=
useStoreState
((
state
)
=>
state
.
levelPrepareModel
)
const
refresh
=
useStoreActions
((
actions
)
=>
actions
.
levelPrepareModel
.
refresh
)
useEffect
(()
=>
{
refresh
()
},
[
currentUser
])
return
(
<
View
>
<
LevelInfo
/>
<
Ranking
users=
{
list
}
currentUser=
{
currentUser
}
/>
</
View
>
);
};
export
default
StagePrepare
;
\ No newline at end of file
src/pages/prepare/components/overview/glory-badge.tsx
0 → 100644
View file @
db3668b5
import
{
View
,
Text
}
from
'@tarojs/components'
import
styles
from
'./index.module.scss'
const
GloryBadge
:
React
.
FC
=
()
=>
{
return
(
<
View
className=
{
styles
.
badge
}
>
<
Text
>
TOP30%
</
Text
>
<
Text
>
升档成功
</
Text
>
<
Text
>
S级实力
</
Text
>
</
View
>
)
}
export
default
GloryBadge
src/pages/
level-prepare/components/level-info
/index.module.scss
→
src/pages/
prepare/components/overview
/index.module.scss
View file @
db3668b5
...
...
@@ -25,7 +25,7 @@
}
.
startChallenge
{
.
launchQuest
{
position
:
relative
;
margin-top
:
48px
;
z-index
:
1
;
...
...
@@ -45,37 +45,6 @@
padding
:
8px
12px
;
}
.modal
{
position
:
fixed
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
background-color
:
white
;
padding
:
20px
;
border-radius
:
10px
;
z-index
:
101
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
box-shadow
:
0
2px
8px
rgba
(
0
,
0
,
0
,
0
.1
);
width
:
80%
;
max-width
:
400px
;
}
.modalOverlay
{
position
:
fixed
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
background-color
:
rgba
(
0
,
0
,
0
,
0
.5
);
z-index
:
100
;
}
.modal
button
{
margin-top
:
10px
;
}
.topLeftInfo
{
position
:
absolute
;
top
:
0
;
...
...
@@ -92,3 +61,20 @@
padding
:
4px
8px
;
border
:
1px
solid
#ccc
;
}
.badge
{
display
:
flex
;
align-items
:
center
;
margin-top
:
24px
;
gap
:
24px
;
padding
:
24px
;
border
:
1px
solid
#000
;
Text
{
border-radius
:
8px
;
padding
:
12px
;
display
:
flex
;
align-items
:
center
;
border
:
1px
dashed
red
;
}
}
\ No newline at end of file
src/pages/prepare/components/overview/index.tsx
0 → 100644
View file @
db3668b5
import
{
View
,
Text
}
from
'@tarojs/components'
// import { useStoreState } from '@/store/hooks';
import
TopLeftInfo
from
'./top-left-info'
import
LaunchQuest
from
'./launch-quest'
import
GloryBadge
from
'./glory-badge'
import
{
formatTime
}
from
'../../utils'
import
styles
from
'./index.module.scss'
const
Overview
:
React
.
FC
=
()
=>
{
// const levelInfo = useStoreState((state) => state.prepareModel.levelInfo)
const
levelInfo
=
{
title
:
'表内除法'
,
totalQuestions
:
10
,
duration
:
80
,
}
return
(
<>
<
TopLeftInfo
/>
<
View
className=
{
styles
.
wrapper
}
>
<
Text
className=
{
styles
.
title
}
>
{
levelInfo
.
title
}
</
Text
>
<
Text
className=
{
styles
.
totalQuestions
}
>
共
{
levelInfo
.
totalQuestions
}
题
</
Text
>
<
View
className=
{
styles
.
requirement
}
>
<
Text
className=
{
styles
.
passingRequirement
}
>
通过要求:全 √
</
Text
>
<
Text
className=
{
styles
.
duration
}
>
时间:
{
formatTime
(
levelInfo
.
duration
)
}
</
Text
>
</
View
>
<
LaunchQuest
/>
<
GloryBadge
/>
</
View
>
</>
)
}
export
default
Overview
src/pages/prepare/components/overview/launch-quest.tsx
0 → 100644
View file @
db3668b5
import
React
from
'react'
import
{
View
,
Text
,
Button
}
from
'@tarojs/components'
import
Modal
from
'@/components/Modal'
import
useModal
from
'@/hooks/useModal'
import
styles
from
'./index.module.scss'
const
LaunchQuest
:
React
.
FC
=
()
=>
{
const
{
isVisible
,
showModal
,
closeModal
}
=
useModal
()
return
(
<>
<
View
className=
{
styles
.
launchQuest
}
>
<
Button
onClick=
{
showModal
}
>
开始闯关
</
Button
>
<
Text
className=
{
styles
.
tip
}
>
首次免答题卡
{
/* {hasFreePass ? '首次免答题卡' : '-1答题卡'} */
}
</
Text
>
</
View
>
<
Modal
isVisible=
{
isVisible
}
onClose=
{
closeModal
}
>
<
View
>
<
Text
>
你的答题卡已经用完了
</
Text
>
<
Button
onClick=
{
closeModal
}
>
建设学习部落得更多答题卡
</
Button
>
<
Button
onClick=
{
closeModal
}
>
购买
</
Button
>
</
View
>
</
Modal
>
</>
)
}
export
default
LaunchQuest
src/pages/
level-prepare/components/level-info
/top-left-info.tsx
→
src/pages/
prepare/components/overview
/top-left-info.tsx
View file @
db3668b5
import
{
View
,
Text
}
from
'@tarojs/components'
import
styles
from
'./index.module.scss'
;
import
styles
from
'./index.module.scss'
const
TopLeftInfo
=
()
=>
{
return
(
...
...
@@ -10,4 +10,4 @@ const TopLeftInfo = () => {
)
}
export
default
TopLeftInfo
\ No newline at end of file
export
default
TopLeftInfo
src/pages/
level-prepare/components/ranking
-list/index.module.scss
→
src/pages/
prepare/components/rank
-list/index.module.scss
View file @
db3668b5
.wrap
{
.wrap
per
{
display
:
flex
;
flex-direction
:
column
;
}
.title
{
text-align
:
center
;
margin-bottom
:
24px
;
.head
{
display
:
flex
;
justify-content
:
flex-end
;
Text
{
width
:
160px
;
text-align
:
center
;
}
}
.timing
{
min-width
:
320px
;
display
:
flex
;
align-items
:
center
;
Text
{
flex
:
1
;
text-align
:
center
;
}
}
.list
{
...
...
@@ -19,7 +35,7 @@
}
.item
{
padding
:
0
24px
;
padding
:
16px
0
;
display
:
flex
;
justify-content
:
space-between
;
}
...
...
@@ -31,4 +47,23 @@
.noTopThree
{
border
:
1px
solid
red
;
margin
:
24px
0
;
}
.userInfo
{
display
:
flex
;
column-gap
:
16px
;
}
.avatar
{
width
:
60px
;
height
:
60px
;
border-radius
:
50%
;
background-color
:
pink
;
}
.userDetails
{
display
:
flex
;
flex-direction
:
column
;
row-gap
:
16px
;
line-height
:
1
;
}
\ No newline at end of file
src/pages/
level-prepare/components/ranking
-list/index.tsx
→
src/pages/
prepare/components/rank
-list/index.tsx
View file @
db3668b5
import
{
View
,
Button
,
Text
}
from
'@tarojs/components'
import
React
,
{
useState
}
from
'react'
import
{
View
,
Button
,
Text
,
}
from
'@tarojs/components'
import
{
useState
}
from
'react'
import
classNames
from
'classnames'
import
{
useStoreState
}
from
'@/store/hooks'
;
import
{
useStoreState
}
from
'@/store/hooks'
import
{
User
}
from
'../../types'
import
UserInfo
from
'./user-info'
import
Tim
eDisplay
from
'./time-display
'
import
Tim
ing
from
'./timing
'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
interface
RankingListProps
{
users
:
User
[];
currentUser
?:
User
;
}
const
Rank
ing
List
:
React
.
FC
<
RankingListProps
>
=
({
users
,
currentUser
})
=>
{
const
RankList
:
React
.
FC
<
RankingListProps
>
=
({
users
,
currentUser
})
=>
{
const
[
showAll
,
setShowAll
]
=
useState
(
false
)
const
{
currentUserInTopThree
,
topThreeUsers
}
=
useStoreState
((
state
)
=>
state
.
levelP
repareModel
)
const
{
currentUserInTopThree
,
topThreeUsers
}
=
useStoreState
((
state
)
=>
state
.
p
repareModel
)
const
renderItem
=
(
user
:
User
)
=>
{
const
isCurrentUser
=
currentUser
&&
currentUser
.
nickname
===
user
.
nickname
return
(
<
View
key=
{
user
.
nickname
}
className=
{
classNames
(
styles
.
item
,
isCurrentUser
&&
styles
.
highlight
)
}
>
<
UserInfo
{
...
user
}
/>
<
Tim
eDisplay
time=
{
user
.
time
}
/>
<
Tim
ing
time=
{
user
.
time
}
/>
</
View
>
)
}
...
...
@@ -30,29 +30,29 @@ const RankingList: React.FC<RankingListProps> = ({ users, currentUser }) => {
const
displayUsers
=
showAll
?
users
:
topThreeUsers
return
(
<
View
className=
{
styles
.
wrap
}
>
<
Text
className=
{
styles
.
title
}
>
本关英雄榜
</
Text
>
<
View
className=
{
styles
.
wrapper
}
>
<
View
className=
{
styles
.
header
}
>
<
Text
>
首次
</
Text
><
Text
>
最佳
</
Text
>
</
View
>
{
!
currentUserInTopThree
&&
currentUser
&&
(
<
View
key=
{
currentUser
.
nickname
}
className=
{
classNames
(
styles
.
item
,
styles
.
noTopThree
)
}
>
<
UserInfo
{
...
currentUser
}
/>
<
Timing
time=
{
currentUser
.
time
}
/>
</
View
>
)
}
<
View
className=
{
styles
.
list
}
>
{
displayUsers
.
map
(
renderItem
)
}
</
View
>
{
!
showAll
&&
(
<
Button
className=
{
styles
.
loadMore
}
onClick=
{
()
=>
setShowAll
(
!
showAll
)
}
>
展示
更多
查看
更多
</
Button
>
)
}
{
!
currentUserInTopThree
&&
currentUser
&&
(
<
View
key=
{
currentUser
.
nickname
}
className=
{
classNames
(
styles
.
item
,
styles
.
noTopThree
)
}
>
<
UserInfo
{
...
currentUser
}
/>
<
TimeDisplay
time=
{
currentUser
.
time
}
/>
</
View
>
)
}
</
View
>
)
}
export
default
RankingList
export
default
RankList
src/pages/prepare/components/rank-list/timing.tsx
0 → 100644
View file @
db3668b5
import
React
from
'react'
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
TimingProps
}
from
'../../types'
// import { formatTime } from '../../utils'
import
styles
from
'./index.module.scss'
const
Timing
:
React
.
FC
<
TimingProps
>
=
({
time
=
0
})
=>
{
return
(
<
View
className=
{
styles
.
timing
}
>
<
Text
>
34.23秒
</
Text
>
<
Text
>
21.23秒
</
Text
>
</
View
>
)
}
export
default
Timing
src/pages/
level-prepare/components/ranking
-list/user-info.tsx
→
src/pages/
prepare/components/rank
-list/user-info.tsx
View file @
db3668b5
import
React
from
'react'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
UserInfoProps
}
from
'../../types'
import
styles
from
'./
user-info
.module.scss'
import
styles
from
'./
index
.module.scss'
console
.
log
(
'11'
)
const
UserInfo
:
React
.
FC
<
UserInfoProps
>
=
({
avatar
,
nickname
,
schoolName
})
=>
{
return
(
<
View
className=
{
styles
.
userInfo
}
>
...
...
src/pages/
level-
prepare/index.module.scss
→
src/pages/prepare/index.module.scss
View file @
db3668b5
File moved
src/pages/prepare/index.tsx
0 → 100644
View file @
db3668b5
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
useEffect
}
from
'react'
import
Tabs
,
{
type
TabItem
}
from
'@/components/Tabs'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
Overview
from
'./components/overview/index'
import
RankList
from
'./components/rank-list/index'
const
Prepare
:
React
.
FC
=
()
=>
{
const
{
currentUser
,
list
}
=
useStoreState
((
state
)
=>
state
.
prepareModel
)
const
refresh
=
useStoreActions
((
actions
)
=>
actions
.
prepareModel
.
refresh
)
useEffect
(()
=>
{
refresh
()
},
[
currentUser
])
const
tabs
:
TabItem
[]
=
[
{
label
:
'成都排行榜'
,
children
:
<
RankList
users=
{
list
}
currentUser=
{
currentUser
}
/>
},
{
label
:
'学习部落排行榜'
,
children
:
(
<
View
>
<
RankList
users=
{
list
}
currentUser=
{
currentUser
}
/>
<
Text
>
立即创建
</
Text
>
</
View
>
)
},
]
return
(
<
View
>
<
Overview
/>
<
Tabs
items=
{
tabs
}
/>
</
View
>
)
}
export
default
Prepare
src/pages/
level-
prepare/types.ts
→
src/pages/prepare/types.ts
View file @
db3668b5
...
...
@@ -4,15 +4,15 @@ export type UserInfoProps = {
schoolName
?:
string
;
}
export
type
Tim
eDisplay
Props
=
{
export
type
Tim
ing
Props
=
{
time
?:
number
;
}
export
type
User
=
UserInfoProps
&
Tim
eDisplay
Props
export
type
User
=
UserInfoProps
&
Tim
ing
Props
export
interface
LevelInfo
{
title
:
string
;
totalQuestions
:
number
;
passingRequirement
:
string
;
duration
:
number
;
}
\ No newline at end of file
// export interface PanelView {
// title: string;
// totalQuestions: number;
// passingRequirement: string;
// duration: number;
// }
src/pages/
level-
prepare/utils.ts
→
src/pages/prepare/utils.ts
View file @
db3668b5
...
...
@@ -2,4 +2,4 @@ export const formatTime = (time: number) => {
const
minutes
=
Math
.
floor
(
time
/
60
)
const
seconds
=
time
%
60
return
`
${
minutes
}
分
${
seconds
}
秒`
}
\ No newline at end of file
}
src/store/modules/
level-
prepare.ts
→
src/store/modules/prepare.ts
View file @
db3668b5
import
{
computed
,
Action
,
Computed
,
action
}
from
'easy-peasy'
import
WithPaging
from
'@/utils/with-paging'
import
{
PagingFn
}
from
'@/types'
import
{
User
,
LevelInfo
}
from
'@/pages/level-
prepare/types'
import
{
User
}
from
'@/pages/
prepare/types'
interface
Model
{
levelInfo
:
LevelInfo
;
setTitle
:
Action
<
LevelPrepareModel
,
string
>
;
setTotalQuestions
:
Action
<
LevelPrepareModel
,
number
>
;
setPassingRequirement
:
Action
<
LevelPrepareModel
,
string
>
;
setDuration
:
Action
<
LevelPrepareModel
,
number
>
;
// setTitle: Action<PrepareModel, string>;
// setTotalQuestions: Action<PrepareModel, number>;
// setPassingRequirement: Action<PrepareModel, string>;
// setDuration: Action<PrepareModel, number>;
currentUser
:
User
;
setCurrentUser
:
Action
<
Level
PrepareModel
,
User
>
;
topThreeUsers
:
Computed
<
Level
PrepareModel
,
User
[]
>
;
currentUserInTopThree
:
Computed
<
Level
PrepareModel
,
boolean
>
;
setCurrentUser
:
Action
<
PrepareModel
,
User
>
;
topThreeUsers
:
Computed
<
PrepareModel
,
User
[]
>
;
currentUserInTopThree
:
Computed
<
PrepareModel
,
boolean
>
;
}
const
api
:
PagingFn
<
any
,
{}
>
=
async
()
=>
{
...
...
@@ -45,7 +43,7 @@ const api: PagingFn<any, {}> = async () => {
schoolName
:
'index4'
,
avatar
:
'index4'
,
time
:
110
,
},
,
},
{
nickname
:
'index5'
,
schoolName
:
'index5'
,
...
...
@@ -65,7 +63,7 @@ const api: PagingFn<any, {}> = async () => {
}
}
const
levelP
repareModel
=
WithPaging
<
User
,
Model
,
{}
>
(
api
)({
const
p
repareModel
=
WithPaging
<
User
,
Model
,
{}
>
(
api
)({
currentUser
:
{
nickname
:
'index4'
,
schoolName
:
'index4'
,
...
...
@@ -73,12 +71,12 @@ const levelPrepareModel = WithPaging<User, Model, {}>(api)({
time
:
30
,
},
levelInfo
:
{
title
:
'表内除法'
,
totalQuestions
:
10
,
passingRequirement
:
'全√'
,
duration
:
80
,
},
// panelCard
: {
//
title: '表内除法',
//
totalQuestions: 10,
//
passingRequirement: '全√',
//
duration: 80,
//
},
topThreeUsers
:
computed
((
state
)
=>
state
.
list
.
slice
(
0
,
3
)),
...
...
@@ -92,24 +90,23 @@ const levelPrepareModel = WithPaging<User, Model, {}>(api)({
state
.
currentUser
=
user
}),
setTitle
:
action
((
state
,
payload
)
=>
{
state
.
levelInfo
.
title
=
payload
;
}),
//
setTitle: action((state, payload) => {
//
state.levelInfo.title = payload;
//
}),
setTotalQuestions
:
action
((
state
,
payload
)
=>
{
state
.
levelInfo
.
totalQuestions
=
payload
;
}),
//
setTotalQuestions: action((state, payload) => {
//
state.levelInfo.totalQuestions = payload;
//
}),
setPassingRequirement
:
action
((
state
,
payload
)
=>
{
state
.
levelInfo
.
passingRequirement
=
payload
;
}),
//
setPassingRequirement: action((state, payload) => {
//
state.levelInfo.passingRequirement = payload;
//
}),
setDuration
:
action
((
state
,
payload
)
=>
{
state
.
levelInfo
.
duration
=
payload
;
}),
//
setDuration: action((state, payload) => {
//
state.levelInfo.duration = payload;
//
}),
})
export
default
levelPrepareModel
export
type
LevelPrepareModel
=
typeof
levelPrepareModel
;
export
default
prepareModel
export
type
PrepareModel
=
typeof
prepareModel
;
src/store/store-model.ts
View file @
db3668b5
import
cartModel
from
'./modules/cart'
import
counterModel
from
'./modules/counter'
import
levelPrepareModel
from
'./modules/level-
prepare'
import
prepareModel
from
'./modules/
prepare'
const
appStoreModel
=
{
cartModel
,
counterModel
,
levelP
repareModel
,
p
repareModel
,
}
export
default
appStoreModel
...
...
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