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
4c0fa8b5
Commit
4c0fa8b5
authored
Apr 27, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 性能优化
parent
82432df1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
320 additions
and
46 deletions
+320
-46
.env.development
.env.development
+3
-2
global.d.ts
global.d.ts
+4
-1
index.json
src/native-components/rank/index.json
+3
-0
index.module.scss
src/native-components/rank/index.module.scss
+144
-0
index.ts
src/native-components/rank/index.ts
+66
-0
index.wxml
src/native-components/rank/index.wxml
+73
-0
index.config.ts
src/pages/prepare/index.config.ts
+4
-1
index.tsx
src/pages/prepare/index.tsx
+4
-2
render.tsx
src/pages/prepare/render.tsx
+19
-40
No files found.
.env.development
View file @
4c0fa8b5
...
@@ -4,9 +4,10 @@
...
@@ -4,9 +4,10 @@
BUILD_MODE=development
BUILD_MODE=development
# 微信小程序appid
# 微信小程序appid
WEAPP_ID=wx693fe3460124d84b
WEAPP_ID=wx8f25def587982a19
# 服务器接口地址
# 服务器接口地址
SERVER_ENDPOINT=http
://172.10.62.80
SERVER_ENDPOINT=http
s://geek.jkwljy.com
# 腾讯地图接口 api key
# 腾讯地图接口 api key
TARO_TECENT_LBS_KEY=X3OBZ-OKM3D-I2A4L-P3LQY-7C7ZZ-3KBFG
TARO_TECENT_LBS_KEY=X3OBZ-OKM3D-I2A4L-P3LQY-7C7ZZ-3KBFG
...
...
global.d.ts
View file @
4c0fa8b5
...
@@ -26,7 +26,10 @@ declare namespace JSX{
...
@@ -26,7 +26,10 @@ declare namespace JSX{
'count-up-time'
:
CountUpTime
;
'count-up-time'
:
CountUpTime
;
'number-keyboard'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'number-keyboard'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
onType
?:
(
a
:
{
detail
:
string
})
=>
void
;
onType
?:
(
a
:
{
detail
:
string
})
=>
void
;
},
HTMLElement
>
},
HTMLElement
>
;
'game-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
},
HTMLElement
>
;
}
}
}
}
...
...
src/native-components/rank/index.json
0 → 100644
View file @
4c0fa8b5
{
"component"
:
true
}
src/native-components/rank/index.module.scss
0 → 100644
View file @
4c0fa8b5
@import
'@/styles/mixins.scss'
;
.thead
{
height
:
40
PX
;
background
:
#F7F9FC
;
display
:
flex
;
align-items
:
center
;
font-size
:
12
PX
;
padding
:
0
32px
;
color
:
rgba
(
70
,
81
,
100
,
0
.5
);
&
_index
{
width
:
80px
;
text-align
:
center
;
padding-left
:
3
PX
;
margin-right
:
23
PX
;
}
&
_username
{
flex
:
1
;
}
&
_result
{
display
:
flex
;
align-items
:
center
;
font-size
:
12
PX
;
font-weight
:
400
;
gap
:
6
PX
;
color
:
rgba
(
70
,
81
,
100
,
0
.7
);
&
_best
{
font-size
:
32px
;
font-weight
:
600
;
color
:
#FE9B45
;
}
}
}
.empty
{
color
:
#9999
;
font-size
:
14
PX
;
margin
:
24
PX
0
;
text-align
:
center
;
}
.spinWrap
{
color
:
#9999
;
padding
:
12
PX
0
;
text-align
:
center
;
}
.item
{
display
:
flex
;
padding
:
30px
32px
;
align-items
:
center
;
&
.active
{
background-color
:
#E4F1FF
;
}
&
_rank
{
margin-right
:
20px
;
@include
flexLayout
(
row
,
center
);
&
_icon
{
width
:
80px
;
height
:
80px
;
margin
:
-17px
0
;
display
:
block
;
}
&
_index
{
display
:
block
;
text-align
:
center
;
width
:
80px
;
font-size
:
36px
;
font-weight
:
500
;
color
:
rgba
(
70
,
81
,
100
,
0
.5
);
}
}
&
_username
{
display
:
flex
;
flex
:
1
;
align-items
:
center
;
padding-right
:
4
PX
;
&
_text
{
font-size
:
14
PX
;
font-weight
:
600
;
color
:
#465164
;
}
&
_crown
{
width
:
36px
;
height
:
36px
;
position
:
relative
;
top
:
-1
PX
;
}
}
&
_result
{
@include
flexLayout
(
row
,
center
,
center
);
font-size
:
12
PX
;
font-weight
:
400
;
gap
:
6
PX
;
color
:
rgba
(
70
,
81
,
100
,
0
.7
);
&
_best
{
font-size
:
32px
;
font-weight
:
600
;
color
:
#FE9B45
;
}
}
}
.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
);
}
}
src/native-components/rank/index.ts
0 → 100644
View file @
4c0fa8b5
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
import
assets
from
'@/assets/oss/assets-group'
import
styles
from
'./index.module.scss'
const
PageSize
=
10
// @ts-ignore
Component
({
properties
:
{
list
:
{
type
:
Array
,
value
:
[]
}
},
data
:
{
styles
,
assets
,
realList
:
[],
me
:
null
,
loading
:
false
},
attached
()
{
this
.
_hasNextPage
=
true
this
.
_loading
=
false
this
.
_currentPage
=
0
this
.
loadMore
()
const
me
=
this
.
data
.
list
?.
find
(
c
=>
c
.
me
)
if
(
me
&&
me
.
no
>
3
)
{
this
.
setData
({
me
})
}
},
methods
:
{
async
loadMore
()
{
if
(
this
.
_loading
||
!
this
.
_hasNextPage
)
return
this
.
_loading
=
true
this
.
setData
({
loading
:
true
})
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
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
)
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
console
.
log
(
11111111
,
this
.
_loading
,
hasNextPage
)
this
.
_hasNextPage
=
hasNextPage
})
}
}
})
src/native-components/rank/index.wxml
0 → 100644
View file @
4c0fa8b5
<template name="rankItem">
<view class="{{styles.item}} {{ item.me ? styles.active : '' }}">
<view class="{{styles.item_rank}}">
<image
wx:if="{{item.no === 1}}"
class="{{styles.item_rank_icon}}"
src="{{assets['rank-1.png'].u}}"
/>
<image
wx:elif="{{item.no === 2}}"
class="{{styles.item_rank_icon}}"
src="{{assets['rank-2.png'].u}}"
/>
<image
wx:elif="{{item.no === 3}}"
class="{{styles.item_rank_icon}}"
src="{{assets['rank-3.png'].u}}"
/>
<text wx:else class="{{styles.item_rank_index}}">{{item.no}}</text>
</view>
<view class="{{styles.item_username}}">
<view class="{{styles.item_username_text}}">
{{item.nickName || '-'}} <text wx:if="{{item.me}}">(你)</text>
</view>
<image
wx:if="{{item.identity === 'LEADER'}}"
class="{{styles.item_username_crown}}"
src="{{assets['crown-small.png'].u}}"
/>
</view>
<view class="{{styles.item_result}}">
<text class="{{styles.item_result_first}}">{{utils.format(item.firstResultTime)}}秒</text>
<text>|</text>
<text class="{{styles.item_result_best}}">{{utils.format(item.bestResultTime)}}秒</text>
</view>
</view>
</template>
<view class="{{styles.thead}}">
<text class="{{styles.thead_index}}">名次</text>
<text class="{{styles.thead_username}}">用户名</text>
<view class="{{styles.thead_result}}">
<text class="{{styles.thead_result_first}}">首次</text>
<text>|</text>
<text class="{{styles.thead_result_best}}">最佳</text>
</view>
</view>
<template is="rankItem" wx:if="{{me}}" data="{{ styles, item: me, assets }}"/>
<block wx:for="{{ realList }}" wx:key="userId">
<template is="rankItem" data="{{ styles, item, assets }}"/>
</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.empty}}" wx:if="{{list.length < 1}}">暂无数据</view>
<wxs module="utils">
module.exports = {
format : function (val) {
if (typeof val === 'number') {
return val.toFixed(1)
}
return '-'
},
}
</wxs>
src/pages/prepare/index.config.ts
View file @
4c0fa8b5
export
default
definePageConfig
({
export
default
definePageConfig
({
enableShareAppMessage
:
true
,
enableShareAppMessage
:
true
,
navigationBarTitleText
:
'pk-math'
,
navigationBarTitleText
:
'pk-math'
,
navigationStyle
:
'custom'
navigationStyle
:
'custom'
,
usingComponents
:
{
'game-rank'
:
'@/native-components/rank/index'
}
})
})
src/pages/prepare/index.tsx
View file @
4c0fa8b5
...
@@ -21,7 +21,7 @@ import Tabs, { type TabItem } from './components/tabs'
...
@@ -21,7 +21,7 @@ import Tabs, { type TabItem } from './components/tabs'
import
TopBar
from
'./components/top-bar'
import
TopBar
from
'./components/top-bar'
import
MainHeader
from
'./components/main-header'
import
MainHeader
from
'./components/main-header'
import
AnswerCardModal
from
'./components/answer-card-modal'
import
AnswerCardModal
from
'./components/answer-card-modal'
import
{
render
List
,
renderTribePage
}
from
'./render'
import
{
render
TribePage
,
RankList
}
from
'./render'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
...
@@ -51,7 +51,9 @@ const Prepare = () => {
...
@@ -51,7 +51,9 @@ const Prepare = () => {
const
tabs
:
TabItem
[]
=
[
const
tabs
:
TabItem
[]
=
[
{
{
label
:
`
${
userInfo
.
city
===
'其他'
?
''
:
(
userInfo
.
city
??
''
)}
排行榜
`,
label
:
`
${
userInfo
.
city
===
'其他'
?
''
:
(
userInfo
.
city
??
''
)}
排行榜
`,
children: renderList(stageDetail?.ranks || [])
children: (
<RankList list={stageDetail?.ranks ?? []} />
)
},
},
{
{
label: '学习部落排行榜',
label: '学习部落排行榜',
...
...
src/pages/prepare/render.tsx
View file @
4c0fa8b5
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
switchTab
}
from
'@tarojs/taro'
import
{
switchTab
,
useReachBottom
,
getCurrentInstance
}
from
'@tarojs/taro'
import
classNames
from
'classnames
'
import
{
useRef
,
useMemo
}
from
'react
'
import
{
NextStep
,
type
StageRank
}
from
'@/api/game'
import
{
type
StageRank
}
from
'@/api/game'
import
assets
from
'@/assets/oss/assets-prepare'
import
assets
from
'@/assets/oss/assets-prepare'
import
assetsGroup
from
'@/assets/oss/assets-group'
import
Thead
from
'./components/thead'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
import
{
formatNextStep
}
from
'./format'
export
const
renderList
=
(
list
:
StageRank
[])
=>
{
type
RankListProps
=
{
const
isEmpty
=
list
.
length
<
1
list
:
StageRank
[]
const
user
=
list
.
find
(
item
=>
item
.
me
)
return
(
<>
<
Thead
/>
{
user
&&
user
.
no
>
3
&&
renderItem
(
user
)
}
{
list
.
map
(
renderItem
)
}
{
isEmpty
&&
<
View
className=
{
styles
.
empty
}
>
暂无数据
</
View
>
}
</>
)
}
}
export
const
renderItem
=
(
item
:
StageRank
)
=>
{
export
function
RankList
(
props
:
RankListProps
)
{
return
(
const
{
list
}
=
props
<
View
key=
{
item
.
userId
}
className=
{
classNames
(
styles
.
item
,
{
[
styles
.
active
]:
item
.
me
})
}
>
<
View
className=
{
styles
.
item_rank
}
>
const
page
=
useMemo
(()
=>
getCurrentInstance
()?.
page
,
[])
{
[
1
,
2
,
3
].
includes
(
item
.
no
)
?
<
Image
className=
{
styles
.
item_rank_icon
}
src=
{
assetsGroup
[
`rank-${item.no}.png`
].
u
}
/>
const
gameRank
=
useRef
(
null
)
:
<
Text
className=
{
styles
.
item_rank_index
}
>
{
item
.
no
}
</
Text
>
useReachBottom
(()
=>
{
if
(
gameRank
.
current
)
{
(
page
?.
selectComponent
?.(
`#
${(
gameRank
.
current
as
any
).
uid
}
`
)
as
any
)?.
loadMore
()
}
}
</
View
>
})
<
View
className=
{
styles
.
item_username
}
>
<
Text
className=
{
styles
.
item_username_text
}
>
return
(
{
item
.
nickName
||
'-'
}
<
game
-
rank
list=
{
list
}
ref=
{
gameRank
}
/>
{
item
.
me
&&
<
Text
>
(你)
</
Text
>
}
</
Text
>
{
item
.
identity
===
'LEADER'
&&
<
Image
className=
{
styles
.
item_username_crown
}
src=
{
assetsGroup
[
'crown-small.png'
].
u
}
/>
}
</
View
>
<
View
className=
{
styles
.
item_result
}
>
<
Text
className=
{
styles
.
item_result_first
}
>
{
item
.
firstResultTime
?.
toFixed
(
1
)
||
'-'
}
秒
</
Text
>
<
Text
>
|
</
Text
>
<
Text
className=
{
styles
.
item_result_best
}
>
{
item
.
bestResultTime
?.
toFixed
(
1
)
||
'-'
}
秒
</
Text
>
</
View
>
</
View
>
)
)
}
}
...
@@ -61,7 +40,7 @@ const renderTribeList = (list: StageRank[], groupNo?: string) => {
...
@@ -61,7 +40,7 @@ const renderTribeList = (list: StageRank[], groupNo?: string) => {
return
(
return
(
<
View
style=
{
{
paddingBottom
:
70
}
}
>
<
View
style=
{
{
paddingBottom
:
70
}
}
>
<
Text
className=
{
styles
.
tribe_title
}
>
{
groupNo
}
部落
</
Text
>
<
Text
className=
{
styles
.
tribe_title
}
>
{
groupNo
}
部落
</
Text
>
{
renderList
(
list
)
}
<
RankList
list=
{
list
}
/>
</
View
>
</
View
>
)
)
}
}
...
...
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