Commit 821d894c authored by hewenhao's avatar hewenhao

Merge branch 'feature/2023-04-19-iter' into 'master'

Feature/2023 04 19 iter See merge request hewenhao/GeekLearnMathWeapp!4
parents e2208652 76eaca15
...@@ -190,5 +190,23 @@ ...@@ -190,5 +190,23 @@
"w": 300, "w": 300,
"h": 300, "h": 300,
"ossName": "/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300" "ossName": "/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300"
},
"market-auth-reject.png": {
"u": "https://cdn.jkwljy.com/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260",
"w": 260,
"h": 260,
"ossName": "/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260"
},
"btn-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72",
"w": 248,
"h": 72,
"ossName": "/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72"
},
"btn-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72",
"w": 248,
"h": 72,
"ossName": "/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72"
} }
} }
...@@ -63,6 +63,7 @@ const config = { ...@@ -63,6 +63,7 @@ const config = {
'process.env.DEV_SERVER': JSON.stringify(process.env.DEV_SERVER || ''), 'process.env.DEV_SERVER': JSON.stringify(process.env.DEV_SERVER || ''),
'process.env.SERVER_ENDPOINT': JSON.stringify(process.env.SERVER_ENDPOINT || ''), 'process.env.SERVER_ENDPOINT': JSON.stringify(process.env.SERVER_ENDPOINT || ''),
'process.env.TARO_STORAGE_KEY': JSON.stringify(process.env.TARO_STORAGE_KEY || ''), 'process.env.TARO_STORAGE_KEY': JSON.stringify(process.env.TARO_STORAGE_KEY || ''),
'process.env.TARO_REFRESH_TOKEN': JSON.stringify(process.env.TARO_REFRESH_TOKEN || ''),
...envMap ...envMap
}, },
copy: { copy: {
......
{ {
"name": "learn-math-weapp", "name": "learn-math-weapp",
"version": "1.0.15", "version": "1.0.16",
"private": true, "private": true,
"description": "", "description": "",
"scripts": { "scripts": {
......
...@@ -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,
......
...@@ -25,6 +25,13 @@ module.exports = function configEnv () { ...@@ -25,6 +25,13 @@ module.exports = function configEnv () {
process.env.NODE_ENV = process.env.BUILD_MODE process.env.NODE_ENV = process.env.BUILD_MODE
} }
/** 更新后强制刷新走静默登录接口 */
const refreshHash = crypto.createHash('md5')
refreshHash.update('GEEK-PK-MATH-token-1.0')
refreshHash.update(`refresh-token-${env}`)
refreshHash.update(`refresh-token-${process.env.SERVER_ENDPOINT || ''}`)
process.env.TARO_REFRESH_TOKEN = refreshHash.digest('base64').substring(0, 12)
const hash = crypto.createHash('md5') const hash = crypto.createHash('md5')
hash.update('GEEK-PK-MATH-WEAPP-V1.9') hash.update('GEEK-PK-MATH-WEAPP-V1.9')
hash.update(`build-${env}`) hash.update(`build-${env}`)
......
main_guide_1, 引导页-1
main_guide_2, 引导页-2
question_continue_btn, 答题-继续
main_guide_4, 引导页-4
main_guide_5_1, 引导页-5-1
main_guide_5_2, 引导页-5-2
main_guide_6, 引导页-6
main_confirm_area, 选择区域
main_confirm_grade, 选择年级
main_confirm_info_result, 选择年级-点击结果
question_clear_btn, 答题-清除
firt_stage_guide, 第一关引导
game_complete_continue, 答题结束-继续
main_guide_6_gen_name, 引导页6-生成昵称
market_guide_1, 学分小店引导
market_guide_receive, 学分小店-领取积分
market_exchange_confirm, 学分小店-兑换答题卡
market_guide_finish, 学分小店-引导结束
app_tab_2, 部落tab
app_tab_1, 首页tab
err_question_guide, 查看错题引导
group_guide_1, 部落引导-1
app_tab_2_guide, 部落引导-2
complete_group_guide, 部落引导-3
err_question, 查看错题
group_gen_name, 部落-生成部落名称
main_shortcut, 定位到当前关卡
main_header_score, 首页-点击积分
join_group_confirm, 加入部落-确定
market_exchange_cancel, 取消兑换答题卡
group_header_score, 部落-点击积分
group_header_ph, 部落-点击答题卡
main_header_ph, 首页-点击答题卡
join_group_cancel, 加入部落-取消
fail_game_reborn, 一战到底-复活
...@@ -160,5 +160,20 @@ export default { ...@@ -160,5 +160,20 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300", "u": "https://cdn.jkwljy.com/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300",
"w": 300, "w": 300,
"h": 300 "h": 300
},
"market-auth-reject.png": {
"u": "https://cdn.jkwljy.com/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260",
"w": 260,
"h": 260
},
"btn-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72",
"w": 248,
"h": 72
},
"btn-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72",
"w": 248,
"h": 72
} }
} as const } as const
...@@ -87,7 +87,7 @@ const MainPage = () => { ...@@ -87,7 +87,7 @@ const MainPage = () => {
}, [player, isFocus]) }, [player, isFocus])
useEffect(() => { useEffect(() => {
if (isFocus && userInfo.city) { if (isFocus && userInfo.city && userInfo.grade) {
fetchAccount() fetchAccount()
const tabbar = getTabBar<TabbarRef>(page) const tabbar = getTabBar<TabbarRef>(page)
...@@ -114,7 +114,7 @@ const MainPage = () => { ...@@ -114,7 +114,7 @@ const MainPage = () => {
}, 200) }, 200)
}) })
} }
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady, userInfo.city]) }, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady, userInfo.city, userInfo.grade])
return ( return (
<> <>
......
...@@ -2,11 +2,24 @@ import { useState, useCallback, useEffect, useRef } from 'react' ...@@ -2,11 +2,24 @@ import { useState, useCallback, useEffect, useRef } from 'react'
import { getAreaAndGrades, type AreaAndGrades, StageStatus } from '@/api' import { getAreaAndGrades, type AreaAndGrades, StageStatus } from '@/api'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useFocus } from '@/hooks' import { useFocus } from '@/hooks'
import assets from '@/assets/oss/assets-guide'
import { preloadImage } from '@/utils/preload-image'
import ModalArea from './modal-area' import ModalArea from './modal-area'
import ModalGrade from './modal-grade' import ModalGrade from './modal-grade'
import ModalResult from './modal-result' import ModalResult from './modal-result'
import ModalGroupGuide from './modal-group-guide' import ModalGroupGuide from './modal-group-guide'
let isLoad = false
const preloadGuideImages = () => {
if (isLoad) return
isLoad = true
const items: string[] = []
for (const key in assets) {
items.push(assets[key].u)
}
preloadImage(items)
}
export type TutorialRef = { export type TutorialRef = {
start: () => void; start: () => void;
} }
...@@ -88,6 +101,7 @@ const Tutorial = () => { ...@@ -88,6 +101,7 @@ const Tutorial = () => {
if (isFocus) { if (isFocus) {
if (!data.areas.length) { if (!data.areas.length) {
loadData() loadData()
preloadGuideImages()
} }
if (isLoadRef.current) { if (isLoadRef.current) {
return return
......
...@@ -36,12 +36,9 @@ const Scene6 = (props: Scene6Props) => { ...@@ -36,12 +36,9 @@ const Scene6 = (props: Scene6Props) => {
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone) const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => { const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => {
if (!e.detail.code) { if (loading) return
console.log(e.detail.errMsg)
return
}
setLoading(true) setLoading(true)
updateNickNameAndPhone({ code: e.detail.code!, name }) updateNickNameAndPhone({ code: e.detail.code, name })
.then(() => { .then(() => {
setLoading(false) setLoading(false)
onNext() onNext()
...@@ -50,7 +47,7 @@ const Scene6 = (props: Scene6Props) => { ...@@ -50,7 +47,7 @@ const Scene6 = (props: Scene6Props) => {
setLoading(false) setLoading(false)
console.log(err) console.log(err)
}) })
}, [updateNickNameAndPhone, onNext, name]) }, [updateNickNameAndPhone, onNext, name, loading])
const _getNickNameWords = useCallback(async () => { const _getNickNameWords = useCallback(async () => {
const words = await getNickNameWords() const words = await getNickNameWords()
...@@ -124,6 +121,7 @@ const Scene6 = (props: Scene6Props) => { ...@@ -124,6 +121,7 @@ const Scene6 = (props: Scene6Props) => {
onGetPhoneNumber={handleGetPhone} onGetPhoneNumber={handleGetPhone}
className={cs.btn} className={cs.btn}
loading={loading} loading={loading}
disabled={loading}
id="main_guide_6" id="main_guide_6"
hoverClass={cs.is_hover} hoverClass={cs.is_hover}
>确定</Button> >确定</Button>
......
...@@ -25,7 +25,7 @@ const ExchangeItem = (props: ExchangeItemProps) => { ...@@ -25,7 +25,7 @@ const ExchangeItem = (props: ExchangeItemProps) => {
const [val, setVal] = useState(1) const [val, setVal] = useState(1)
const isGuideActive = useMemo(() => { const isGuideActive = useMemo(() => {
return storeGuideStep === 3 && storeGuideActive return storeGuideStep === 4 && storeGuideActive
}, [storeGuideStep, storeGuideActive]) }, [storeGuideStep, storeGuideActive])
const handleMinus = useCallback(() => { const handleMinus = useCallback(() => {
......
import { View, RootPortal, Image, Text } from '@tarojs/components'
import { useEffect } from 'react'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import styles from './shared.module.scss'
type ModalAuthPhoneBeforeProps = {
onConfirm: () => void;
}
const ModalAuthPhoneBefore = (props: ModalAuthPhoneBeforeProps) => {
const { onConfirm } = props
const userInfo = useStoreState(state => state.userModel.userInfo)
const nextStoreGuide = useStoreActions(actions => actions.guideModel.nextStoreGuide)
useEffect(() => {
if (userInfo.authPhone === 'Y') {
nextStoreGuide()
}
}, [userInfo.authPhone, nextStoreGuide])
if (userInfo.authPhone === 'Y') {
return null
}
return (
<RootPortal>
<View className={styles.mask} catchMove></View>
<View className={styles.result_wrap} catchMove>
<Image src={tutorialAssets['cat.png'].u} className={styles.result_cat} />
<View className={styles.result_main}>
<View className={classNames(styles.dialog)} onClick={() => onConfirm()} id="market-guide-before-authphone">
<View>
为了让阿喵老师能给你发放礼品,需要你进行授权哦。
<View>
<Text className={styles.em}>授权成功后,</Text>还可以
<Text className={styles.em}>获得100水晶</Text>奖励哦!
</View>
</View>
<View className={styles.continue}>
<View className={styles.continue_btn}>
继续<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
</View>
</View>
</View>
</RootPortal>
)
}
export default ModalAuthPhoneBefore
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import ReceivePointModal from './receive-point' import ReceivePointModal from './receive-point'
import GuideFinish from './guide-finish' import GuideFinish from './guide-finish'
import ModalAuthPhoneBefore from './auth-phone-before'
export type TutorialRef = { export type TutorialRef = {
start: () => void; start: () => void;
...@@ -11,11 +12,13 @@ const Tutorial = () => { ...@@ -11,11 +12,13 @@ const Tutorial = () => {
const storeGuideActive = useStoreState(state => state.guideModel.storeGuideActive) const storeGuideActive = useStoreState(state => state.guideModel.storeGuideActive)
const revceiPoint = useStoreActions(state => state.guideModel.revceiPoint) const revceiPoint = useStoreActions(state => state.guideModel.revceiPoint)
const completeStoreGuide = useStoreActions(state => state.guideModel.completeStoreGuide) const completeStoreGuide = useStoreActions(state => state.guideModel.completeStoreGuide)
const nextStoreGuide = useStoreActions(state => state.guideModel.nextStoreGuide)
return ( return (
<> <>
{storeGuideActive && storeGuideStep === 1 && <ReceivePointModal onConfirm={revceiPoint} />} {storeGuideActive && storeGuideStep === 1 && <ModalAuthPhoneBefore onConfirm={nextStoreGuide} />}
{storeGuideActive && storeGuideStep === 4 && <GuideFinish onConfirm={completeStoreGuide} />} {storeGuideActive && storeGuideStep === 2 && <ReceivePointModal onConfirm={revceiPoint} />}
{storeGuideActive && storeGuideStep === 5 && <GuideFinish onConfirm={completeStoreGuide} />}
</> </>
) )
} }
......
import { View, RootPortal, Image, Button } from '@tarojs/components' import { View, RootPortal, Image, Button, CommonEventFunction, ButtonProps } from '@tarojs/components'
import { showToast } from '@tarojs/taro' import { showToast } from '@tarojs/taro'
import { useBoolean } from '@/hooks' import { useBoolean } from '@/hooks'
import { receivePoint } from '@/api' import { receivePoint } from '@/api'
import { useStoreState, useStoreActions } from '@/store/hooks'
import guideAssets from '@/assets/oss/assets-guide'
import giftAssets from '@/assets/oss/assets-gift' import giftAssets from '@/assets/oss/assets-gift'
import styles from './shared.module.scss' import styles from './shared.module.scss'
...@@ -12,6 +15,39 @@ type ReceivePointProps = { ...@@ -12,6 +15,39 @@ type ReceivePointProps = {
const ModalReceivePoint = (props: ReceivePointProps) => { const ModalReceivePoint = (props: ReceivePointProps) => {
const { onConfirm } = props const { onConfirm } = props
const [loading, loadingActions] = useBoolean(false) const [loading, loadingActions] = useBoolean(false)
const useInfo = useStoreState(state => state.userModel.userInfo)
const completeStoreGuide = useStoreActions(actions => actions.guideModel.completeStoreGuide)
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
const [fail, failActions] = useBoolean(false)
const updatePhoneAndReceive = async (code: string) => {
if (loading) return
loadingActions.setTrue()
try {
await updateNickNameAndPhone({ code })
await receivePoint()
onConfirm && onConfirm()
loadingActions.setFalse()
} catch (err) {
loadingActions.setFalse()
}
}
const handleConfirmAndAuth: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail> = (arg) => {
if (!arg.detail.code) {
failActions.setTrue()
return
}
updatePhoneAndReceive(arg.detail.code)
}
const handleConfirmAndAuthTwice: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail> = arg => {
if (!arg.detail.code) {
completeStoreGuide()
return
}
updatePhoneAndReceive(arg.detail.code)
}
const handleConfirm = async () => { const handleConfirm = async () => {
if (loading) return if (loading) return
...@@ -26,15 +62,74 @@ const ModalReceivePoint = (props: ReceivePointProps) => { ...@@ -26,15 +62,74 @@ const ModalReceivePoint = (props: ReceivePointProps) => {
} }
} }
const finish = () => {
completeStoreGuide()
}
const renderModal = () => {
if (fail) {
return (
<View className={styles.modal} catchMove>
<View className={styles.reject_modal}>
<Image src={guideAssets['market-auth-reject.png'].u} className={styles.reject_cat}></Image>
<View className={styles.tips_1}>授权失败</View>
<View className={styles.tips_2}>
<View>授权失败,阿喵老师将</View>
<View>无法给你发放成长奖励礼品哦?</View>
</View>
<View className={styles.reject_modal_footer}>
<View className={styles.btn_reject_2} onClick={finish} id="market_guide_reject_point">先不要了</View>
<Button
className={styles.btn_receive_2}
onGetPhoneNumber={handleConfirmAndAuthTwice}
openType="getPhoneNumber"
loading={loading}
hoverClass={styles.btn_receive_2_active}
id="market_guide_receive_and_auth_2"
>
领取
</Button>
</View>
</View>
</View>
)
}
return ( return (
<RootPortal>
<View className={styles.mask} catchMove></View>
<View className={styles.modal} catchMove> <View className={styles.modal} catchMove>
<Image src={giftAssets['point-receive.png'].u} className={styles.icon}></Image> <Image src={giftAssets['point-receive.png'].u} className={styles.icon}></Image>
<View className={styles.count}>水晶 +100</View> <View className={styles.count}>水晶 +100</View>
<View className={styles.tips}>阿喵老师的奖励,继续加油哦~</View> <View className={styles.tips}>阿喵老师的奖励,继续加油哦~</View>
<Button className={styles.btn} onClick={handleConfirm} loading={loading} id="market_guide_receive">领取</Button> {useInfo.authPhone === 'Y'
? (
<Button
className={styles.btn}
onClick={handleConfirm}
loading={loading}
id="market_guide_receive"
>
领取
</Button>
)
: (
<Button
className={styles.btn}
onGetPhoneNumber={handleConfirmAndAuth}
openType="getPhoneNumber"
loading={loading}
id="market_guide_receive_and_auth_1"
>
领取
</Button>
)}
</View> </View>
)
}
return (
<RootPortal>
<View className={styles.mask} catchMove></View>
{renderModal()}
</RootPortal> </RootPortal>
) )
} }
......
...@@ -59,3 +59,146 @@ ...@@ -59,3 +59,146 @@
height: 960px; height: 960px;
margin-top: -80px; margin-top: -80px;
} }
.dialog {
width: 510px;
height: 272px;
padding: 24px 20px 0 42px;
box-sizing: border-box;
background-size: 100% 100%;
background-image: url(https://cdn.jkwljy.com/pk-math/mFR86xsmGbKnCC9yu5ak2yadejB/510x272);
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 44px;
.em {
color: #FFC056;
}
}
.result_wrap {
position: fixed;
z-index: 100000;
bottom: 15vh;
left: 0;
right: 0;
display: flex;
padding: 0 16px;
}
.result_main {
flex: 1;
padding-top: 60px;
margin-left: -8px;
}
.result_cat {
width: 200px;
height: 300px;
}
.continue {
display: flex;
justify-content: flex-end;
}
.continue_btn {
display: flex;
justify-content: flex-end;
align-items: center;
font-size: 28px;
font-weight: 500;
color: #1786F7;
padding: 2px 8px 2px 20px;
margin-right: -8px;
line-height: 40px;
}
.continue_icon {
width: 28px;
height: 28px;
display: block;
margin-left: 4px;
}
.reject_modal {
width: 654px;
background: #FFFEFF;
border-radius: 32px;
position: relative;
padding: 140px 64px 32px 64px;
box-sizing: border-box;
text-align: center;
.reject_cat {
position: absolute;
left: 50%;
width: 260px;
height: 260px;
top: -120px;
margin-left: -130px;
}
.tips_1 {
font-size: 48px;
font-weight: 600;
color: #586170;
line-height: 66px;
padding-top: 32px;
}
.tips_2 {
padding-top: 32px;
font-size: 32px;
font-weight: 400;
color: #586170;
line-height: 48px;
}
}
.btn_receive_2 {
width: 248px;
height: 72px;
background-image: url(https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72);
background-size: 100% 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
font-weight: 500;
color: #FFFFFF;
line-height: 40px;
border: none;
&::after {
border: none;
background-color: transparent;
}
&.btn_receive_2_active {
background-image: url(https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72);
}
}
.btn_reject_2 {
width: 246px;
height: 72px;
border-radius: 36px;
border: 4px solid rgba(70,81,100,0.3);
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-right: 34px;
}
.reject_modal_footer {
display: flex;
padding-top: 48px;
align-items: center;
}
...@@ -82,6 +82,7 @@ const StudyMarket = () => { ...@@ -82,6 +82,7 @@ const StudyMarket = () => {
const setting = useStoreState(state => state.userModel.setting) const setting = useStoreState(state => state.userModel.setting)
const storeGuideStep = useStoreState(state => state.guideModel.storeGuideStep) const storeGuideStep = useStoreState(state => state.guideModel.storeGuideStep)
const storeGuideActive = useStoreState(state => state.guideModel.storeGuideActive) const storeGuideActive = useStoreState(state => state.guideModel.storeGuideActive)
const isStoreGuideComplete = useStoreState(state => state.guideModel.isStoreGuideComplete)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount) const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const getSetting = useStoreActions(actions => actions.userModel.getSetting) const getSetting = useStoreActions(actions => actions.userModel.getSetting)
...@@ -94,10 +95,10 @@ const StudyMarket = () => { ...@@ -94,10 +95,10 @@ const StudyMarket = () => {
}) })
useEffect(() => { useEffect(() => {
if (userInfo.pointReceive === 'N') { if (userInfo.pointReceive === 'N' && !isStoreGuideComplete) {
updateStoreGuideActive(true) updateStoreGuideActive(true)
} }
}, [userInfo, updateStoreGuideActive]) }, [userInfo, updateStoreGuideActive, isStoreGuideComplete])
const list: ExchangeGoods[] = useMemo(() => { const list: ExchangeGoods[] = useMemo(() => {
return [ return [
...@@ -120,7 +121,7 @@ const StudyMarket = () => { ...@@ -120,7 +121,7 @@ const StudyMarket = () => {
}, [setTrue]) }, [setTrue])
const isMaskActive = useMemo(() => { const isMaskActive = useMemo(() => {
return (storeGuideStep === 0 || storeGuideStep === 2) && storeGuideActive return (storeGuideStep === 0 || storeGuideStep === 3) && storeGuideActive
}, [storeGuideStep, storeGuideActive]) }, [storeGuideStep, storeGuideActive])
const isStep1Active = useMemo(() => { const isStep1Active = useMemo(() => {
...@@ -180,7 +181,7 @@ const StudyMarket = () => { ...@@ -180,7 +181,7 @@ const StudyMarket = () => {
disabled={(!(item.isGuideCard && isStep1Active)) && disabled} disabled={(!(item.isGuideCard && isStep1Active)) && disabled}
subtitle={item.description} subtitle={item.description}
disabledText={disabledText} disabledText={disabledText}
isGuideActive={isMaskActive && storeGuideStep === 2 && index === 0} isGuideActive={isMaskActive && storeGuideStep === 3 && index === 0}
onClick={() => { onClick={() => {
open(item) open(item)
}} }}
......
...@@ -64,6 +64,7 @@ const guideModel: GuideModel = { ...@@ -64,6 +64,7 @@ const guideModel: GuideModel = {
state.pointToCardNum = num state.pointToCardNum = num
} }
}), }),
revceiPoint: thunk(async (actions, _, helpers) => { revceiPoint: thunk(async (actions, _, helpers) => {
actions.nextStoreGuide() actions.nextStoreGuide()
const userInfo = getStorage(StorageKeys.userInfo) const userInfo = getStorage(StorageKeys.userInfo)
...@@ -72,6 +73,7 @@ const guideModel: GuideModel = { ...@@ -72,6 +73,7 @@ const guideModel: GuideModel = {
helpers.getStoreActions().userModel.updateState({ userInfo: newUserInfo }) helpers.getStoreActions().userModel.updateState({ userInfo: newUserInfo })
helpers.getStoreActions().userModel.fetchAccount() helpers.getStoreActions().userModel.fetchAccount()
}), }),
nextGroupGuide: action(state => { nextGroupGuide: action(state => {
state.groupGuideStep += 1 state.groupGuideStep += 1
}), }),
......
...@@ -25,7 +25,7 @@ export interface UserModel { ...@@ -25,7 +25,7 @@ export interface UserModel {
exchangeItem: Thunk<UserModel, { name: string; num: number; }, void, AppStoreModel>; exchangeItem: Thunk<UserModel, { name: string; num: number; }, void, AppStoreModel>;
updateNickNameAndPhone: Thunk<UserModel, { code: string; name: string }, void, AppStoreModel>; updateNickNameAndPhone: Thunk<UserModel, { code?: string; name?: string }, void, AppStoreModel>;
} }
const userModel: UserModel = { const userModel: UserModel = {
...@@ -64,16 +64,35 @@ const userModel: UserModel = { ...@@ -64,16 +64,35 @@ const userModel: UserModel = {
updateNickNameAndPhone: thunk(async (actions, payload, helpers) => { updateNickNameAndPhone: thunk(async (actions, payload, helpers) => {
try { try {
if (!payload.code) { const fns: Promise<any>[] = [
throw new Error('') ]
if (payload.name) {
fns.push(updateUserInfo({ nickName: payload.name }))
} }
await Promise.all([
updateUserPhone(payload.code), let authPhone
updateUserInfo({ nickName: payload.name }),
]) if (payload.code) {
fns.push(updateUserPhone(payload.code))
authPhone = 'Y'
}
await Promise.all(fns)
const { userInfo } = helpers.getState() const { userInfo } = helpers.getState()
const current = { ...userInfo, nickName: payload.name }
let current = { ...userInfo }
if (authPhone) {
current = { ...current, authPhone }
}
if (payload.name) {
current = { ...current, nickName: payload.name }
}
updateStorage(StorageKeys.userInfo, current) updateStorage(StorageKeys.userInfo, current)
actions.updateState({ actions.updateState({
userInfo: current userInfo: current
}) })
......
...@@ -9,6 +9,8 @@ export type UserInfo = { ...@@ -9,6 +9,8 @@ export type UserInfo = {
phone?: string | null; phone?: string | null;
/** 是否以获取了积分 */ /** 是否以获取了积分 */
pointReceive?: 'Y' | 'N'; pointReceive?: 'Y' | 'N';
/** 是否授权了手机号 */
authPhone?: 'Y' | 'N';
} }
export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>> export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>>
......
...@@ -10,16 +10,24 @@ import { ...@@ -10,16 +10,24 @@ import {
const silentLoginDeferred = new Deferred<null>() const silentLoginDeferred = new Deferred<null>()
async function silentLogin () { async function silentLogin () {
const currentVersionRefreshToken = process.env.TARO_REFRESH_TOKEN
try { try {
await Taro.checkSession() await Taro.checkSession()
// const token = getStorage(StorageKeys.token) // const token = getStorage(StorageKeys.token)
const openId = getStorage(StorageKeys.openid) const openId = getStorage(StorageKeys.openid)
const userInfo = getStorage(StorageKeys.userInfo) const userInfo = getStorage(StorageKeys.userInfo)
const refreshToken = getStorage(StorageKeys.refreshToken)
if (refreshToken !== currentVersionRefreshToken) {
throw new Error('force silent login')
}
if (!openId) { // 未登录 if (!openId) { // 未登录
throw new Error('unlogin') throw new Error('unlogin')
} }
setProfile(openId, `${userInfo?.userId}`) setProfile(openId, `${userInfo?.userId}`)
} catch (error) { } catch (error) {
updateStorage(StorageKeys.refreshToken, currentVersionRefreshToken)
console.log('check session', error) console.log('check session', error)
try { try {
......
...@@ -27,6 +27,9 @@ export enum StorageKeys { ...@@ -27,6 +27,9 @@ export enum StorageKeys {
/** 学分小店引导 */ /** 学分小店引导 */
isStoreGuideComplete, isStoreGuideComplete,
/** 用于强制用户走静默登录接口 */
refreshToken = 100,
} }
type Storage = { type Storage = {
...@@ -40,6 +43,7 @@ type Storage = { ...@@ -40,6 +43,7 @@ type Storage = {
[StorageKeys.isErrQuestionGuideComplete]: boolean | null; [StorageKeys.isErrQuestionGuideComplete]: boolean | null;
[StorageKeys.isGroupGuideComplete]: boolean | null; [StorageKeys.isGroupGuideComplete]: boolean | null;
[StorageKeys.isStoreGuideComplete]: boolean | null; [StorageKeys.isStoreGuideComplete]: boolean | null;
[StorageKeys.refreshToken]: string | undefined;
} }
const store: Storage = {} as Storage const store: Storage = {} as Storage
...@@ -61,7 +65,8 @@ export function reloadStore () { ...@@ -61,7 +65,8 @@ export function reloadStore () {
StorageKeys.isMainGuideComplete, StorageKeys.isMainGuideComplete,
StorageKeys.isErrQuestionGuideComplete, StorageKeys.isErrQuestionGuideComplete,
StorageKeys.isGroupGuideComplete, StorageKeys.isGroupGuideComplete,
StorageKeys.isStoreGuideComplete StorageKeys.isStoreGuideComplete,
StorageKeys.refreshToken,
].forEach((element) => { ].forEach((element) => {
updateStorage(element, Taro.getStorageSync(`${storagePrefix}${element}`) ?? null) updateStorage(element, Taro.getStorageSync(`${storagePrefix}${element}`) ?? null)
}) })
......
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