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
479ce5c8
Commit
479ce5c8
authored
Apr 17, 2024
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 成都一区计算大赛
parent
99aed970
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
479 additions
and
145 deletions
+479
-145
.env.development
.env.development
+1
-1
.env.testing
.env.testing
+1
-1
index.js
config/index.js
+6
-1
global.d.ts
global.d.ts
+6
-0
package.json
package.json
+19
-20
project.config.json
project.config.json
+1
-1
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-0
compile.js
scripts/compile.js
+1
-2
game.ts
src/api/game.ts
+13
-1
skynet.ts
src/config/skynet.ts
+1
-1
index.json
src/native-components/pk-rank/index.json
+3
-0
index.module.scss
src/native-components/pk-rank/index.module.scss
+144
-0
index.ts
src/native-components/pk-rank/index.ts
+71
-0
index.wxml
src/native-components/pk-rank/index.wxml
+62
-0
modal-name.tsx
src/pages/accept-pk/components/modal-name.tsx
+43
-42
index.tsx
src/pages/main/guide/index.tsx
+1
-1
scene-6.tsx
src/pages/main/guide/scene-6.tsx
+69
-52
chapter.tsx
src/pages/main/main-underground/chapter.tsx
+1
-1
answer-card-modal.tsx
src/pages/prepare/components/answer-card-modal.tsx
+3
-3
index.config.ts
src/pages/prepare/index.config.ts
+2
-1
index.tsx
src/pages/prepare/index.tsx
+5
-14
render.tsx
src/pages/prepare/render.tsx
+22
-1
user.ts
src/store/modules/user.ts
+3
-2
yarn.lock
yarn.lock
+0
-0
No files found.
.env.development
View file @
479ce5c8
...
...
@@ -6,7 +6,7 @@ BUILD_MODE=development
# 微信小程序appid
WEAPP_ID=wx693fe3460124d84b
# 服务器接口地址
SERVER_ENDPOINT=http://172.1
0.62.80
SERVER_ENDPOINT=http://172.1
6.62.125
# 腾讯地图接口 api key
TARO_TECENT_LBS_KEY=X3OBZ-OKM3D-I2A4L-P3LQY-7C7ZZ-3KBFG
...
...
.env.testing
View file @
479ce5c8
...
...
@@ -6,7 +6,7 @@ BUILD_MODE=production
# 微信小程序appid
WEAPP_ID=wx693fe3460124d84b
# 服务器接口地址
SERVER_ENDPOINT=http://172.1
0.62.80
SERVER_ENDPOINT=http://172.1
6.62.125
# 天御验证码App id
TARO_T_CAPTCHA_APP_ID=2034167834
...
...
config/index.js
View file @
479ce5c8
...
...
@@ -81,7 +81,12 @@ const config = {
}
},
framework
:
'preact'
,
compiler
:
'webpack5'
,
compiler
:
{
type
:
'webpack5'
,
prebundle
:
{
enable
:
true
}
},
cache
:
{
enable
:
false
// Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
},
...
...
global.d.ts
View file @
479ce5c8
...
...
@@ -39,6 +39,12 @@ declare namespace JSX {
},
HTMLElement
>
,
'game-pk-rank'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[]
},
HTMLElement
>
,
'pk-record'
:
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
list
:
any
[];
...
...
package.json
View file @
479ce5c8
...
...
@@ -21,20 +21,20 @@
"dependencies"
:
{
"
@babel/runtime
"
:
"^7.7.7"
,
"
@geek/skynet-client-wxmini
"
:
"^1.1.12"
,
"
@tarojs/components
"
:
"3.6.2"
,
"
@tarojs/helper
"
:
"3.6.2"
,
"
@tarojs/plugin-framework-react
"
:
"3.6.2"
,
"
@tarojs/plugin-inject
"
:
"^3.6.
4
"
,
"
@tarojs/plugin-platform-alipay
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-h5
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-jd
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-qq
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-swan
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-tt
"
:
"3.6.2"
,
"
@tarojs/plugin-platform-weapp
"
:
"3.6.2"
,
"
@tarojs/runtime
"
:
"3.6.2"
,
"
@tarojs/shared
"
:
"3.6.2"
,
"
@tarojs/taro
"
:
"3.6.2"
,
"
@tarojs/components
"
:
"3.6.2
6
"
,
"
@tarojs/helper
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-framework-react
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-inject
"
:
"^3.6.
26
"
,
"
@tarojs/plugin-platform-alipay
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-h5
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-jd
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-qq
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-swan
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-tt
"
:
"3.6.2
6
"
,
"
@tarojs/plugin-platform-weapp
"
:
"3.6.2
6
"
,
"
@tarojs/runtime
"
:
"3.6.2
6
"
,
"
@tarojs/shared
"
:
"3.6.2
6
"
,
"
@tarojs/taro
"
:
"3.6.2
6
"
,
"
easy-peasy
"
:
"^5.2.0"
,
"
html-parse-stringify
"
:
"^3.0.1"
,
"
preact
"
:
"^10.5.15"
,
...
...
@@ -49,13 +49,13 @@
"
@prefresh/babel-plugin
"
:
"^0.4.1"
,
"
@prefresh/core
"
:
"^1.3.4"
,
"
@prefresh/webpack
"
:
"^3.2.3"
,
"
@tarojs/cli
"
:
"3.6.2"
,
"
@tarojs/webpack5-runner
"
:
"3.6.2"
,
"
@tarojs/cli
"
:
"3.6.2
6
"
,
"
@tarojs/webpack5-runner
"
:
"3.6.2
6
"
,
"
@types/react
"
:
"^18.0.0"
,
"
@types/webpack-env
"
:
"^1.13.6"
,
"
@typescript-eslint/eslint-plugin
"
:
"^5.20.0"
,
"
@typescript-eslint/parser
"
:
"^5.20.0"
,
"
babel-preset-taro
"
:
"3.6.2"
,
"
babel-preset-taro
"
:
"3.6.2
6
"
,
"
base-x
"
:
"^4.0.0"
,
"
copy-dir
"
:
"^1.3.0"
,
"
cos-nodejs-sdk-v5
"
:
"^2.11.4"
,
...
...
@@ -63,7 +63,7 @@
"
dotenv
"
:
"^9.0.2"
,
"
eslint
"
:
"^8.12.0"
,
"
eslint-config-standard
"
:
"^17.0.0"
,
"
eslint-config-taro
"
:
"3.6.2"
,
"
eslint-config-taro
"
:
"3.6.2
6
"
,
"
eslint-plugin-import
"
:
"^2.25.2"
,
"
eslint-plugin-n
"
:
"^15.0.0"
,
"
eslint-plugin-promise
"
:
"^6.0.0"
,
...
...
@@ -98,4 +98,4 @@
"resolutions"
:
{
"@types/react"
:
"^17.0.2"
}
}
\ No newline at end of file
}
project.config.json
View file @
479ce5c8
...
...
@@ -2,7 +2,7 @@
"miniprogramRoot"
:
"dist/"
,
"projectname"
:
"GeekLearnMathWeapp"
,
"description"
:
""
,
"appid"
:
"wx
8f25def587982a19
"
,
"appid"
:
"wx
693fe3460124d84b
"
,
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
false
,
...
...
scripts/app.config.ts.tpl
View file @
479ce5c8
...
...
@@ -5,6 +5,7 @@
/* Do not edit this file. It is a file generated by script/config-pkgs.js */
export default {
__usePrivacyCheck__: true,
pages: [
'pages/main/main',
'pages/accept-pk/index',
...
...
scripts/compile.js
View file @
479ce5c8
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
execa
=
require
(
'execa'
)
const
chalk
=
require
(
'chalk'
).
default
const
address
=
require
(
'address'
)
const
chokidar
=
require
(
'chokidar'
)
const
configEnv
=
require
(
'./config-env'
)
...
...
@@ -69,7 +68,7 @@ if (watch) {
timer
=
setTimeout
(()
=>
{
timer
=
null
if
(
child
&&
child
.
kill
(
'SIGKILL'
))
{
console
.
log
(
`
${
chalk
.
blue
(
'重启mock服务中...'
)}
`
)
console
.
log
(
'重启mock服务中...'
)
}
child
=
createMock
()
},
restartMockDuration
)
...
...
src/api/game.ts
View file @
479ce5c8
...
...
@@ -97,6 +97,17 @@ export type NextStep = {
nextStepReward
:
number
;
nextStepTime
:
number
}
export
type
PKRank
=
{
loseNum
:
number
;
me
:
boolean
;
nickName
:
string
;
no
:
number
;
secondName
:
string
;
userId
:
number
;
winNum
:
number
;
}
export
interface
StageDetail
extends
Stage
{
aTime
:
number
;
bTime
:
number
;
...
...
@@ -105,6 +116,7 @@ export interface StageDetail extends Stage {
content
:
string
;
bestResultTime
:
number
;
ranks
?:
StageRank
[];
pkRanks
?:
PKRank
[];
groupRanks
?:
StageRank
[];
questionNum
:
number
;
nextSteps
?:
NextStep
[];
...
...
@@ -124,7 +136,7 @@ export function getStageList () {
return
requestAfterSilentLogin
<
Stage
[],
{
chapter
:
number
;
userId
?:
number
}
>
(
userInfo
=>
({
method
:
'GET'
,
url
:
'/service-idea/stage/listStages'
,
data
:
{
chapter
:
2
,
userId
:
userInfo
?.
userId
}
data
:
{
chapter
:
3
,
userId
:
userInfo
?.
userId
}
}))
}
...
...
src/config/skynet.ts
View file @
479ce5c8
import
{
baseUrl
}
from
'./server'
const
_baseUrl
=
process
.
env
.
SERVER_ENDPOINT
===
'https://geek.jkwljy.com'
?
baseUrl
:
'http://172.1
0.61.134
'
const
_baseUrl
=
process
.
env
.
SERVER_ENDPOINT
===
'https://geek.jkwljy.com'
?
baseUrl
:
'http://172.1
6.62.123
'
export
const
SkynetConfig
=
{
appId
:
'learn-math'
,
...
...
src/native-components/pk-rank/index.json
0 → 100644
View file @
479ce5c8
{
"component"
:
true
}
src/native-components/pk-rank/index.module.scss
0 → 100644
View file @
479ce5c8
@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/pk-rank/index.ts
0 → 100644
View file @
479ce5c8
/* 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
,
300
))
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
this
.
_hasNextPage
=
hasNextPage
})
}
}
})
src/native-components/pk-rank/index.wxml
0 → 100644
View file @
479ce5c8
<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}}">{{item.loseNum}}</text>
<text>|</text>
<text class="{{styles.item_result_best}}">{{item.winNum}}</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>
src/pages/accept-pk/components/modal-name.tsx
View file @
479ce5c8
import
{
View
,
RootPortal
,
Image
,
Button
,
ButtonProps
,
CommonEventFunction
,
Input
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
{
useCallback
,
use
Ref
,
use
State
}
from
'react'
import
{
useCallback
,
useState
}
from
'react'
import
{
EyeProtectionView
}
from
'@/components'
import
{
useBoolean
}
from
'@/hooks'
import
{
useStoreActions
}
from
'@/store/hooks'
import
{
getNickNameWords
,
type
NickNameWord
}
from
'@/api'
// import { useBoolean } from '@/hooks'
// import { getNickNameWords, type NickNameWord } from '@/api'
import
assetsPk
from
'@/assets/oss/assets-pk'
import
assetsGuide
from
'@/assets/oss/assets-guide'
//
import assetsGuide from '@/assets/oss/assets-guide'
import
{
report
,
SkynetEvent
}
from
'@/utils/skynet'
import
styles
from
'./modal-name.module.scss'
const
randomPick
=
(
arr
:
string
[])
=>
{
const
len
=
arr
.
length
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
len
)
return
arr
[
randomIndex
]
}
//
const randomPick = (arr: string[]) => {
//
const len = arr.length
//
const randomIndex = Math.floor(Math.random() * len)
//
return arr[randomIndex]
//
}
const
ModalName
=
({
isVisible
,
...
...
@@ -26,39 +26,39 @@ const ModalName = ({
onClose
:
()
=>
void
;
onFinish
:
()
=>
void
;
})
=>
{
const
[
name
,
setName
]
=
useState
(
'
小明
'
)
const
[
generating
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
dataRef
=
useRef
<
NickNameWord
>
({
noun
:
[],
adj
:
[]
})
const
timerRef
=
useRef
<
NodeJS
.
Timer
|
null
>
(
null
)
const
[
name
,
setName
]
=
useState
(
''
)
//
const [generating, { setTrue, setFalse }] = useBoolean(false)
//
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
//
const timerRef = useRef<NodeJS.Timer | null>(null)
const
updateNickNameAndPhone
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateNickNameAndPhone
)
const
generateName
=
useCallback
(()
=>
{
const
{
noun
,
adj
}
=
dataRef
.
current
const
nam
=
[
randomPick
(
adj
),
randomPick
(
noun
)].
filter
(
Boolean
).
join
(
''
)
setName
(
nam
)
},
[])
//
const generateName = useCallback(() => {
//
const { noun, adj } = dataRef.current
//
const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('')
//
setName(nam)
//
}, [])
const
getNameWords
=
useCallback
(
async
()
=>
{
const
words
=
await
getNickNameWords
()
dataRef
.
current
=
words
generateName
()
},
[
generateName
])
//
const getNameWords = useCallback(async () => {
//
const words = await getNickNameWords()
//
dataRef.current = words
//
generateName()
//
}, [generateName])
const
handleGenerate
=
useCallback
(()
=>
{
setTrue
()
if
(
dataRef
.
current
.
adj
.
length
<
1
)
{
getNameWords
()
}
else
{
generateName
()
}
if
(
timerRef
.
current
)
{
clearTimeout
(
timerRef
.
current
)
}
timerRef
.
current
=
setTimeout
(()
=>
{
setFalse
()
timerRef
.
current
=
null
},
1000
)
},
[
generateName
,
setTrue
,
setFalse
,
getNameWords
])
//
const handleGenerate = useCallback(() => {
//
setTrue()
//
if (dataRef.current.adj.length < 1) {
//
getNameWords()
//
} else {
//
generateName()
//
}
//
if (timerRef.current) {
//
clearTimeout(timerRef.current)
//
}
//
timerRef.current = setTimeout(() => {
//
setFalse()
//
timerRef.current = null
//
}, 1000)
//
}, [generateName, setTrue, setFalse, getNameWords])
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
handleGetPhone
=
useCallback
<
CommonEventFunction
<
ButtonProps
.
onGetPhoneNumberEventDetail
>>
((
e
)
=>
{
...
...
@@ -78,7 +78,7 @@ const ModalName = ({
setLoading
(
false
)
console
.
log
(
err
)
})
},
[
onClose
,
updateNickNameAndPhone
,
onFinish
,
name
,
loading
])
},
[
updateNickNameAndPhone
,
onFinish
,
name
,
loading
])
return
(
<
RootPortal
>
...
...
@@ -95,22 +95,23 @@ const ModalName = ({
/>
<
View
className=
{
styles
.
title
}
>
请问大侠,尊姓大名
</
View
>
<
View
className=
{
styles
.
tips
}
>
请输入您的
角色
名(7字以内)
请输入您的
姓
名(7字以内)
</
View
>
<
View
className=
{
styles
.
input
}
>
<
Input
className=
{
styles
.
inputName
}
value=
{
name
as
string
}
placeholder=
"请输入"
onInput=
{
(
e
)
=>
setName
(
e
.
detail
.
value
)
}
/>
<
Image
{
/*
<Image
src={assetsGuide['touzi.png'].u}
className={classNames(
styles.inputIcon,
generating && styles.generating
)}
onClick={handleGenerate}
></
Image
>
></Image>
*/
}
</
View
>
<
View
className=
{
styles
.
footer
}
>
<
Button
...
...
src/pages/main/guide/index.tsx
View file @
479ce5c8
...
...
@@ -57,7 +57,7 @@ const Guide = (props: GuideProps) => {
// <Scene3 spriteTop={spriteTop} isCurrent={step === 2} onNext={(val: number) => { setStep(3); setTime(val) }} key={3} />,
// <Scene4 spriteTop={spriteTop} isCurrent={step === 3} onNext={() => setStep(4)} time={time} key={4} />,
<
Scene5
spriteTop=
{
spriteTop
}
isCurrent=
{
step
===
2
}
onNext=
{
()
=>
setStep
(
3
)
}
key=
{
2
}
/>,
<
Scene6
spriteTop=
{
spriteTop
}
onNext=
{
onDone
}
key=
{
3
}
/>
<
Scene6
spriteTop=
{
spriteTop
}
isCurrent=
{
step
===
3
}
onNext=
{
onDone
}
key=
{
3
}
/>
]
},
[
onDone
,
spriteTop
,
step
])
...
...
src/pages/main/guide/scene-6.tsx
View file @
479ce5c8
import
{
View
,
Input
,
Image
,
ScrollView
,
Button
,
CommonEventFunction
,
ButtonProps
}
from
'@tarojs/components'
import
classNames
from
'classnames'
import
{
useState
,
useCallback
,
use
Effect
,
useRef
,
useMemo
}
from
'react'
import
{
useState
,
useCallback
,
use
Memo
,
useEffect
}
from
'react'
import
{
useStoreActions
}
from
'@/store/hooks'
import
{
showToast
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-guide'
import
{
useBoolean
}
from
'@/hooks'
//
import { useBoolean } from '@/hooks'
import
{
report
,
SkynetEvent
}
from
'@/utils/skynet'
import
{
getNickNameWords
,
type
NickNameWord
}
from
'@/api'
//
import { getNickNameWords, type NickNameWord } from '@/api'
import
cs
from
'./index.module.scss'
import
styles
from
'./scene-6.module.scss'
type
Scene6Props
=
{
spriteTop
:
number
;
onNext
:
()
=>
void
;
isCurrent
:
boolean
;
}
const
randomPick
=
(
arr
:
string
[])
=>
{
const
len
=
arr
.
length
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
len
)
return
arr
[
randomIndex
]
}
//
const randomPick = (arr: string[]) => {
//
const len = arr.length
//
const randomIndex = Math.floor(Math.random() * len)
//
return arr[randomIndex]
//
}
const
Scene6
=
(
props
:
Scene6Props
)
=>
{
const
{
spriteTop
,
onNext
}
=
props
const
{
spriteTop
,
onNext
,
isCurrent
}
=
props
const
[
name
,
setName
]
=
useState
(
''
)
const
dataRef
=
useRef
<
NickNameWord
>
({
noun
:
[],
adj
:
[]
})
const
timerRef
=
useRef
<
NodeJS
.
Timer
|
null
>
(
null
)
//
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
//
const timerRef = useRef<NodeJS.Timer | null>(null)
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
isGenerating
,
genActions
]
=
useBoolean
(
false
)
const
[
focus
,
setFocus
]
=
useState
(
false
)
// const [isGenerating, genActions] = useBoolean(false)
const
genName
=
useCallback
(()
=>
{
const
{
noun
,
adj
}
=
dataRef
.
current
const
nam
=
[
randomPick
(
adj
),
randomPick
(
noun
)].
filter
(
Boolean
).
join
(
''
)
setName
(
nam
)
},
[])
// const genName = useCallback(() => {
// const { noun, adj } = dataRef.current
// const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('')
// setName(nam)
// }, [])
useEffect
(()
=>
{
let
timer
:
NodeJS
.
Timer
if
(
isCurrent
)
{
timer
=
setTimeout
(()
=>
{
setFocus
(
true
)
},
1000
)
}
return
()
=>
{
if
(
timer
)
{
clearTimeout
(
timer
)
}
}
},
[
isCurrent
])
const
updateNickNameAndPhone
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateNickNameAndPhone
)
...
...
@@ -56,31 +72,31 @@ const Scene6 = (props: Scene6Props) => {
})
},
[
updateNickNameAndPhone
,
onNext
,
name
,
loading
])
const
_getNickNameWords
=
useCallback
(
async
()
=>
{
const
words
=
await
getNickNameWords
()
dataRef
.
current
=
words
genName
()
},
[
genName
])
const
handleGen
=
useCallback
(()
=>
{
genActions
.
setTrue
()
if
(
dataRef
.
current
.
adj
.
length
<
1
)
{
_getNickNameWords
()
}
else
{
genName
()
}
if
(
timerRef
.
current
)
{
clearTimeout
(
timerRef
.
current
)
}
timerRef
.
current
=
setTimeout
(()
=>
{
genActions
.
setFalse
()
timerRef
.
current
=
null
},
1000
)
},
[
genName
,
genActions
,
_getNickNameWords
])
useEffect
(()
=>
{
_getNickNameWords
()
},
[
_getNickNameWords
])
//
const _getNickNameWords = useCallback(async () => {
//
const words = await getNickNameWords()
//
dataRef.current = words
//
genName()
//
}, [genName])
//
const handleGen = useCallback(() => {
//
genActions.setTrue()
//
if (dataRef.current.adj.length < 1) {
//
_getNickNameWords()
//
} else {
//
genName()
//
}
//
if (timerRef.current) {
//
clearTimeout(timerRef.current)
//
}
//
timerRef.current = setTimeout(() => {
//
genActions.setFalse()
//
timerRef.current = null
//
}, 1000)
//
}, [genName, genActions, _getNickNameWords])
//
useEffect(() => {
//
_getNickNameWords()
//
}, [_getNickNameWords])
const
handleInput
=
useCallback
((
e
)
=>
{
setName
(
e
.
detail
.
value
)
...
...
@@ -104,25 +120,25 @@ const Scene6 = (props: Scene6Props) => {
<
View
className=
{
classNames
(
cs
.
sprite
,
cs
.
step_static
)
}
style=
{
{
paddingTop
:
`${spriteTop}px`
}
}
>
<
Image
src=
{
assets
[
'cat-5.png'
].
u
}
className=
{
cs
.
cat
}
/>
<
View
className=
{
styles
.
modal_4
}
style=
{
{
marginTop
:
`${spriteTop}px`
}
}
>
<
View
>
请
输入你的角色名(7字以内)
</
View
>
<
View
className=
{
styles
.
tips
}
>
*
仅用于排行榜展示
哦
</
View
>
<
View
>
请
填写你的真实姓名
</
View
>
<
View
className=
{
styles
.
tips
}
>
*
将用于最后的结果与奖品发放
哦
</
View
>
</
View
>
</
View
>
<
View
className=
{
styles
.
top
}
></
View
>
<
View
>
<
View
className=
{
styles
.
input
}
>
<
View
className=
{
styles
.
input_item
}
>
<
Input
value=
{
name
}
className=
{
styles
.
input_inner
}
onInput=
{
handleInput
}
></
Input
>
<
Input
value=
{
name
}
className=
{
styles
.
input_inner
}
focus=
{
focus
}
placeholder=
"请输入姓名"
onInput=
{
handleInput
}
></
Input
>
</
View
>
<
Image
{
/*
<Image
src={assets['touzi.png'].u}
className={classNames(styles.input_icon, isGenerating && styles.is_gen)}
onClick={handleGen}
id="main_guide_6_gen_name"
></
Image
>
></Image>
*/
}
</
View
>
<
View
className=
{
styles
.
input_tip
}
>
* 可点击右侧按钮随机生成昵称
{
/* * 可点击右侧按钮随机生成昵称 */
}
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
></
View
>
...
...
@@ -134,15 +150,16 @@ const Scene6 = (props: Scene6Props) => {
<
View
className=
{
styles
.
btn_tip
}
>
同时为保存你的闯关数据,请进行授权
</
View
>
{
disabled
?
(
<
View
className=
{
classNames
(
cs
.
btn
,
cs
.
disabled
)
}
onClick=
{
handleClick
}
>
确定
</
View
>
<
View
className=
{
classNames
(
cs
.
btn
,
cs
.
disabled
)
}
onClick=
{
handleClick
}
>
确定
</
View
>
)
:
(
<
Button
openType=
"getPhoneNumber"
onGetPhoneNumber=
{
handleGetPhone
}
onAgreePrivacyAuthorization=
{
console
.
log
}
className=
{
cs
.
btn
}
loading=
{
loading
}
disabled=
{
loading
}
...
...
src/pages/main/main-underground/chapter.tsx
View file @
479ce5c8
...
...
@@ -33,7 +33,7 @@ const MainHeader = () => {
<
Image
src=
{
assetsMainNext
[
'page-head-2.png'
].
u
}
mode=
"widthFix"
className=
{
styles
.
bg
}
></
Image
>
<
View
className=
{
styles
.
chapterContent
}
>
<
View
className=
{
styles
.
chapterName
}
>
地心历险记
计算小勇士
</
View
>
</
View
>
{
!
isAddDeskTopGuideComplete
&&
(
...
...
src/pages/prepare/components/answer-card-modal.tsx
View file @
479ce5c8
import
{
PropsWithChildren
}
from
'react'
import
{
View
,
RootPortal
,
Image
,
Text
}
from
'@tarojs/components'
import
{
switchTab
}
from
'@tarojs/taro'
import
{
redirectTo
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
styles
from
'./answer-card-modal.module.scss'
...
...
@@ -23,8 +23,8 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => {
<
View
className=
{
styles
.
tips
}
>
可通过以下途径获得哦
</
View
>
<
View
className=
{
styles
.
footer
}
>
{
children
}
<
View
className=
{
styles
.
studyTribe
}
onClick=
{
()
=>
switchTab
({
url
:
'/pages/group
/index'
})
}
>
<
Text
>
建设学习部落,得更多答题卡
</
Text
>
<
View
className=
{
styles
.
studyTribe
}
onClick=
{
()
=>
redirectTo
({
url
:
'/pages/battles
/index'
})
}
>
<
Text
>
发起更多PK,赢水晶
</
Text
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/prepare/index.config.ts
View file @
479ce5c8
...
...
@@ -3,6 +3,7 @@ export default definePageConfig({
navigationBarTitleText
:
'pk-math'
,
navigationStyle
:
'custom'
,
usingComponents
:
{
'game-rank'
:
'@/native-components/rank/index'
'game-rank'
:
'@/native-components/rank/index'
,
'game-pk-rank'
:
'@/native-components/pk-rank/index'
}
})
src/pages/prepare/index.tsx
View file @
479ce5c8
...
...
@@ -5,13 +5,11 @@ import classNames from 'classnames'
import
Button
from
'@/components/Button'
import
Loading
from
'@/components/Loading'
import
ShareView
from
'@/pages/group/components/share-view'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useBoolean
,
useRequest
,
useShare
}
from
'@/hooks'
import
{
pointToCard
}
from
'@/api/account'
import
assets
from
'@/assets/oss/assets-prepare'
import
assetsGroup
from
'@/assets/oss/assets-group'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
{
EyeProtectionView
}
from
'@/components'
...
...
@@ -20,10 +18,9 @@ import tutorialAssets from '@/assets/oss/assets-tutorial'
import
Tabs
,
{
type
TabItem
}
from
'./components/tabs'
import
TopBar
from
'./components/top-bar'
import
MainHeader
from
'./components/main-header'
import
PkGuide
from
'./guide/pk/scene-1'
import
AnswerCardModal
from
'./components/answer-card-modal'
import
PkGuideScene
from
'./guide/pk/scene'
import
{
renderTribePage
,
RankList
}
from
'./render'
import
{
RankList
,
Pk
RankList
}
from
'./render'
import
styles
from
'./index.module.scss'
...
...
@@ -61,11 +58,9 @@ const Prepare = () => {
)
},
{
label: '
学习部落
排行榜',
label: '
PK
排行榜',
children: (
<View className={styles.tribe}>
{renderTribePage(stageDetail?.groupRanks || [], tribeInfo?.groupNo)}
</View>
<PkRankList list={stageDetail?.pkRanks || []}></PkRankList>
)
}
]
...
...
@@ -259,16 +254,12 @@ const Prepare = () => {
</View>
<View className={styles.footer_bar}>
{currentTab === 1 && tribeInfo && tribeInfo.id && <ShareView>
{/* <View className={styles.members_tip}>
<Image className={styles.members_tip_icon} src={require('@/pages/main/assets/score.png')} />
<Text className={styles.members_tip_text}>+100</Text>
</View> */}
{/* {currentTab === 1 && tribeInfo && 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>}
</ShareView>}
*/}
{!isSubmit ? renderFisrtActions() : renderAgainActions()}
</View>
...
...
src/pages/prepare/render.tsx
View file @
479ce5c8
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
switchTab
,
useReachBottom
,
getCurrentInstance
}
from
'@tarojs/taro'
import
{
useRef
,
useMemo
}
from
'react'
import
{
type
StageRank
}
from
'@/api/game'
import
{
PKRank
,
type
StageRank
}
from
'@/api/game'
import
assets
from
'@/assets/oss/assets-prepare'
import
styles
from
'./index.module.scss'
...
...
@@ -27,6 +27,27 @@ export function RankList (props: RankListProps) {
)
}
type
PkRankListProps
=
{
list
:
PKRank
[]
}
export
function
PkRankList
(
props
:
PkRankListProps
)
{
const
{
list
}
=
props
const
page
=
useMemo
(()
=>
getCurrentInstance
()?.
page
,
[])
const
pkRank
=
useRef
(
null
)
useReachBottom
(()
=>
{
if
(
pkRank
.
current
)
{
(
page
?.
selectComponent
?.(
`#
${(
pkRank
.
current
as
any
).
uid
}
`
)
as
any
)?.
loadMore
()
}
})
return
(
<
game
-
pk
-
rank
list=
{
list
}
ref=
{
pkRank
}
/>
)
}
const
renderEmptyTribe
=
()
=>
(
<
View
className=
{
styles
.
tribe_empty
}
>
<
Image
className=
{
styles
.
tribe_empty_logo
}
src=
{
assets
[
'tribe.png'
].
u
}
mode=
"widthFix"
/>
...
...
src/store/modules/user.ts
View file @
479ce5c8
...
...
@@ -69,10 +69,11 @@ const userModel: UserModel = {
updateNickNameAndPhone
:
thunk
(
async
(
actions
,
payload
,
helpers
)
=>
{
try
{
const
defaultUserInfo
=
{
city
:
'成都'
,
grade
:
'二年级'
}
const
fns
:
Promise
<
any
>
[]
=
[
]
if
(
payload
.
name
)
{
fns
.
push
(
updateUserInfo
({
nickName
:
payload
.
name
}))
fns
.
push
(
updateUserInfo
({
nickName
:
payload
.
name
,
...
defaultUserInfo
}))
}
let
authPhone
...
...
@@ -93,7 +94,7 @@ const userModel: UserModel = {
}
if
(
payload
.
name
)
{
current
=
{
...
current
,
nickName
:
payload
.
name
}
current
=
{
...
current
,
nickName
:
payload
.
name
,
...
defaultUserInfo
}
}
updateStorage
(
StorageKeys
.
userInfo
,
current
)
...
...
yarn.lock
View file @
479ce5c8
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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