Commit b7062136 authored by m's avatar m

feat: 优化

parents d2a2b83c 14a7dd47
{
"A和B通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav",
"ossName": "/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav"
},
"S通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav",
"ossName": "/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav"
},
"最后10秒 一战到底.mp3": {
"u": "https://cdn.jkwljy.com/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3",
"ossName": "/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3"
},
"点领取水晶部落.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav",
"ossName": "/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav"
},
"蹦蹦top出现首页.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav",
"ossName": "/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav"
},
"部门排行榜出现.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav",
"ossName": "/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav"
},
"闯关失败.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav",
"ossName": "/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav"
},
"回答正确--一战到底.wav": {
"u": "https://cdn.jkwljy.com/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav",
"ossName": "/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav"
},
"错误.wav": {
"u": "https://cdn.jkwljy.com/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav",
"ossName": "/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav"
}
}
{
"noun": ["白菜", "西瓜", "萝卜"],
"adj": ["快乐的", "英勇的", "奋斗的"]
}
{
"ad": ["你的"],
"none": ["我的"]
}
...@@ -78,7 +78,12 @@ async function uploadFolder ({ fileList, outputFileName, cachedOutputFileName }) ...@@ -78,7 +78,12 @@ async function uploadFolder ({ fileList, outputFileName, cachedOutputFileName })
} }
const resultList = fileList.map(item => { const resultList = fileList.map(item => {
const dimensions = sizeOf(item.filePath) let dimensions = null
try {
dimensions = sizeOf(item.filePath)
} catch (err) {
console.log(err)
}
const ossName = getFileName(item.relativePath, item.filePath, dimensions) const ossName = getFileName(item.relativePath, item.filePath, dimensions)
return { return {
ossName, ossName,
...@@ -141,8 +146,8 @@ function uploadFile ({ fileName, filePath, ContentType, ossName, dimensions }) { ...@@ -141,8 +146,8 @@ function uploadFile ({ fileName, filePath, ContentType, ossName, dimensions }) {
resolve({ resolve({
fileName, fileName,
filePath, filePath,
width: dimensions.width, width: dimensions?.width,
height: dimensions.height, height: dimensions?.height,
ossName, ossName,
// originPath, // originPath,
url: `https://${data.Location}`.replace(`${config.Bucket}.cos.ap-chengdu.myqcloud.com`, 'cdn.jkwljy.com') url: `https://${data.Location}`.replace(`${config.Bucket}.cos.ap-chengdu.myqcloud.com`, 'cdn.jkwljy.com')
...@@ -161,5 +166,13 @@ function getFileName (relativePath, absolutPath, dimensions) { ...@@ -161,5 +166,13 @@ function getFileName (relativePath, absolutPath, dimensions) {
.update(fs.readFileSync(absolutPath, { encoding: 'binary' })) .update(fs.readFileSync(absolutPath, { encoding: 'binary' }))
.digest() .digest()
const key = bs58.encode(buffer) const key = bs58.encode(buffer)
if (dimensions) {
return `/pk-math/${key}/${dimensions.width}x${dimensions.height}` return `/pk-math/${key}/${dimensions.width}x${dimensions.height}`
}
const dot = absolutPath.lastIndexOf('.')
if (dot < -1) {
throw Error('File name is not right!')
}
const suffix = absolutPath.substr(dot + 1)
return `/pk-math/${key}.${suffix}`
} }
const path = require('path')
const fastglob = require('fast-glob')
const COS = require('cos-nodejs-sdk-v5')
const rootFolderPath = path.resolve(__dirname, '../assets/setting')
const config = {
SecretId: 'AKIDJG6HEyXfdP5dw05OhldO2RaV9Xgbe6Wh', // 'AKIDmMhgQGAJbkjZ8bfpa5LNAoJfuvkJJuwh',
SecretKey: 'Kdg05SKVRb4qMnUv51nRwCHAAuOMULzM', // 'gCTs8h8btRo00mIcgYBZh16zd7YpvqRn',
Bucket: 'frontend-bkt-1257124244' // 'test-1257124244'
}
const cos = new COS({
SecretId: config.SecretId,
SecretKey: config.SecretKey
})
const folderList = fastglob
.sync('**', { onlyFiles: false, deep: 1, cwd: rootFolderPath })
if (folderList.length < 1) {
console.log('empty folder', rootFolderPath)
}
folderList.forEach(item => {
return uploadFile({ filePath: path.resolve(rootFolderPath, item), ossName: `/pk-math/setting/${item}` })
})
function uploadFile ({ filePath, ossName }) {
return new Promise((resolve, reject) => {
cos.sliceUploadFile({
Bucket: config.Bucket,
Region: 'ap-chengdu',
Key: ossName,
ContentType: 'application/json',
CacheControl: 'max-age=0',
FilePath: filePath,
}, function (err, data) {
if (err) {
reject(err)
} else {
console.log(`https://${data.Location}`.replace(`${config.Bucket}.cos.ap-chengdu.myqcloud.com`, 'cdn.jkwljy.com'))
}
})
})
}
import { request, requestAfterSilentLogin } from '@/utils/request' import { request, requestAfterSilentLogin } from '@/utils/request'
import { request as requesNative } from '@tarojs/taro'
import type { UserInfo } from '@/types' import type { UserInfo } from '@/types'
type LoginResult = UserInfo type LoginResult = UserInfo
...@@ -63,3 +64,19 @@ export function updateUserPhone (code: string) { ...@@ -63,3 +64,19 @@ export function updateUserPhone (code: string) {
data: { code, userId: userInfo?.userId } data: { code, userId: userInfo?.userId }
})) }))
} }
export type NickNameWord = {
noun: string[];
adj: string[];
}
const NickNameUrl = 'https://cdn.jkwljy.com/pk-math/setting/nickname-words.json'
export function getNickNameWords () {
return requesNative<NickNameWord>({
method: 'GET',
url: `${NickNameUrl}?d=${Date.now()}`,
header: { 'Cache-Control': 'no-cache' },
timeout: 800
}).then(({ data }) => data)
}
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"A和B通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav"
},
"S通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav"
},
"最后10秒 一战到底.mp3": {
"u": "https://cdn.jkwljy.com/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3"
},
"点领取水晶部落.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav"
},
"蹦蹦top出现首页.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav"
},
"部门排行榜出现.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav"
},
"闯关失败.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav"
},
"回答正确--一战到底.wav": {
"u": "https://cdn.jkwljy.com/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav"
},
"错误.wav": {
"u": "https://cdn.jkwljy.com/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav"
}
} as const
import Taro from '@tarojs/taro' import { request } from '@tarojs/taro'
const RE = /^https?:\/\// const RE = /^https?:\/\//
const buildVersion = String(process.env.TARO_BUILD_VERSION) || '\0_not_find' const buildVersion = String(process.env.TARO_BUILD_VERSION) || '\0_not_find'
...@@ -34,7 +34,7 @@ export const getBaseUrl = () => { ...@@ -34,7 +34,7 @@ export const getBaseUrl = () => {
// 开发阶段不使用服务端配置 // 开发阶段不使用服务端配置
if (process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com') { if (process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com') {
console.log('init base url from', WeappConfigUrl) console.log('init base url from', WeappConfigUrl)
requestInstance = Taro.request<ServerConfig>({ requestInstance = request<ServerConfig>({
method: 'GET', method: 'GET',
url: WeappConfigUrl, url: WeappConfigUrl,
header: { 'Cache-Control': 'no-cache' }, header: { 'Cache-Control': 'no-cache' },
......
import { View, Image } from '@tarojs/components' import { View, Image } from '@tarojs/components'
import { useMemo } from 'react' import { useMemo, useEffect } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro' import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import assets from '@/assets/oss/assets-complete' import assets from '@/assets/oss/assets-complete'
import { useFormatTick } from '@/hooks/use-format-tick' import { useFormatTick } from '@/hooks/use-format-tick'
import { StageLevel } from '@/api' import { StageLevel } from '@/api'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
import styles from './complete-head.module.scss' import styles from './complete-head.module.scss'
...@@ -25,6 +27,17 @@ const getLevelBigBg = (s?: StageLevel | null): string => { ...@@ -25,6 +27,17 @@ const getLevelBigBg = (s?: StageLevel | null): string => {
return assets['level-big-fail.png'].u return assets['level-big-fail.png'].u
} }
const getAudioSrc = (s?: StageLevel | null) => {
if (!s) {
return audio['闯关失败.wav'].u
}
if (s === StageLevel.S) {
return audio['S通关.wav'].u
}
return audio['A和B通关.wav'].u
}
const getLevelText = (s?: StageLevel | null) => { const getLevelText = (s?: StageLevel | null) => {
switch (s) { switch (s) {
case StageLevel.S: { case StageLevel.S: {
...@@ -76,6 +89,12 @@ const GameCompleteHead = () => { ...@@ -76,6 +89,12 @@ const GameCompleteHead = () => {
const time = useFormatTick((gameResult?.resultTime ?? 0) * 1000) const time = useFormatTick((gameResult?.resultTime ?? 0) * 1000)
const au = useMemo(() => getAudioSrc(gameResult?.level), [gameResult?.level])
useEffect(() => {
palyAudio(au)
}, [au])
const bonus = useMemo(() => { const bonus = useMemo(() => {
if (!gameResult) return 0 if (!gameResult) return 0
return gameResult?.gearReward + gameResult?.levelReward + gameResult?.upGearReward return gameResult?.gearReward + gameResult?.levelReward + gameResult?.upGearReward
......
...@@ -5,6 +5,8 @@ import classNames from 'classnames' ...@@ -5,6 +5,8 @@ import classNames from 'classnames'
import { useBoolean } from '@/hooks' import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { type StageDetail, StageType } from '@/api' import { type StageDetail, StageType } from '@/api'
import audio from '@/assets/oss/assets-audio'
import { palyAudio } from '@/utils/play-audio'
import styles from './count-up.module.scss' import styles from './count-up.module.scss'
...@@ -74,6 +76,11 @@ const CountUp = (props: CountUpProps) => { ...@@ -74,6 +76,11 @@ const CountUp = (props: CountUpProps) => {
} }
}, [submit, isOneStop]) }, [submit, isOneStop])
const handleExceed = useCallback(() => {
exceedActions.setTrue()
palyAudio(audio['最后10秒 一战到底.mp3'].u)
}, [exceedActions])
return ( return (
<View className={classNames(styles.count, isOneStop && styles.is_stop)}> <View className={classNames(styles.count, isOneStop && styles.is_stop)}>
<View className={styles.process}> <View className={styles.process}>
...@@ -94,8 +101,8 @@ const CountUp = (props: CountUpProps) => { ...@@ -94,8 +101,8 @@ const CountUp = (props: CountUpProps) => {
: (<Image src={require('../assets/count-time.png')} className={styles.icon}></Image>) : (<Image src={require('../assets/count-time.png')} className={styles.icon}></Image>)
} }
<count-up-time <count-up-time
exceedTime={20} exceedTime={10}
onExceed={exceedActions.setTrue} onExceed={handleExceed}
maxValue={stageDetail.bTime} maxValue={stageDetail.bTime}
startValue={startTick} startValue={startTick}
isDown={isOneStop} isDown={isOneStop}
......
...@@ -2,6 +2,8 @@ import { action, Action, computed, Computed, Thunk, thunk } from 'easy-peasy' ...@@ -2,6 +2,8 @@ import { action, Action, computed, Computed, Thunk, thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model' import { AppStoreModel } from '@/store/store-model'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, resumeGame } from '@/api' import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, resumeGame } from '@/api'
import { showLoading, hideLoading, showModal, redirectTo, vibrateShort, getCurrentInstance } from '@tarojs/taro' import { showLoading, hideLoading, showModal, redirectTo, vibrateShort, getCurrentInstance } from '@tarojs/taro'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
import { import {
QuestionType, QuestionType,
QuestionAnswer, QuestionAnswer,
...@@ -174,10 +176,12 @@ const gameModel: GameModel = { ...@@ -174,10 +176,12 @@ const gameModel: GameModel = {
const { canGoNext, currentQuestionIndex, questionList, stageDetail, currentQuestion, isReborn } = helpers.getState() const { canGoNext, currentQuestionIndex, questionList, stageDetail, currentQuestion, isReborn } = helpers.getState()
if (!canGoNext) return if (!canGoNext) return
if (stageDetail?.type === StageType.OneStop && currentQuestion && !determinQuestion(currentQuestion)) { if (stageDetail?.type === StageType.OneStop && currentQuestion) {
if (!determinQuestion(currentQuestion)) {
const cardNum = helpers.getStoreState().userModel.cardNum const cardNum = helpers.getStoreState().userModel.cardNum
/** 没有复活过并且有答题卡 */ /** 没有复活过并且有答题卡 */
if (!isReborn && cardNum > 0) { if (!isReborn && cardNum > 0) {
palyAudio(audio['错误.wav'].u)
stopCounter() stopCounter()
actions.updateState({ modalContinueVisible: true, isReborn: true }) actions.updateState({ modalContinueVisible: true, isReborn: true })
} else { } else {
...@@ -185,6 +189,10 @@ const gameModel: GameModel = { ...@@ -185,6 +189,10 @@ const gameModel: GameModel = {
} }
return return
} }
if (currentQuestionIndex > 0 && currentQuestionIndex % 3 === 0) {
palyAudio(audio['回答正确--一战到底.wav'].u)
}
}
if (questionList.length === currentQuestionIndex + 1) { if (questionList.length === currentQuestionIndex + 1) {
actions.submit() actions.submit()
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
.avatar { .avatar {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
margin-right: 8PX;
.name { .name {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
......
import { View, Text, Image } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import styles from './chapter.module.scss' import styles from './chapter.module.scss'
...@@ -9,11 +9,11 @@ const MainHeader = () => { ...@@ -9,11 +9,11 @@ const MainHeader = () => {
<View className={styles.chapterName}> <View className={styles.chapterName}>
<Text>第 1 单元</Text> <Text>第 1 单元</Text>
</View> </View>
<View className={styles.chapterTips}><Text>单元内容名称单元内容名称单元内容名称单元内容名称</Text></View> <View className={styles.chapterTips}><Text>二年级下·上半学期</Text></View>
</View> </View>
<View className={styles.help} hoverClass={styles['is-hover-btn']}> {/* <View className={styles.help} hoverClass={styles['is-hover-btn']}>
<Image src={require('../assets/help.png')} className={styles.icon}></Image> <Image src={require('../assets/help.png')} className={styles.icon}></Image>
</View> </View> */}
</View> </View>
) )
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
.avatar { .avatar {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
margin-right: 8PX;
.name { .name {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
......
...@@ -55,9 +55,12 @@ const MainPage = () => { ...@@ -55,9 +55,12 @@ const MainPage = () => {
scrollToCurrent(() => { scrollToCurrent(() => {
updateReady(true) updateReady(true)
}) })
setTimeout(() => {
updateReady(true)
}, 300)
} }
}) })
}, 500) }, 200)
}) })
} }
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady]) }, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady])
......
...@@ -2,7 +2,12 @@ import { Image } from '@tarojs/components' ...@@ -2,7 +2,12 @@ import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo, useState } from 'react' import { useEffect, useRef, useMemo, useState } from 'react'
import assets from '@/assets/oss/assets-round' import assets from '@/assets/oss/assets-round'
import { useFocus } from '@/hooks' import { useFocus } from '@/hooks'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect, IntersectionObserver, nextTick } from '@tarojs/taro' import {
usePageScroll, createIntersectionObserver, getCurrentInstance,
getMenuButtonBoundingClientRect, IntersectionObserver, nextTick
} from '@tarojs/taro'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
type StageTagProps = { type StageTagProps = {
url?: string; url?: string;
...@@ -47,6 +52,7 @@ const StageTag = (props: StageTagProps) => { ...@@ -47,6 +52,7 @@ const StageTag = (props: StageTagProps) => {
clearTimeout(timer) clearTimeout(timer)
} }
timer = setTimeout(() => { timer = setTimeout(() => {
palyAudio(audio['蹦蹦top出现首页.wav'].u)
setIsAnimated(true) setIsAnimated(true)
page?.animate?.(`#${uid}`, [ page?.animate?.(`#${uid}`, [
{ opacity: 0, translateY: 50, scale: [1, 1] }, { opacity: 0, translateY: 50, scale: [1, 1] },
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.roundName { .roundName {
// position: absolute; // position: absolute;
// bottom: -48px; // bottom: -48px;
margin: 8px -20px 0 -20px; margin: 8px -160px 0 -160px;
text-align: center; text-align: center;
font-size: 28px; font-size: 28px;
font-weight: 500; font-weight: 500;
......
...@@ -91,7 +91,7 @@ const Scene1 = ({ onNext }: Scene1Props) => { ...@@ -91,7 +91,7 @@ const Scene1 = ({ onNext }: Scene1Props) => {
<View className={cs.footer_inner}> <View className={cs.footer_inner}>
<View <View
className={classNames(cs.btn, !isActive && cs.disabled)} className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''} hoverClass={isActive ? cs.is_hover : ''}
onClick={handleClick} onClick={handleClick}
>继续</View> >继续</View>
</View> </View>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168); background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168);
background-size: 100% 100%; background-size: 100% 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 28px 28px 28px 56px; padding: 28px 20px 28px 50px;
font-size: 40px; font-size: 40px;
font-weight: 500; font-weight: 500;
...@@ -19,6 +19,16 @@ ...@@ -19,6 +19,16 @@
color: #1786F7; color: #1786F7;
} }
.select {
background: #F0F2F9;
border-radius: 24px;
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
padding: 2px 12px;
}
.option { .option {
bottom: -64px; bottom: -64px;
position: absolute; position: absolute;
......
...@@ -25,7 +25,7 @@ const Scene2 = (props: Scene2Props) => { ...@@ -25,7 +25,7 @@ const Scene2 = (props: Scene2Props) => {
<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="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} /> <Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}> <View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<Text>请问同学有哪些<Text className={styles.em}>计算问题</Text>需要提高呢?</Text> <Text>请问同学有哪些<Text className={styles.em}>计算问题</Text>需要提高呢?<Text className={styles.select}>多选</Text></Text>
</View> </View>
<View className={styles.option}> <View className={styles.option}>
...@@ -56,7 +56,7 @@ const Scene2 = (props: Scene2Props) => { ...@@ -56,7 +56,7 @@ const Scene2 = (props: Scene2Props) => {
<View className={cs.footer_inner}> <View className={cs.footer_inner}>
<View <View
className={classNames(cs.btn, !isActive && cs.disabled)} className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''} hoverClass={isActive ? cs.is_hover : ''}
onClick={onNext} onClick={onNext}
>继续</View> >继续</View>
</View> </View>
......
import { View, Text, Image, ScrollView } from '@tarojs/components' import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { useFormatTick } from '@/hooks' import { useFormatTick } from '@/hooks'
import { useMemo } from 'react'
import assets from '@/assets/oss/assets-guide' import assets from '@/assets/oss/assets-guide'
import cs from './index.module.scss' import cs from './index.module.scss'
...@@ -12,9 +13,45 @@ type Scene4Props = { ...@@ -12,9 +13,45 @@ type Scene4Props = {
onNext: () => void; onNext: () => void;
} }
function getIcon (level: 'S' | 'A' | 'B') {
switch (level) {
case 'S': {
return [assets['s.png'].u, assets['top10.png'].u]
}
case 'A': {
return [assets['a.png'].u, assets['top20.png'].u]
}
case 'B': {
return [assets['b.png'].u, assets['top30.png'].u]
}
}
}
function getLevelName (level: 'S' | 'A' | 'B') {
switch (level) {
case 'S': {
return '十'
}
case 'A': {
return '二十'
}
case 'B': {
return '三十'
}
}
}
const Scene4 = (props: Scene4Props) => { const Scene4 = (props: Scene4Props) => {
const { spriteTop, onNext, time } = props const { spriteTop, onNext, time } = props
const level = useMemo(() => {
if (time <= 10) return 'S'
if (time <= 15) return 'A'
return 'B'
}, [time])
const icons = useMemo(() => getIcon(level), [level])
const isActive = true const isActive = true
const timeFmt = useFormatTick(time * 1000) const timeFmt = useFormatTick(time * 1000)
...@@ -42,18 +79,18 @@ const Scene4 = (props: Scene4Props) => { ...@@ -42,18 +79,18 @@ const Scene4 = (props: Scene4Props) => {
<View> <View>
<View className={styles.title}>达标等级:</View> <View className={styles.title}>达标等级:</View>
<View className={styles.card}> <View className={styles.card}>
<Image src={assets['s.png'].u} className={styles.icon}></Image> <Image src={icons[0]} className={styles.icon}></Image>
<View className={styles.text}>以本次练习的水准,继续答对15题,那你就达到<Text className={styles.glod}>B级实力</Text>了</View> <View className={styles.text}>以本次练习的水准,继续答对15题,那你就达到<Text className={styles.glod}>{level}级实力</Text>了</View>
</View> </View>
<View className={styles.tips}>* 共有 B → A → S 三个水准</View> <View className={styles.tips}>* 共有 B → A → S 三个水准</View>
</View> </View>
<View> <View>
<View className={styles.title}>排行成就:</View> <View className={styles.title}>排行成就:</View>
<View className={styles.card}> <View className={styles.card}>
<Image src={assets['top10.png'].u} className={styles.icon}></Image> <Image src={icons[1]} className={styles.icon}></Image>
<View className={styles.text}> <View className={styles.text}>
<View>本次练习非常优秀哦, </View> <View>本次练习非常优秀哦, </View>
<View>排在所有同学前百分<Text className={styles.glod}>前百分之三十</Text></View> <View>排在所有同学前百分<Text className={styles.glod}>前百分之{getLevelName(level)}</Text></View>
</View> </View>
</View> </View>
<View className={styles.tips}>* 共有 TOP30% → TOP20% → TOP10% 三个成就</View> <View className={styles.tips}>* 共有 TOP30% → TOP20% → TOP10% 三个成就</View>
...@@ -65,7 +102,7 @@ const Scene4 = (props: Scene4Props) => { ...@@ -65,7 +102,7 @@ const Scene4 = (props: Scene4Props) => {
<View className={styles.btn_tips}>如果每个技能达到S水准,那面对考试,就胜券在握了</View> <View className={styles.btn_tips}>如果每个技能达到S水准,那面对考试,就胜券在握了</View>
<View <View
className={classNames(cs.btn, !isActive && cs.disabled)} className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''} hoverClass={isActive ? cs.is_hover : ''}
onClick={onNext} onClick={onNext}
>继续</View> >继续</View>
</View> </View>
......
...@@ -41,24 +41,30 @@ const Scene5 = (props: Scene5Props) => { ...@@ -41,24 +41,30 @@ const Scene5 = (props: Scene5Props) => {
<View> <View>
<View className={styles.tips3}>帮助你<Text className={styles.gold}>从易到难</Text>,逐个掌握。</View> <View className={styles.tips3}>帮助你<Text className={styles.gold}>从易到难</Text>,逐个掌握。</View>
<View className={styles.card_wrap}> <View className={styles.card_wrap}>
{active1 && (
<View className={styles.card}> <View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} /> <Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-1.png'].u} className={styles.card_icon}></Image> <Image src={assets['book-1.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View> <View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View> <View className={styles.tip2}>每学期近30类</View>
</View> </View>
)}
{active2 && (
<View className={styles.card}> <View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} /> <Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-2.png'].u} className={styles.card_icon}></Image> <Image src={assets['book-2.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View> <View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View> <View className={styles.tip2}>每学期近30类</View>
</View> </View>
)}
{active3 && (
<View className={styles.card}> <View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} /> <Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-3.png'].u} className={styles.card_icon}></Image> <Image src={assets['book-3.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View> <View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View> <View className={styles.tip2}>每学期近30类</View>
</View> </View>
)}
</View> </View>
</View> </View>
)} )}
...@@ -85,7 +91,7 @@ const Scene5 = (props: Scene5Props) => { ...@@ -85,7 +91,7 @@ const Scene5 = (props: Scene5Props) => {
<View className={cs.footer_inner}> <View className={cs.footer_inner}>
<View <View
className={classNames(cs.btn, !isActive && cs.disabled)} className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''} hoverClass={isActive ? cs.is_hover : ''}
onClick={handleClick} onClick={handleClick}
>{isSubmit ? '开启我的快乐提升之旅' : '继续'}</View> >{isSubmit ? '开启我的快乐提升之旅' : '继续'}</View>
</View> </View>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
font-size: 40px; font-size: 40px;
font-weight: 500; font-weight: 500;
color: rgba(70,81,100,0.8); color: rgba(70, 81, 100, 0.8);
line-height: 56px; line-height: 56px;
} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.tips { .tips {
font-size: 28px; font-size: 28px;
font-weight: 500; font-weight: 500;
color: rgba(70,81,100,0.5); color: rgba(70, 81, 100, 0.5);
line-height: 40px; line-height: 40px;
margin-top: 8px; margin-top: 8px;
} }
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
display: flex; display: flex;
font-size: 28px; font-size: 28px;
font-weight: 600; font-weight: 600;
color: rgba(70,81,100,0.5); color: rgba(70, 81, 100, 0.5);
line-height: 40px; line-height: 40px;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -81,12 +81,41 @@ ...@@ -81,12 +81,41 @@
display: block; display: block;
} }
.is_gen {
animation-name: rotate_3d;
animation-duration: .3s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
@keyframes rotate_3d {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(90deg);
}
50% {
transform: rotate(180deg);
}
75% {
transform: rotate(270deg);
}
100% {
transform: rotate(360deg);
}
}
.btn_tip { .btn_tip {
font-size: 28px; font-size: 28px;
font-weight: 600; font-weight: 600;
color: rgba(70,81,100,0.5); color: rgba(70, 81, 100, 0.5);
line-height: 40px; line-height: 40px;
text-align: center; text-align: center;
padding-bottom: 32px; padding-bottom: 32px;
} }
import { View, Text, Image, ScrollView, Button, CommonEventFunction, ButtonProps } from '@tarojs/components' import { View, Text, Image, ScrollView, Button, CommonEventFunction, ButtonProps } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { useState, useCallback } from 'react' import { useState, useCallback, useEffect, useRef } from 'react'
import { useStoreActions } from '@/store/hooks' import { useStoreActions } from '@/store/hooks'
import assets from '@/assets/oss/assets-guide' import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks'
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'
...@@ -11,9 +13,23 @@ type Scene6Props = { ...@@ -11,9 +13,23 @@ type Scene6Props = {
onNext: () => void; onNext: () => void;
} }
const randomPick = (arr: string[]) => {
const len = arr.length
const randomIndex = Math.floor(Math.random() * len)
return arr[randomIndex]
}
const Scene6 = (props: Scene6Props) => { const Scene6 = (props: Scene6Props) => {
const { spriteTop, onNext } = props const { spriteTop, onNext } = props
const [name, setName] = useState('好娃娃') const [name, setName] = useState('')
const dataRef = useRef<NickNameWord>({ noun: [], adj: [] })
const [isGenerating, genActions] = useBoolean(false)
const genName = useCallback(() => {
const { noun, adj } = dataRef.current
const nam = `${randomPick(adj)}${randomPick(noun)}`
setName(nam)
}, [])
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone) const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
...@@ -22,6 +38,22 @@ const Scene6 = (props: Scene6Props) => { ...@@ -22,6 +38,22 @@ const Scene6 = (props: Scene6Props) => {
.then(() => onNext()) .then(() => onNext())
}, [updateNickNameAndPhone, onNext, name]) }, [updateNickNameAndPhone, onNext, name])
const handleGen = useCallback(async () => {
genActions.setTrue()
await new Promise(resolve => setTimeout(resolve, 1000))
genName()
genActions.setFalse()
}, [genName, genActions])
useEffect(() => {
const fn = async () => {
const words = await getNickNameWords()
dataRef.current = words
genName()
}
fn()
}, [genName])
return ( return (
<View className={cs.viewport}> <View className={cs.viewport}>
<View className={cs.viewport_body}> <View className={cs.viewport_body}>
...@@ -37,8 +69,8 @@ const Scene6 = (props: Scene6Props) => { ...@@ -37,8 +69,8 @@ const Scene6 = (props: Scene6Props) => {
<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> <View className={styles.input_item}>{name}</View>
<Image src={assets['touzi.png'].u} className={styles.input_icon}></Image> <Image src={assets['touzi.png'].u} className={classNames(styles.input_icon, isGenerating && styles.is_gen)} onClick={handleGen}></Image>
</View> </View>
<View className={styles.input_tip}> <View className={styles.input_tip}>
确定后奖励<Image src={assets['score.png'].u} className={styles.score}></Image><Text className={styles.em}>+100</Text> 确定后奖励<Image src={assets['score.png'].u} className={styles.score}></Image><Text className={styles.em}>+100</Text>
......
...@@ -9,7 +9,7 @@ type TextPrinterProps = { ...@@ -9,7 +9,7 @@ type TextPrinterProps = {
} }
const TextPrinter = (props: TextPrinterProps) => { const TextPrinter = (props: TextPrinterProps) => {
const { textList, onEnd, speed = 200, pauseTime = 200 } = props const { textList, onEnd, speed = 100, pauseTime = 400 } = props
const [visibleText, setVisibleText] = useState('') const [visibleText, setVisibleText] = useState('')
const charIndex = useRef(0) const charIndex = useRef(0)
const currentTextIndex = useRef(0) const currentTextIndex = useRef(0)
......
...@@ -25,20 +25,20 @@ const ExchangeItems: ExchangeGoods[] = [ ...@@ -25,20 +25,20 @@ const ExchangeItems: ExchangeGoods[] = [
{ {
title: '答题卡', title: '答题卡',
subTitle: '答题卡', subTitle: '答题卡',
description: '答题卡是不断追求更高档位与排名的必备道具答题卡是不断追求更高档位与排名的必备道具', description: '答题卡是不断追求更高档位与排名的必备道具',
price: 30, price: 30,
stock: null, stock: null,
img: require('./assets/ph.png'), img: require('./assets/ph.png'),
}, },
{ // {
title: '月度神秘大礼', // title: '月度神秘大礼',
subTitle: '神秘大礼', // subTitle: '神秘大礼',
description: '兑换神秘大礼,线下领取超级大礼', // description: '兑换神秘大礼,线下领取超级大礼',
price: 30, // price: 30,
stock: 10, // stock: 10,
img: require('./assets/gift.png'), // img: require('./assets/gift.png'),
} // }
] ]
const StudyMarket = () => { const StudyMarket = () => {
......
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, useRef } from 'react'
import { useRouter, redirectTo, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo, showLoading, hideLoading, useDidShow } from '@tarojs/taro' import { useRouter, redirectTo, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo, showLoading, hideLoading, useDidShow } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
...@@ -23,6 +23,7 @@ import styles from './index.module.scss' ...@@ -23,6 +23,7 @@ import styles from './index.module.scss'
const Prepare = () => { const Prepare = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, []) const nav = useMemo(getMenuButtonBoundingClientRect, [])
const router = useRouter<{ id: string }>() const router = useRouter<{ id: string }>()
const isClickRef = useRef(false)
const [currentTab, setCurrentTab] = useState(0) const [currentTab, setCurrentTab] = useState(0)
const [isVisible, { setTrue, setFalse }] = useBoolean(false) const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [isLoad, { toggle: toggleLoad }] = useBoolean(true) const [isLoad, { toggle: toggleLoad }] = useBoolean(true)
...@@ -85,8 +86,8 @@ const Prepare = () => { ...@@ -85,8 +86,8 @@ const Prepare = () => {
const { run: exchange, loading: spinning } = useRequest(pointToCard, { const { run: exchange, loading: spinning } = useRequest(pointToCard, {
immediate: false, immediate: false,
onSuccess: () => { onSuccess: () => {
setFalse()
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
setFalse()
navigateTo({ navigateTo({
url: `/pages/game/play/index?id=${router.params.id}` url: `/pages/game/play/index?id=${router.params.id}`
}) })
...@@ -98,7 +99,10 @@ const Prepare = () => { ...@@ -98,7 +99,10 @@ const Prepare = () => {
if (cardNum < 1 && !stageDetail?.firstTime) { if (cardNum < 1 && !stageDetail?.firstTime) {
setTrue() setTrue()
} else { } else {
if (isClickRef.current) return
isClickRef.current = true
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
isClickRef.current = false
navigateTo({ navigateTo({
url: `/pages/game/play/index?id=${router.params.id}` url: `/pages/game/play/index?id=${router.params.id}`
}) })
......
import { createInnerAudioContext } from '@tarojs/taro'
const innerAudioContext = createInnerAudioContext()
export function palyAudio (src: string) {
innerAudioContext.src = src
innerAudioContext.play()
return innerAudioContext
}
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