Commit d16282d8 authored by hewenhao's avatar hewenhao

feat: 引导页

parent df5f52d7
{
"noun": ["白菜", "西瓜", "萝卜"],
"adj": ["快乐的", "英勇的", "奋斗的"]
}
{
"ad": ["你的"],
"none": ["我的"]
}
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)
}
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' },
......
...@@ -27,7 +27,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => { ...@@ -27,7 +27,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
} }
}) })
if (!userInfo.nickName) { if (userInfo.nickName) {
return null return null
} }
......
...@@ -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)
......
...@@ -19,7 +19,7 @@ const MainPage = () => { ...@@ -19,7 +19,7 @@ const MainPage = () => {
useEffect(() => { useEffect(() => {
silentLoginDeferred.getPromise().then(() => { silentLoginDeferred.getPromise().then(() => {
const userInfo = getStorage(StorageKeys.userInfo) const userInfo = getStorage(StorageKeys.userInfo)
if (userInfo?.nickName) { if (!userInfo?.nickName) {
setIsDone(true) setIsDone(true)
} }
setIsReady(true) setIsReady(true)
......
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