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
eb2af188
Commit
eb2af188
authored
Apr 06, 2023
by
m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
104617a2
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
417 additions
and
96 deletions
+417
-96
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-1
index.module.scss
src/custom-tab-bar/index.module.scss
+17
-0
index.tsx
src/custom-tab-bar/index.tsx
+3
-1
data.json
src/pages/group/data.json
+172
-0
index.module.scss
src/pages/group/index.module.scss
+7
-0
index.tsx
src/pages/group/index.tsx
+16
-5
index.ts
src/pages/group/model/index.ts
+2
-0
main-header.module.scss
src/pages/prepare/components/main-header.module.scss
+141
-55
main-header.tsx
src/pages/prepare/components/main-header.tsx
+2
-1
tabs.module.scss
src/pages/prepare/components/tabs.module.scss
+9
-0
tabs.tsx
src/pages/prepare/components/tabs.tsx
+2
-0
index.module.scss
src/pages/prepare/index.module.scss
+1
-1
index.tsx
src/pages/prepare/index.tsx
+44
-32
No files found.
scripts/app.config.ts.tpl
View file @
eb2af188
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
export default {
export default {
pages: [
pages: [
'pages/main/main',
'pages/main/main',
'pages/group/index',
'pages/prepare/index',
'pages/prepare/index',
'pages/group/index',
'pages/market/index',
'pages/market/index',
'pages/game/play/index',
'pages/game/play/index',
'pages/game/complete/index',
'pages/game/complete/index',
...
...
src/custom-tab-bar/index.module.scss
View file @
eb2af188
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
&
.right
{
&
.right
{
left
:
-48px
;
left
:
-48px
;
}
}
}
}
...
@@ -54,3 +55,19 @@
...
@@ -54,3 +55,19 @@
position
:
relative
;
position
:
relative
;
z-index
:
2
;
z-index
:
2
;
}
}
.right
.icon
{
&
.hasPoint
{
position
:
relative
;
&
:
:
after
{
position
:
absolute
;
content
:
""
;
top
:
6
PX
;
right
:
0
;
width
:
12
PX
;
height
:
12
PX
;
border-radius
:
24
PX
;
background-color
:
#ff4d4f
;
}
}
}
src/custom-tab-bar/index.tsx
View file @
eb2af188
import
{
useState
,
useImperativeHandle
,
forwardRef
,
useCallback
,
type
ForwardRefRenderFunction
}
from
'react'
import
{
useState
,
useImperativeHandle
,
forwardRef
,
useCallback
,
type
ForwardRefRenderFunction
}
from
'react'
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
switchTab
}
from
'@tarojs/taro'
import
{
switchTab
}
from
'@tarojs/taro'
import
{
useStoreState
}
from
'@/store/hooks'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
...
@@ -11,6 +12,7 @@ type TabbarRef = {
...
@@ -11,6 +12,7 @@ type TabbarRef = {
const
Tabbar
:
ForwardRefRenderFunction
<
TabbarRef
,
{}
>
=
(
_
,
ref
)
=>
{
const
Tabbar
:
ForwardRefRenderFunction
<
TabbarRef
,
{}
>
=
(
_
,
ref
)
=>
{
const
[
selected
,
setSelected
]
=
useState
(
0
)
const
[
selected
,
setSelected
]
=
useState
(
0
)
const
hasPoint
=
useStoreState
(
state
=>
state
.
groupModel
.
hasPoint
)
const
_switchTab
=
useCallback
((
index
:
number
,
url
:
string
)
=>
{
const
_switchTab
=
useCallback
((
index
:
number
,
url
:
string
)
=>
{
setSelected
(
index
)
setSelected
(
index
)
...
@@ -37,7 +39,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
...
@@ -37,7 +39,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
{
selected
===
1
&&
(
{
selected
===
1
&&
(
<
Image
src=
"/assets/tabbar/group-bg.png"
className=
{
classNames
(
styles
.
bg
,
styles
.
right
)
}
></
Image
>
<
Image
src=
"/assets/tabbar/group-bg.png"
className=
{
classNames
(
styles
.
bg
,
styles
.
right
)
}
></
Image
>
)
}
)
}
<
Image
src=
"/assets/tabbar/group-on.png"
className=
{
styles
.
icon
}
/>
<
Image
src=
"/assets/tabbar/group-on.png"
className=
{
classNames
(
styles
.
icon
,
{
[
styles
.
hasPoint
]:
hasPoint
})
}
/>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/group/data.json
0 → 100644
View file @
eb2af188
[
"快乐学堂"
,
"小天才俱乐部"
,
"阳光小学霸"
,
"知识小勇士"
,
"童话学习园"
,
"学习小精灵"
,
"天才小书虫"
,
"梦想学习园"
,
"童心书屋"
,
"快乐成长树"
,
"学习的小蜜蜂"
,
"小小探险家"
,
"彩虹学习园"
,
"知识小花园"
,
"童趣学习宝"
,
"笑脸学习站"
,
"阳光小学堂"
,
"学习宝贝岛"
,
"智慧小博士"
,
"成长快车道"
,
"快乐学习团"
,
"童年学习梦"
,
"稚趣学园"
,
"学习小蜗牛"
,
"智力小超人"
,
"小小地球村"
,
"学习乐园"
,
"梦想小舞台"
,
"小小数学家"
,
"知识小火车"
,
"爱心学习站"
,
"快乐学习家"
,
"学习小翅膀"
,
"童年智慧树"
,
"快乐小天使"
,
"学习的小精灵"
,
"阳光学习园"
,
"快乐读书房"
,
"童梦学习园"
,
"智慧的种子"
,
"爱学习的小熊"
,
"学习小动力"
,
"彩虹小学者"
,
"幸福学习屋"
,
"快乐小导航"
,
"学习的小苹果"
,
"知识小宇宙"
,
"笑声学习岛"
,
"学习小奇迹"
,
"学习小小鸟"
,
"勇敢学习者"
,
"童话小学者"
,
"智慧小花朵"
,
"快乐成长班"
,
"快乐学习派"
,
"快乐学习小组"
,
"成长的脚印"
,
"智慧之光"
,
"勤学好问团"
,
"阳光小伙伴"
,
"小小智者"
,
"知识宝石"
,
"快乐成长园"
,
"智慧小鸟"
,
"梦想之船"
,
"学习天地"
,
"小状元家"
,
"知识小宝藏"
,
"快乐蜜蜂"
,
"智慧小农场"
,
"学海探险队"
,
"快乐小学堂"
,
"奇思妙想团"
,
"成长快乐屋"
,
"智慧星空"
,
"宝贝学习站"
,
"知识探险家"
,
"勇敢小学霸"
,
"快乐学习岛"
,
"成长奇迹"
,
"智慧之星"
,
"快乐小蜜蜂"
,
"宝贝学习园"
,
"学习小导航"
,
"智慧之树"
,
"学习小战士"
,
"知识小天地"
,
"快乐探索家"
,
"智慧之路"
,
"学习快车"
,
"成长幸福园"
,
"快乐小学者"
,
"知识小宇宙"
,
"学习之旅"
,
"发现之星"
,
"梦想成真"
,
"学习小天地"
,
"知识小导航"
,
"学习之星"
,
"勤奋小蜗牛"
,
"智慧小花园"
,
"成长之梦"
,
"快乐学习舞台"
,
"知识小岛"
,
"学习之路"
,
"勇敢的小学者"
,
"快乐小王子"
,
"知识宝库"
,
"智慧之源"
,
"成长快乐站"
,
"快乐学习宝"
,
"知识小精灵"
,
"学习小天使"
,
"智慧小神童"
,
"成长快乐家"
,
"快乐学习园"
,
"知识小飞侠"
,
"学习小助手"
,
"智慧小导航"
,
"成长快乐岛"
,
"快乐学习派"
,
"学习小能手"
,
"智慧小熊"
,
"成长的天空"
,
"快乐小书虫"
,
"知识小助手"
,
"学习小飞侠"
,
"智慧小花朵"
,
"成长的舞台"
,
"快乐学习星"
,
"知识小导航"
,
"学习小蜜蜂"
,
"智慧小太阳"
,
"成长的翅膀"
,
"快乐小学习"
,
"知识小天才"
,
"学习小超人"
,
"智慧小奇迹"
,
"成长的日记"
,
"知识小状元"
,
"学习小梦想"
,
"智慧小神童"
,
"成长的足迹"
,
"快乐小状元"
,
"知识小舞台"
,
"学习小宝贝"
,
"智慧小蜜蜂"
,
"成长的歌声"
,
"快乐学习园"
,
"知识小能手"
,
"学习小快乐"
,
"智慧小天空"
,
"成长的种子"
,
"快乐小智者"
,
"知识小战士"
,
"学习小发现"
,
"智慧小冒险家"
,
"成长的航道"
,
"快乐小发现"
,
"知识小探险家"
,
"学习小太阳"
,
"智慧小星星"
,
"成长的瞬间"
,
"快乐小小熊"
,
"知识小英雄"
,
"学习小快车"
,
"智慧小脚印"
,
"成长的花园"
,
"快乐小奇迹"
]
\ No newline at end of file
src/pages/group/index.module.scss
View file @
eb2af188
...
@@ -23,6 +23,13 @@
...
@@ -23,6 +23,13 @@
height
:
30
PX
;
height
:
30
PX
;
}
}
&
_description
{
font-size
:
13
PX
;
color
:
#9999
;
position
:
relative
;
left
:
20
PX
;
}
&
_footer
{
&
_footer
{
margin-top
:
64px
;
margin-top
:
64px
;
display
:
flex
;
display
:
flex
;
...
...
src/pages/group/index.tsx
View file @
eb2af188
import
{
View
,
Image
,
Input
,
ScrollView
}
from
'@tarojs/components'
import
{
View
,
Image
,
Input
,
ScrollView
,
Text
}
from
'@tarojs/components'
import
{
useDidShow
,
getCurrentInstance
,
getTabBar
,
getMenuButtonBoundingClientRect
,
showModal
,
useShareAppMessage
}
from
'@tarojs/taro'
import
{
useDidShow
,
getCurrentInstance
,
getTabBar
,
getMenuButtonBoundingClientRect
,
showModal
,
useShareAppMessage
}
from
'@tarojs/taro'
import
{
useMemo
,
useState
}
from
'react'
import
{
useMemo
,
useState
}
from
'react'
...
@@ -20,11 +20,14 @@ import ShareButton from './components/share-button'
...
@@ -20,11 +20,14 @@ import ShareButton from './components/share-button'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
import
memberStyles
from
'./components/members.module.scss'
import
memberStyles
from
'./components/members.module.scss'
import
groupNames
from
'./data.json'
const
Group
=
()
=>
{
const
Group
=
()
=>
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
groupNames
.
length
)
const
page
=
useMemo
(()
=>
getCurrentInstance
().
page
,
[])
const
page
=
useMemo
(()
=>
getCurrentInstance
().
page
,
[])
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
groupNo
,
setGroupNo
]
=
useState
<
string
>
(
''
)
const
[
groupNo
,
setGroupNo
]
=
useState
<
string
>
(
groupNames
[
randomIndex
]
)
const
[
refresher
,
{
toggle
}]
=
useBoolean
(
false
)
const
[
refresher
,
{
toggle
}]
=
useBoolean
(
false
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
...
@@ -87,7 +90,7 @@ const Group = () => {
...
@@ -87,7 +90,7 @@ const Group = () => {
<MainHeader groupNo={tribeInfo?.groupNo!} />
<MainHeader groupNo={tribeInfo?.groupNo!} />
<View>
<View>
{
!tribeInfo?.id ? <Creator onClick={setTrue} /> : <Members
/>}
{
tribeInfo?.id ? <Members /> : <Creator onClick={setTrue}
/>}
</View>
</View>
</ScrollView>
</ScrollView>
...
@@ -98,9 +101,17 @@ const Group = () => {
...
@@ -98,9 +101,17 @@ const Group = () => {
<Modal isVisible={isVisible} tilte="学习部落名" onClose={setFalse}>
<Modal isVisible={isVisible} tilte="学习部落名" onClose={setFalse}>
<View className={styles.modal}>
<View className={styles.modal}>
<View className={styles.modal_body}>
<View className={styles.modal_body}>
<Input className={styles.modal_input} value={groupNo} placeholder="请输入" placeholderStyle="color: #9999;" onInput={(e) => setGroupNo(e.detail.value)} />
<Input className={styles.modal_input} disabled value={groupNo} />
<Image className={styles.modal_refresh} mode="widthFix" src={assets['refresh.png'].u} />
<Image
className={styles.modal_refresh}
mode="widthFix"
src={assets['refresh.png'].u}
onClick={() => setGroupNo(groupNames[randomIndex])}
/>
</View>
</View>
<Text className={styles.modal_description}>
* 可点击右侧按钮随机生成名字
</Text>
<View className={styles.modal_footer}>
<View className={styles.modal_footer}>
<Button onClick={setFalse} type="default">取消</Button>
<Button onClick={setFalse} type="default">取消</Button>
<Button onClick={onConfirm} loading={spining}>确定</Button>
<Button onClick={onConfirm} loading={spining}>确定</Button>
...
...
src/pages/group/model/index.ts
View file @
eb2af188
...
@@ -9,6 +9,7 @@ export interface GroupModel {
...
@@ -9,6 +9,7 @@ export interface GroupModel {
points
:
PointType
[],
points
:
PointType
[],
tribeInfo
:
TribeInfo
|
null
;
tribeInfo
:
TribeInfo
|
null
;
groupMembers
:
Computed
<
GroupModel
,
MemberItem
[]
>
;
groupMembers
:
Computed
<
GroupModel
,
MemberItem
[]
>
;
hasPoint
:
Computed
<
GroupModel
,
boolean
>
;
isEmpty
:
Computed
<
GroupModel
,
boolean
>
;
isEmpty
:
Computed
<
GroupModel
,
boolean
>
;
updateState
:
Action
<
GroupModel
,
Partial
<
State
<
GroupModel
>>>
;
updateState
:
Action
<
GroupModel
,
Partial
<
State
<
GroupModel
>>>
;
fetchTribeInfo
:
Thunk
<
GroupModel
,
{
memberId
?:
number
}
|
undefined
,
void
,
AppStoreModel
,
Promise
<
TribeInfo
>>
;
fetchTribeInfo
:
Thunk
<
GroupModel
,
{
memberId
?:
number
}
|
undefined
,
void
,
AppStoreModel
,
Promise
<
TribeInfo
>>
;
...
@@ -20,6 +21,7 @@ const groupModel: GroupModel = {
...
@@ -20,6 +21,7 @@ const groupModel: GroupModel = {
points
:
[],
points
:
[],
groupMembers
:
computed
((
state
)
=>
state
.
tribeInfo
?.
groupMembers
||
[]),
groupMembers
:
computed
((
state
)
=>
state
.
tribeInfo
?.
groupMembers
||
[]),
isEmpty
:
computed
((
state
)
=>
state
.
groupMembers
.
length
<
1
),
isEmpty
:
computed
((
state
)
=>
state
.
groupMembers
.
length
<
1
),
hasPoint
:
computed
((
state
)
=>
state
.
points
.
some
(
item
=>
item
.
point
)),
updateState
:
action
((
state
,
payload
)
=>
{
updateState
:
action
((
state
,
payload
)
=>
{
for
(
const
key
in
payload
)
{
for
(
const
key
in
payload
)
{
...
...
src/pages/prepare/components/main-header.module.scss
View file @
eb2af188
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
font-size
:
52px
;
font-size
:
52px
;
font-weight
:
600
;
font-weight
:
600
;
color
:
#FFFFFF
;
color
:
#FFFFFF
;
animation
:
scale3d
1s
ease-in-out
forwards
;
}
}
.labels
{
.labels
{
...
@@ -20,15 +21,40 @@
...
@@ -20,15 +21,40 @@
gap
:
20px
;
gap
:
20px
;
margin-bottom
:
48px
;
margin-bottom
:
48px
;
@keyframes
fadeInScale
{
0
%
{
opacity
:
0
;
transform
:
scale
(
0
.3
)
translateX
(
-50px
);
}
50
%
{
transform
:
scale
(
1
.1
)
translateX
(
0
);
}
100
%
{
opacity
:
1
;
transform
:
scale
(
1
)
translateX
(
0
);
}
}
.label
{
.label
{
@include
flexLayout
(
row
,
center
);
font-size
:
12
PX
;
font-size
:
12
PX
;
font-weight
:
400
;
font-weight
:
400
;
color
:
#FFFFFF
;
color
:
#FFFFFF
;
padding
:
8
PX
;
padding
:
8
PX
;
background
:
rgba
(
226
,
233
,
255
,
0
.2
);
background
:
rgba
(
226
,
233
,
255
,
0
.2
);
border-radius
:
6
PX
;
border-radius
:
6
PX
;
@include
flexLayout
(
row
,
center
);
gap
:
3
PX
;
gap
:
3
PX
;
animation
:
fadeInScale
1s
cubic-bezier
(
0
.215
,
0
.610
,
0
.355
,
1
.000
)
backwards
;
&
:nth-child
(
1
)
{
animation-delay
:
0
.3s
;
}
&
:nth-child
(
2
)
{
animation-delay
:
0
.6s
;
}
&
:nth-child
(
3
)
{
animation-delay
:
0
.9s
;
}
.icon
{
.icon
{
width
:
16
PX
;
width
:
16
PX
;
...
@@ -37,6 +63,66 @@
...
@@ -37,6 +63,66 @@
}
}
}
}
.replay
{
background
:
rgba
(
226
,
233
,
255
,
0
.2
);
border-radius
:
30px
;
border
:
1px
solid
#FFFFFF
;
@include
flexLayout
(
row
,
center
);
font-size
:
15
PX
;
font-weight
:
500
;
color
:
#FFFFFF
;
padding
:
32px
0
;
position
:
relative
;
margin-bottom
:
48px
;
&
:
:
before
{
content
:
''
;
position
:
absolute
;
width
:
1px
;
transform
:
scaleY
(
0
.5
);
background-color
:
rgba
(
255
,
255
,
255
,
0
.4
);
right
:
50%
;
top
:
0
;
bottom
:
0
;
}
.performance
{
width
:
50%
;
animation
:
fadeInLeft
1s
ease-in-out
forwards
;
.details
{
@include
flexLayout
(
row
,
center
,
center
);
gap
:
6
PX
;
margin-top
:
12
PX
;
.logo
{
width
:
24
PX
;
height
:
24
PX
;
}
.consume
{
font-size
:
20
PX
;
}
}
}
.achievement
{
width
:
50%
;
animation
:
fadeInRight
1s
ease-in-out
forwards
;
.details
{
margin-top
:
12
PX
;
@include
flexLayout
(
row
,
center
,
center
);
gap
:
20px
;
.logo
{
width
:
32
PX
;
height
:
32
PX
;
}
}
}
}
.requirement
{
.requirement
{
@include
flexLayout
(
column
);
@include
flexLayout
(
column
);
...
@@ -77,10 +163,23 @@
...
@@ -77,10 +163,23 @@
gap
:
12
PX
;
gap
:
12
PX
;
.detail
{
.detail
{
@include
flexLayout
(
row
,
center
,
space-between
);
animation
:
fadeInLeft
1s
ease-in-out
backwards
;
background
:
rgba
(
226
,
233
,
255
,
0
.3
);
background
:
rgba
(
226
,
233
,
255
,
0
.3
);
border-radius
:
12
PX
;
border-radius
:
12
PX
;
@include
flexLayout
(
row
,
center
,
space-between
);
color
:
#fff
;
color
:
#fff
;
&
:nth-child
(
1
)
{
animation-delay
:
0
.3s
;
}
&
:nth-child
(
2
)
{
animation-delay
:
0
.6s
;
}
&
:nth-child
(
3
)
{
animation-delay
:
0
.9s
;
}
.content
{
.content
{
@include
flexLayout
(
row
,
center
);
@include
flexLayout
(
row
,
center
);
...
@@ -123,62 +222,48 @@
...
@@ -123,62 +222,48 @@
}
}
}
}
}
}
}
.replay
{
@keyframes
fadeInRight
{
background
:
rgba
(
226
,
233
,
255
,
0
.2
);
0
%
{
border-radius
:
30px
;
opacity
:
0
;
border
:
1px
solid
#FFFFFF
;
transform
:
translateX
(
30px
);
@include
flexLayout
(
row
,
center
);
}
font-size
:
15
PX
;
100
%
{
font-weight
:
500
;
opacity
:
1
;
color
:
#FFFFFF
;
transform
:
translateX
(
0
);
padding
:
32px
0
;
}
position
:
relative
;
}
margin-bottom
:
48px
;
&
:
:
before
{
content
:
''
;
position
:
absolute
;
width
:
1px
;
transform
:
scaleY
(
0
.5
);
background-color
:
rgba
(
255
,
255
,
255
,
0
.4
);
right
:
50%
;
top
:
0
;
bottom
:
0
;
}
.performance
{
width
:
50%
;
.details
{
@include
flexLayout
(
row
,
center
,
center
);
gap
:
6
PX
;
margin-top
:
12
PX
;
.logo
{
@keyframes
fadeInLeft
{
width
:
24
PX
;
0
%
{
height
:
24
PX
;
opacity
:
0
;
}
transform
:
translateX
(
-30px
);
}
.consume
{
100
%
{
font-size
:
20
PX
;
opacity
:
1
;
}
transform
:
translateX
(
0
);
}
}
}
}
.achievement
{
@keyframes
fadeInDown
{
width
:
50%
;
0
%
{
opacity
:
0
;
.details
{
transform
:
translateY
(
-30px
);
margin-top
:
12
PX
;
}
@include
flexLayout
(
row
,
center
,
center
);
100
%
{
gap
:
20px
;
opacity
:
1
;
transform
:
translateY
(
0
);
}
}
.logo
{
@keyframes
scale3d
{
width
:
32
PX
;
0
%
{
height
:
32
PX
;
opacity
:
0
;
}
transform
:
scale3d
(
1
.5
,
1
.5
,
1
);
}
}
}
100
%
{
opacity
:
1
;
transform
:
scale3d
(
1
,
1
,
1
)
}
}
}
}
\ No newline at end of file
src/pages/prepare/components/main-header.tsx
View file @
eb2af188
...
@@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react'
...
@@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
StageType
,
StageLevel
,
type
StageDetail
,
type
NextStep
}
from
'@/api'
import
{
StageType
,
StageLevel
,
type
StageDetail
,
type
NextStep
}
from
'@/api'
import
assets
from
'@/assets/oss/assets-prepare'
import
assets
from
'@/assets/oss/assets-prepare'
import
styles
from
'./main-header.module.scss'
import
styles
from
'./main-header.module.scss'
const
MainHeader
=
()
=>
{
const
MainHeader
=
()
=>
{
...
@@ -112,7 +113,7 @@ const MainHeader = () => {
...
@@ -112,7 +113,7 @@ const MainHeader = () => {
const
renderAgain
=
()
=>
(
const
renderAgain
=
()
=>
(
<
View
className=
{
styles
.
details
}
>
<
View
className=
{
styles
.
details
}
>
{
stageDetail
.
nextSteps
?.
map
((
item
)
=>
(
{
stageDetail
.
nextSteps
?.
map
((
item
)
=>
(
<
RequireItem
u=
{
renderNextStep
(
item
)
}
v=
{
item
.
nextStepReward
}
t=
{
item
.
nextStepTime
}
/>
<
RequireItem
key=
{
item
.
nextStep
}
u=
{
renderNextStep
(
item
)
}
v=
{
item
.
nextStepReward
}
t=
{
item
.
nextStepTime
}
/>
))
}
))
}
</
View
>
</
View
>
)
)
...
...
src/pages/prepare/components/tabs.module.scss
View file @
eb2af188
...
@@ -7,6 +7,15 @@
...
@@ -7,6 +7,15 @@
overflow
:
visible
;
overflow
:
visible
;
}
}
.mask
{
position
:
absolute
;
background-color
:
#fff
;
top
:
48
PX
;
bottom
:
0
;
left
:
0
;
right
:
0
;
}
.tabBar
{
.tabBar
{
display
:
flex
;
display
:
flex
;
height
:
88
PX
;
height
:
88
PX
;
...
...
src/pages/prepare/components/tabs.tsx
View file @
eb2af188
...
@@ -67,6 +67,7 @@ const Tabs = ({
...
@@ -67,6 +67,7 @@ const Tabs = ({
})
})
const
tabPaneStyle
=
{
const
tabPaneStyle
=
{
height
:
isActive
?
'auto'
:
0
,
transform
:
`translateX(
${(
index
-
activeIndex
)
*
100
}
%)`
,
transform
:
`translateX(
${(
index
-
activeIndex
)
*
100
}
%)`
,
transition
:
'transform 0.3s ease-in-out'
,
transition
:
'transform 0.3s ease-in-out'
,
}
}
...
@@ -81,6 +82,7 @@ const Tabs = ({
...
@@ -81,6 +82,7 @@ const Tabs = ({
return
(
return
(
<
View
className=
{
styles
.
tabs
}
>
<
View
className=
{
styles
.
tabs
}
>
<
View
className=
{
styles
.
mask
}
/>
<
View
className=
{
classNames
(
styles
.
tabBar
,
activeIndex
===
0
?
styles
.
active_1
:
styles
.
active_2
)
}
>
<
View
className=
{
classNames
(
styles
.
tabBar
,
activeIndex
===
0
?
styles
.
active_1
:
styles
.
active_2
)
}
>
{
renderTabs
()
}
{
renderTabs
()
}
</
View
>
</
View
>
...
...
src/pages/prepare/index.module.scss
View file @
eb2af188
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
.empty
{
.empty
{
color
:
#9999
;
color
:
#9999
;
font-size
:
14
PX
;
font-size
:
14
PX
;
margin
-top
:
12
PX
;
margin
:
24
PX
0
;
text-align
:
center
;
text-align
:
center
;
}
}
...
...
src/pages/prepare/index.tsx
View file @
eb2af188
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
useMemo
,
useState
,
useEffect
,
useCallback
}
from
'react'
import
{
useMemo
,
useState
,
useEffect
,
useCallback
}
from
'react'
import
{
useRouter
,
redirectTo
,
useDidShow
,
getMenuButtonBoundingClientRect
,
useShareAppMessage
,
navigateTo
}
from
'@tarojs/taro'
import
{
useRouter
,
redirectTo
,
useDidShow
,
getMenuButtonBoundingClientRect
,
useShareAppMessage
,
navigateTo
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
Button
from
'@/components/Button'
import
Button
from
'@/components/Button'
...
@@ -24,6 +24,7 @@ const Prepare = () => {
...
@@ -24,6 +24,7 @@ const Prepare = () => {
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
router
=
useRouter
<
{
id
:
string
}
>
()
const
router
=
useRouter
<
{
id
:
string
}
>
()
const
[
currentTab
,
setCurrentTab
]
=
useState
(
0
)
const
[
currentTab
,
setCurrentTab
]
=
useState
(
0
)
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
...
@@ -54,18 +55,6 @@ const Prepare = () => {
...
@@ -54,18 +55,6 @@ 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
}
`
})
})
}
})
const
innerStyle
=
useMemo
(()
=>
{
const
innerStyle
=
useMemo
(()
=>
{
const
h
=
nav
.
height
+
nav
.
top
+
5
const
h
=
nav
.
height
+
nav
.
top
+
5
return
{
return
{
...
@@ -73,15 +62,21 @@ const Prepare = () => {
...
@@ -73,15 +62,21 @@ const Prepare = () => {
}
}
},
[
nav
.
height
,
nav
.
top
])
},
[
nav
.
height
,
nav
.
top
])
useDidShow
(
async
()
=>
{
setLoading
(
true
)
await
getStageDetail
(
+
router
.
params
.
id
||
1
)
setLoading
(
false
)
})
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
cardNum
<
1
)
{
if
(
cardNum
<
1
)
{
getSetting
()
getSetting
()
}
}
},
[
cardNum
,
getSetting
])
},
[
cardNum
,
getSetting
])
use
DidShow
(()
=>
{
use
Effect
(()
=>
{
getStageDetail
(
+
router
.
params
.
id
||
1
)
!
loading
&&
hideLoading
(
)
})
}
,
[
loading
]
)
useShareAppMessage
(()
=>
{
useShareAppMessage
(()
=>
{
return
{
return
{
...
@@ -91,6 +86,18 @@ const Prepare = () => {
...
@@ -91,6 +86,18 @@ const Prepare = () => {
}
}
})
})
const { run: exchange, loading: spinning } = useRequest(pointToCard, {
immediate: false,
onSuccess: () => {
setFalse()
getQuestionList(+router.params.id || 1).then(() => {
navigateTo({
url: `
/
pages
/
game
/
play
/
index
?
id
=
$
{
router
.
params
.
id
}
`
})
})
}
})
const handleClick = () => {
const handleClick = () => {
if (cardNum < 1 && !stageDetail?.firstTime) {
if (cardNum < 1 && !stageDetail?.firstTime) {
setTrue()
setTrue()
...
@@ -103,19 +110,6 @@ const Prepare = () => {
...
@@ -103,19 +110,6 @@ const Prepare = () => {
}
}
}
}
const isLast = useMemo(() => {
return stageList.length - 1 === stageList.findIndex(c => c.id === stageDetail?.id)
}, [stageList, stageDetail])
const onNext = useCallback(() => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const id = stageList[index + 1]?.id
if (id) {
redirectTo({ url: `
/
pages
/
prepare
/
index
?
id
=
$
{
id
}
` })
updateState({ isSubmit: false })
}
}, [stageList, stageDetail?.id, updateState])
const renderFisrtActions = () => (
const renderFisrtActions = () => (
<View className={styles.challenge}>
<View className={styles.challenge}>
<Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}>
<Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}>
...
@@ -131,6 +125,19 @@ const Prepare = () => {
...
@@ -131,6 +125,19 @@ const Prepare = () => {
</View>
</View>
)
)
const isLast = useMemo(() => {
return stageList.length - 1 === stageList.findIndex(c => c.id === stageDetail?.id)
}, [stageList, stageDetail])
const onNext = useCallback(() => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const id = stageList[index + 1]?.id
if (id) {
redirectTo({ url: `
/
pages
/
prepare
/
index
?
id
=
$
{
id
}
` })
updateState({ isSubmit: false })
}
}, [stageList, stageDetail?.id, updateState])
const hasNextBtn = useMemo(() => {
const hasNextBtn = useMemo(() => {
return stageDetail?.level && isSubmit && !isLast
return stageDetail?.level && isSubmit && !isLast
}, [stageDetail, isSubmit, isLast])
}, [stageDetail, isSubmit, isLast])
...
@@ -157,9 +164,14 @@ const Prepare = () => {
...
@@ -157,9 +164,14 @@ const Prepare = () => {
</View>
</View>
)
)
if (loading) {
return showLoading()
}
return (
return (
<View className={styles.wrapper}>
<View className={styles.wrapper}>
<TopBar />
<TopBar />
<View className={styles.inner} style={innerStyle}>
<View className={styles.inner} style={innerStyle}>
<MainHeader />
<MainHeader />
<Tabs initialIndex={currentTab} items={tabs} onChange={setCurrentTab} />
<Tabs initialIndex={currentTab} items={tabs} onChange={setCurrentTab} />
...
@@ -180,11 +192,11 @@ const Prepare = () => {
...
@@ -180,11 +192,11 @@ const Prepare = () => {
<View
<View
className={classNames(styles.buy_card, {
className={classNames(styles.buy_card, {
[styles.buy_card_disabled]: point < setting.pointToCard,
[styles.buy_card_disabled]: point < setting.pointToCard,
[styles.buy_card_loading]:
load
ing,
[styles.buy_card_loading]:
spinn
ing,
})}
})}
onClick={() => !
load
ing && point >= setting.pointToCard && exchange({ num: 1 })}
onClick={() => !
spinn
ing && point >= setting.pointToCard && exchange({ num: 1 })}
>
>
<Loading size="small" className={styles.buy_card_spin} spinning={
load
ing} />
<Loading size="small" className={styles.buy_card_spin} spinning={
spinn
ing} />
<View className={styles.inner}>
<View className={styles.inner}>
<Image className={styles.logo} src={point >= setting.pointToCard ? assets['diamond.png'].u : assets['diamond-un.png'].u} mode="widthFix" />
<Image className={styles.logo} src={point >= setting.pointToCard ? assets['diamond.png'].u : assets['diamond-un.png'].u} mode="widthFix" />
<Text>-{setting.pointToCard}</Text>
<Text>-{setting.pointToCard}</Text>
...
...
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