Commit 479ce5c8 authored by hewenhao's avatar hewenhao

feat: 成都一区计算大赛

parent 99aed970
...@@ -6,7 +6,7 @@ BUILD_MODE=development ...@@ -6,7 +6,7 @@ BUILD_MODE=development
# 微信小程序appid # 微信小程序appid
WEAPP_ID=wx693fe3460124d84b WEAPP_ID=wx693fe3460124d84b
# 服务器接口地址 # 服务器接口地址
SERVER_ENDPOINT=http://172.10.62.80 SERVER_ENDPOINT=http://172.16.62.125
# 腾讯地图接口 api key # 腾讯地图接口 api key
TARO_TECENT_LBS_KEY=X3OBZ-OKM3D-I2A4L-P3LQY-7C7ZZ-3KBFG TARO_TECENT_LBS_KEY=X3OBZ-OKM3D-I2A4L-P3LQY-7C7ZZ-3KBFG
......
...@@ -6,7 +6,7 @@ BUILD_MODE=production ...@@ -6,7 +6,7 @@ BUILD_MODE=production
# 微信小程序appid # 微信小程序appid
WEAPP_ID=wx693fe3460124d84b WEAPP_ID=wx693fe3460124d84b
# 服务器接口地址 # 服务器接口地址
SERVER_ENDPOINT=http://172.10.62.80 SERVER_ENDPOINT=http://172.16.62.125
# 天御验证码App id # 天御验证码App id
TARO_T_CAPTCHA_APP_ID=2034167834 TARO_T_CAPTCHA_APP_ID=2034167834
......
...@@ -81,7 +81,12 @@ const config = { ...@@ -81,7 +81,12 @@ const config = {
} }
}, },
framework: 'preact', framework: 'preact',
compiler: 'webpack5', compiler: {
type: 'webpack5',
prebundle: {
enable: true
}
},
cache: { cache: {
enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
}, },
......
...@@ -39,6 +39,12 @@ declare namespace JSX { ...@@ -39,6 +39,12 @@ declare namespace JSX {
}, },
HTMLElement HTMLElement
>, >,
'game-pk-rank': React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement> & {
list: any[]
},
HTMLElement
>,
'pk-record': React.DetailedHTMLProps< 'pk-record': React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement> & { React.HTMLAttributes<HTMLElement> & {
list: any[]; list: any[];
......
...@@ -21,20 +21,20 @@ ...@@ -21,20 +21,20 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"@geek/skynet-client-wxmini": "^1.1.12", "@geek/skynet-client-wxmini": "^1.1.12",
"@tarojs/components": "3.6.2", "@tarojs/components": "3.6.26",
"@tarojs/helper": "3.6.2", "@tarojs/helper": "3.6.26",
"@tarojs/plugin-framework-react": "3.6.2", "@tarojs/plugin-framework-react": "3.6.26",
"@tarojs/plugin-inject": "^3.6.4", "@tarojs/plugin-inject": "^3.6.26",
"@tarojs/plugin-platform-alipay": "3.6.2", "@tarojs/plugin-platform-alipay": "3.6.26",
"@tarojs/plugin-platform-h5": "3.6.2", "@tarojs/plugin-platform-h5": "3.6.26",
"@tarojs/plugin-platform-jd": "3.6.2", "@tarojs/plugin-platform-jd": "3.6.26",
"@tarojs/plugin-platform-qq": "3.6.2", "@tarojs/plugin-platform-qq": "3.6.26",
"@tarojs/plugin-platform-swan": "3.6.2", "@tarojs/plugin-platform-swan": "3.6.26",
"@tarojs/plugin-platform-tt": "3.6.2", "@tarojs/plugin-platform-tt": "3.6.26",
"@tarojs/plugin-platform-weapp": "3.6.2", "@tarojs/plugin-platform-weapp": "3.6.26",
"@tarojs/runtime": "3.6.2", "@tarojs/runtime": "3.6.26",
"@tarojs/shared": "3.6.2", "@tarojs/shared": "3.6.26",
"@tarojs/taro": "3.6.2", "@tarojs/taro": "3.6.26",
"easy-peasy": "^5.2.0", "easy-peasy": "^5.2.0",
"html-parse-stringify": "^3.0.1", "html-parse-stringify": "^3.0.1",
"preact": "^10.5.15", "preact": "^10.5.15",
...@@ -49,13 +49,13 @@ ...@@ -49,13 +49,13 @@
"@prefresh/babel-plugin": "^0.4.1", "@prefresh/babel-plugin": "^0.4.1",
"@prefresh/core": "^1.3.4", "@prefresh/core": "^1.3.4",
"@prefresh/webpack": "^3.2.3", "@prefresh/webpack": "^3.2.3",
"@tarojs/cli": "3.6.2", "@tarojs/cli": "3.6.26",
"@tarojs/webpack5-runner": "3.6.2", "@tarojs/webpack5-runner": "3.6.26",
"@types/react": "^18.0.0", "@types/react": "^18.0.0",
"@types/webpack-env": "^1.13.6", "@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0", "@typescript-eslint/parser": "^5.20.0",
"babel-preset-taro": "3.6.2", "babel-preset-taro": "3.6.26",
"base-x": "^4.0.0", "base-x": "^4.0.0",
"copy-dir": "^1.3.0", "copy-dir": "^1.3.0",
"cos-nodejs-sdk-v5": "^2.11.4", "cos-nodejs-sdk-v5": "^2.11.4",
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"dotenv": "^9.0.2", "dotenv": "^9.0.2",
"eslint": "^8.12.0", "eslint": "^8.12.0",
"eslint-config-standard": "^17.0.0", "eslint-config-standard": "^17.0.0",
"eslint-config-taro": "3.6.2", "eslint-config-taro": "3.6.26",
"eslint-plugin-import": "^2.25.2", "eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0", "eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0", "eslint-plugin-promise": "^6.0.0",
...@@ -98,4 +98,4 @@ ...@@ -98,4 +98,4 @@
"resolutions": { "resolutions": {
"@types/react": "^17.0.2" "@types/react": "^17.0.2"
} }
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"miniprogramRoot": "dist/", "miniprogramRoot": "dist/",
"projectname": "GeekLearnMathWeapp", "projectname": "GeekLearnMathWeapp",
"description": "", "description": "",
"appid": "wx8f25def587982a19", "appid": "wx693fe3460124d84b",
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
"es6": false, "es6": false,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
/* Do not edit this file. It is a file generated by script/config-pkgs.js */ /* Do not edit this file. It is a file generated by script/config-pkgs.js */
export default { export default {
__usePrivacyCheck__: true,
pages: [ pages: [
'pages/main/main', 'pages/main/main',
'pages/accept-pk/index', 'pages/accept-pk/index',
......
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const execa = require('execa') const execa = require('execa')
const chalk = require('chalk').default
const address = require('address') const address = require('address')
const chokidar = require('chokidar') const chokidar = require('chokidar')
const configEnv = require('./config-env') const configEnv = require('./config-env')
...@@ -69,7 +68,7 @@ if (watch) { ...@@ -69,7 +68,7 @@ if (watch) {
timer = setTimeout(() => { timer = setTimeout(() => {
timer = null timer = null
if (child && child.kill('SIGKILL')) { if (child && child.kill('SIGKILL')) {
console.log(`${chalk.blue('重启mock服务中...')}`) console.log('重启mock服务中...')
} }
child = createMock() child = createMock()
}, restartMockDuration) }, restartMockDuration)
......
...@@ -97,6 +97,17 @@ export type NextStep = { ...@@ -97,6 +97,17 @@ export type NextStep = {
nextStepReward: number; nextStepReward: number;
nextStepTime: 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 { export interface StageDetail extends Stage {
aTime: number; aTime: number;
bTime: number; bTime: number;
...@@ -105,6 +116,7 @@ export interface StageDetail extends Stage { ...@@ -105,6 +116,7 @@ export interface StageDetail extends Stage {
content: string; content: string;
bestResultTime: number; bestResultTime: number;
ranks?: StageRank[]; ranks?: StageRank[];
pkRanks?: PKRank[];
groupRanks?: StageRank[]; groupRanks?: StageRank[];
questionNum: number; questionNum: number;
nextSteps?: NextStep[]; nextSteps?: NextStep[];
...@@ -124,7 +136,7 @@ export function getStageList () { ...@@ -124,7 +136,7 @@ export function getStageList () {
return requestAfterSilentLogin<Stage[], { chapter: number; userId?: number }>(userInfo => ({ return requestAfterSilentLogin<Stage[], { chapter: number; userId?: number }>(userInfo => ({
method: 'GET', method: 'GET',
url: '/service-idea/stage/listStages', url: '/service-idea/stage/listStages',
data: { chapter: 2, userId: userInfo?.userId } data: { chapter: 3, userId: userInfo?.userId }
})) }))
} }
......
import { baseUrl } from './server' import { baseUrl } from './server'
const _baseUrl = process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com' ? baseUrl : 'http://172.10.61.134' const _baseUrl = process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com' ? baseUrl : 'http://172.16.62.123'
export const SkynetConfig = { export const SkynetConfig = {
appId: 'learn-math', appId: 'learn-math',
......
@import '@/styles/mixins.scss';
.thead {
height: 40PX;
background: #F7F9FC;
display: flex;
align-items: center;
font-size: 12PX;
padding: 0 32px;
color: rgba(70,81,100,0.5);
&_index {
width: 80px;
text-align: center;
padding-left: 3PX;
margin-right: 23PX;
}
&_username {
flex: 1;
}
&_result {
display: flex;
align-items: center;
font-size: 12PX;
font-weight: 400;
gap: 6PX;
color: rgba(70,81,100,0.7);
&_best {
font-size: 32px;
font-weight: 600;
color: #FE9B45;
}
}
}
.empty {
color: #9999;
font-size: 14PX;
margin: 24PX 0;
text-align: center;
}
.spinWrap {
color: #9999;
padding: 12PX 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: 4PX;
&_text {
font-size: 14PX;
font-weight: 600;
color: #465164;
}
&_crown {
width: 36px;
height: 36px;
position: relative;
top: -1PX;
}
}
&_result {
@include flexLayout(row, center, center);
font-size: 12PX;
font-weight: 400;
gap: 6PX;
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: 18PX;
height: 18PX;
}
.spinText {
font-size: 14PX;
margin-left: 12PX;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* 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
})
}
}
})
<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>
import { View, RootPortal, Image, Button, ButtonProps, CommonEventFunction, Input } from '@tarojs/components' import { View, RootPortal, Image, Button, ButtonProps, CommonEventFunction, Input } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { useCallback, useRef, useState } from 'react' import { useCallback, useState } from 'react'
import { EyeProtectionView } from '@/components' import { EyeProtectionView } from '@/components'
import { useBoolean } from '@/hooks'
import { useStoreActions } from '@/store/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 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 { report, SkynetEvent } from '@/utils/skynet'
import styles from './modal-name.module.scss' import styles from './modal-name.module.scss'
const randomPick = (arr: string[]) => { // const randomPick = (arr: string[]) => {
const len = arr.length // const len = arr.length
const randomIndex = Math.floor(Math.random() * len) // const randomIndex = Math.floor(Math.random() * len)
return arr[randomIndex] // return arr[randomIndex]
} // }
const ModalName = ({ const ModalName = ({
isVisible, isVisible,
...@@ -26,39 +26,39 @@ const ModalName = ({ ...@@ -26,39 +26,39 @@ const ModalName = ({
onClose: () => void; onClose: () => void;
onFinish: () => void; onFinish: () => void;
}) => { }) => {
const [name, setName] = useState('小明') const [name, setName] = useState('')
const [generating, { setTrue, setFalse }] = useBoolean(false) // const [generating, { setTrue, setFalse }] = useBoolean(false)
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] }) // const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
const timerRef = useRef<NodeJS.Timer | null>(null) // const timerRef = useRef<NodeJS.Timer | null>(null)
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone) const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
const generateName = useCallback(() => { // const generateName = useCallback(() => {
const { noun, adj } = dataRef.current // const { noun, adj } = dataRef.current
const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('') // const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('')
setName(nam) // setName(nam)
}, []) // }, [])
const getNameWords = useCallback(async () => { // const getNameWords = useCallback(async () => {
const words = await getNickNameWords() // const words = await getNickNameWords()
dataRef.current = words // dataRef.current = words
generateName() // generateName()
}, [generateName]) // }, [generateName])
const handleGenerate = useCallback(() => { // const handleGenerate = useCallback(() => {
setTrue() // setTrue()
if (dataRef.current.adj.length < 1) { // if (dataRef.current.adj.length < 1) {
getNameWords() // getNameWords()
} else { // } else {
generateName() // generateName()
} // }
if (timerRef.current) { // if (timerRef.current) {
clearTimeout(timerRef.current) // clearTimeout(timerRef.current)
} // }
timerRef.current = setTimeout(() => { // timerRef.current = setTimeout(() => {
setFalse() // setFalse()
timerRef.current = null // timerRef.current = null
}, 1000) // }, 1000)
}, [generateName, setTrue, setFalse, getNameWords]) // }, [generateName, setTrue, setFalse, getNameWords])
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => { const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => {
...@@ -78,7 +78,7 @@ const ModalName = ({ ...@@ -78,7 +78,7 @@ const ModalName = ({
setLoading(false) setLoading(false)
console.log(err) console.log(err)
}) })
}, [onClose, updateNickNameAndPhone, onFinish, name, loading]) }, [updateNickNameAndPhone, onFinish, name, loading])
return ( return (
<RootPortal> <RootPortal>
...@@ -95,22 +95,23 @@ const ModalName = ({ ...@@ -95,22 +95,23 @@ const ModalName = ({
/> />
<View className={styles.title}>请问大侠,尊姓大名</View> <View className={styles.title}>请问大侠,尊姓大名</View>
<View className={styles.tips}> <View className={styles.tips}>
请输入您的角色名(7字以内) 请输入您的姓名(7字以内)
</View> </View>
<View className={styles.input}> <View className={styles.input}>
<Input <Input
className={styles.inputName} className={styles.inputName}
value={name as string} value={name as string}
placeholder="请输入"
onInput={(e) => setName(e.detail.value)} onInput={(e) => setName(e.detail.value)}
/> />
<Image {/* <Image
src={assetsGuide['touzi.png'].u} src={assetsGuide['touzi.png'].u}
className={classNames( className={classNames(
styles.inputIcon, styles.inputIcon,
generating && styles.generating generating && styles.generating
)} )}
onClick={handleGenerate} onClick={handleGenerate}
></Image> ></Image> */}
</View> </View>
<View className={styles.footer}> <View className={styles.footer}>
<Button <Button
......
...@@ -57,7 +57,7 @@ const Guide = (props: GuideProps) => { ...@@ -57,7 +57,7 @@ const Guide = (props: GuideProps) => {
// <Scene3 spriteTop={spriteTop} isCurrent={step === 2} onNext={(val: number) => { setStep(3); setTime(val) }} key={3} />, // <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} />, // <Scene4 spriteTop={spriteTop} isCurrent={step === 3} onNext={() => setStep(4)} time={time} key={4} />,
<Scene5 spriteTop={spriteTop} isCurrent={step === 2} onNext={() => setStep(3)} key={2} />, <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]) }, [onDone, spriteTop, step])
......
import { View, Input, Image, ScrollView, Button, CommonEventFunction, ButtonProps } from '@tarojs/components' import { View, Input, Image, ScrollView, Button, CommonEventFunction, ButtonProps } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { useState, useCallback, useEffect, useRef, useMemo } from 'react' import { useState, useCallback, useMemo, useEffect } from 'react'
import { useStoreActions } from '@/store/hooks' import { useStoreActions } from '@/store/hooks'
import { showToast } from '@tarojs/taro' import { showToast } from '@tarojs/taro'
import assets from '@/assets/oss/assets-guide' import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks' // import { useBoolean } from '@/hooks'
import { report, SkynetEvent } from '@/utils/skynet' 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 cs from './index.module.scss'
import styles from './scene-6.module.scss' import styles from './scene-6.module.scss'
type Scene6Props = { type Scene6Props = {
spriteTop: number; spriteTop: number;
onNext: () => void; onNext: () => void;
isCurrent: boolean;
} }
const randomPick = (arr: string[]) => { // const randomPick = (arr: string[]) => {
const len = arr.length // const len = arr.length
const randomIndex = Math.floor(Math.random() * len) // const randomIndex = Math.floor(Math.random() * len)
return arr[randomIndex] // return arr[randomIndex]
} // }
const Scene6 = (props: Scene6Props) => { const Scene6 = (props: Scene6Props) => {
const { spriteTop, onNext } = props const { spriteTop, onNext, isCurrent } = props
const [name, setName] = useState('') const [name, setName] = useState('')
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] }) // const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
const timerRef = useRef<NodeJS.Timer | null>(null) // const timerRef = useRef<NodeJS.Timer | null>(null)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [isGenerating, genActions] = useBoolean(false) const [focus, setFocus] = useState(false)
// const [isGenerating, genActions] = useBoolean(false)
const genName = useCallback(() => { // const genName = useCallback(() => {
const { noun, adj } = dataRef.current // const { noun, adj } = dataRef.current
const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('') // const nam = [randomPick(adj), randomPick(noun)].filter(Boolean).join('')
setName(nam) // 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) const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
...@@ -56,31 +72,31 @@ const Scene6 = (props: Scene6Props) => { ...@@ -56,31 +72,31 @@ const Scene6 = (props: Scene6Props) => {
}) })
}, [updateNickNameAndPhone, onNext, name, loading]) }, [updateNickNameAndPhone, onNext, name, loading])
const _getNickNameWords = useCallback(async () => { // const _getNickNameWords = useCallback(async () => {
const words = await getNickNameWords() // const words = await getNickNameWords()
dataRef.current = words // dataRef.current = words
genName() // genName()
}, [genName]) // }, [genName])
const handleGen = useCallback(() => { // const handleGen = useCallback(() => {
genActions.setTrue() // genActions.setTrue()
if (dataRef.current.adj.length < 1) { // if (dataRef.current.adj.length < 1) {
_getNickNameWords() // _getNickNameWords()
} else { // } else {
genName() // genName()
} // }
if (timerRef.current) { // if (timerRef.current) {
clearTimeout(timerRef.current) // clearTimeout(timerRef.current)
} // }
timerRef.current = setTimeout(() => { // timerRef.current = setTimeout(() => {
genActions.setFalse() // genActions.setFalse()
timerRef.current = null // timerRef.current = null
}, 1000) // }, 1000)
}, [genName, genActions, _getNickNameWords]) // }, [genName, genActions, _getNickNameWords])
useEffect(() => { // useEffect(() => {
_getNickNameWords() // _getNickNameWords()
}, [_getNickNameWords]) // }, [_getNickNameWords])
const handleInput = useCallback((e) => { const handleInput = useCallback((e) => {
setName(e.detail.value) setName(e.detail.value)
...@@ -104,25 +120,25 @@ const Scene6 = (props: Scene6Props) => { ...@@ -104,25 +120,25 @@ const Scene6 = (props: Scene6Props) => {
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}> <View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src={assets['cat-5.png'].u} className={cs.cat} /> <Image src={assets['cat-5.png'].u} className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}> <View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<View>请输入你的角色名(7字以内)</View> <View>请填写你的真实姓名</View>
<View className={styles.tips}>*仅用于排行榜展示哦</View> <View className={styles.tips}>*将用于最后的结果与奖品发放哦</View>
</View> </View>
</View> </View>
<View className={styles.top}></View> <View className={styles.top}></View>
<View> <View>
<View className={styles.input}> <View className={styles.input}>
<View className={styles.input_item}> <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> </View>
<Image {/* <Image
src={assets['touzi.png'].u} src={assets['touzi.png'].u}
className={classNames(styles.input_icon, isGenerating && styles.is_gen)} className={classNames(styles.input_icon, isGenerating && styles.is_gen)}
onClick={handleGen} onClick={handleGen}
id="main_guide_6_gen_name" id="main_guide_6_gen_name"
></Image> ></Image> */}
</View> </View>
<View className={styles.input_tip}> <View className={styles.input_tip}>
* 可点击右侧按钮随机生成昵称 {/* * 可点击右侧按钮随机生成昵称 */}
</View> </View>
</View> </View>
<View className={styles.bottom}></View> <View className={styles.bottom}></View>
...@@ -134,15 +150,16 @@ const Scene6 = (props: Scene6Props) => { ...@@ -134,15 +150,16 @@ const Scene6 = (props: Scene6Props) => {
<View className={styles.btn_tip}>同时为保存你的闯关数据,请进行授权</View> <View className={styles.btn_tip}>同时为保存你的闯关数据,请进行授权</View>
{disabled {disabled
? ( ? (
<View <View
className={classNames(cs.btn, cs.disabled)} className={classNames(cs.btn, cs.disabled)}
onClick={handleClick} onClick={handleClick}
>确定</View> >确定</View>
) )
: ( : (
<Button <Button
openType="getPhoneNumber" openType="getPhoneNumber"
onGetPhoneNumber={handleGetPhone} onGetPhoneNumber={handleGetPhone}
onAgreePrivacyAuthorization={console.log}
className={cs.btn} className={cs.btn}
loading={loading} loading={loading}
disabled={loading} disabled={loading}
......
...@@ -33,7 +33,7 @@ const MainHeader = () => { ...@@ -33,7 +33,7 @@ const MainHeader = () => {
<Image src={assetsMainNext['page-head-2.png'].u} mode="widthFix" className={styles.bg}></Image> <Image src={assetsMainNext['page-head-2.png'].u} mode="widthFix" className={styles.bg}></Image>
<View className={styles.chapterContent}> <View className={styles.chapterContent}>
<View className={styles.chapterName}> <View className={styles.chapterName}>
地心历险记 计算小勇士
</View> </View>
</View> </View>
{!isAddDeskTopGuideComplete && ( {!isAddDeskTopGuideComplete && (
......
import { PropsWithChildren } from 'react' import { PropsWithChildren } from 'react'
import { View, RootPortal, Image, Text } from '@tarojs/components' import { View, RootPortal, Image, Text } from '@tarojs/components'
import { switchTab } from '@tarojs/taro' import { redirectTo } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import styles from './answer-card-modal.module.scss' import styles from './answer-card-modal.module.scss'
...@@ -23,8 +23,8 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => { ...@@ -23,8 +23,8 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => {
<View className={styles.tips}>可通过以下途径获得哦</View> <View className={styles.tips}>可通过以下途径获得哦</View>
<View className={styles.footer}> <View className={styles.footer}>
{children} {children}
<View className={styles.studyTribe} onClick={() => switchTab({ url: '/pages/group/index' })}> <View className={styles.studyTribe} onClick={() => redirectTo({ url: '/pages/battles/index' })}>
<Text>建设学习部落,得更多答题卡</Text> <Text>发起更多PK,赢水晶</Text>
</View> </View>
</View> </View>
</View> </View>
......
...@@ -3,6 +3,7 @@ export default definePageConfig({ ...@@ -3,6 +3,7 @@ export default definePageConfig({
navigationBarTitleText: 'pk-math', navigationBarTitleText: 'pk-math',
navigationStyle: 'custom', navigationStyle: 'custom',
usingComponents: { usingComponents: {
'game-rank': '@/native-components/rank/index' 'game-rank': '@/native-components/rank/index',
'game-pk-rank': '@/native-components/pk-rank/index'
} }
}) })
...@@ -5,13 +5,11 @@ import classNames from 'classnames' ...@@ -5,13 +5,11 @@ import classNames from 'classnames'
import Button from '@/components/Button' import Button from '@/components/Button'
import Loading from '@/components/Loading' import Loading from '@/components/Loading'
import ShareView from '@/pages/group/components/share-view'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean, useRequest, useShare } from '@/hooks' import { useBoolean, useRequest, useShare } from '@/hooks'
import { pointToCard } from '@/api/account' import { pointToCard } from '@/api/account'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import assetsGroup from '@/assets/oss/assets-group'
import { palyAudio } from '@/utils/play-audio' import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio' import audio from '@/assets/oss/assets-audio'
import { EyeProtectionView } from '@/components' import { EyeProtectionView } from '@/components'
...@@ -20,10 +18,9 @@ import tutorialAssets from '@/assets/oss/assets-tutorial' ...@@ -20,10 +18,9 @@ import tutorialAssets from '@/assets/oss/assets-tutorial'
import Tabs, { type TabItem } from './components/tabs' 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 PkGuide from './guide/pk/scene-1'
import AnswerCardModal from './components/answer-card-modal' import AnswerCardModal from './components/answer-card-modal'
import PkGuideScene from './guide/pk/scene' import PkGuideScene from './guide/pk/scene'
import { renderTribePage, RankList } from './render' import { RankList, PkRankList } from './render'
import styles from './index.module.scss' import styles from './index.module.scss'
...@@ -61,11 +58,9 @@ const Prepare = () => { ...@@ -61,11 +58,9 @@ const Prepare = () => {
) )
}, },
{ {
label: '学习部落排行榜', label: 'PK排行榜',
children: ( children: (
<View className={styles.tribe}> <PkRankList list={stageDetail?.pkRanks || []}></PkRankList>
{renderTribePage(stageDetail?.groupRanks || [], tribeInfo?.groupNo)}
</View>
) )
} }
] ]
...@@ -259,16 +254,12 @@ const Prepare = () => { ...@@ -259,16 +254,12 @@ const Prepare = () => {
</View> </View>
<View className={styles.footer_bar}> <View className={styles.footer_bar}>
{currentTab === 1 && tribeInfo && tribeInfo.id && <ShareView> {/* {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> */}
<View className={styles.tribe_share}> <View className={styles.tribe_share}>
<Image style={{ width: 32, height: 32 }} src={assetsGroup['invite-small.png'].u} /> <Image style={{ width: 32, height: 32 }} src={assetsGroup['invite-small.png'].u} />
<Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text> <Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text>
</View> </View>
</ShareView>} </ShareView>} */}
{!isSubmit ? renderFisrtActions() : renderAgainActions()} {!isSubmit ? renderFisrtActions() : renderAgainActions()}
</View> </View>
......
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { switchTab, useReachBottom, getCurrentInstance } from '@tarojs/taro' import { switchTab, useReachBottom, getCurrentInstance } from '@tarojs/taro'
import { useRef, useMemo } from 'react' 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 assets from '@/assets/oss/assets-prepare'
import styles from './index.module.scss' import styles from './index.module.scss'
...@@ -27,6 +27,27 @@ export function RankList (props: RankListProps) { ...@@ -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 = () => ( const renderEmptyTribe = () => (
<View className={styles.tribe_empty}> <View className={styles.tribe_empty}>
<Image className={styles.tribe_empty_logo} src={assets['tribe.png'].u} mode="widthFix" /> <Image className={styles.tribe_empty_logo} src={assets['tribe.png'].u} mode="widthFix" />
......
...@@ -69,10 +69,11 @@ const userModel: UserModel = { ...@@ -69,10 +69,11 @@ const userModel: UserModel = {
updateNickNameAndPhone: thunk(async (actions, payload, helpers) => { updateNickNameAndPhone: thunk(async (actions, payload, helpers) => {
try { try {
const defaultUserInfo = { city: '成都', grade: '二年级' }
const fns: Promise<any>[] = [ const fns: Promise<any>[] = [
] ]
if (payload.name) { if (payload.name) {
fns.push(updateUserInfo({ nickName: payload.name })) fns.push(updateUserInfo({ nickName: payload.name, ...defaultUserInfo }))
} }
let authPhone let authPhone
...@@ -93,7 +94,7 @@ const userModel: UserModel = { ...@@ -93,7 +94,7 @@ const userModel: UserModel = {
} }
if (payload.name) { if (payload.name) {
current = { ...current, nickName: payload.name } current = { ...current, nickName: payload.name, ...defaultUserInfo }
} }
updateStorage(StorageKeys.userInfo, current) updateStorage(StorageKeys.userInfo, current)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment