Commit c96231fd authored by 666's avatar 666
parents 4080118f 3b01da02
{
"level-big-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536"
},
"level-big-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536"
},
"level-big-fail.png": {
"u": "https://cdn.jkwljy.com/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536"
},
"level-big-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536"
},
"level-small-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96"
},
"level-small-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96"
},
"level-small-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96"
},
"rank.png": {
"u": "https://cdn.jkwljy.com/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96"
},
"top-10.png": {
"u": "https://cdn.jkwljy.com/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96"
},
"top-20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96"
},
"top-30.png": {
"u": "https://cdn.jkwljy.com/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96"
},
"upgear.png": {
"u": "https://cdn.jkwljy.com/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96"
},
"btn-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112",
"w": 686,
"h": 112,
"ossName": "/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112"
}
}
......@@ -12,6 +12,7 @@ export default {
'pages/prepare/index',
'pages/study-market/index',
'pages/game/play/index',
'pages/game/complete/index',
],
subPackages: {{packages}},
resizable: true,
......
import { request, requestAfterSilentLogin } from '@/utils/request'
import { getStorage, StorageKeys } from '@/utils/storage'
type LoginResult = {
phone?: string | null;
......@@ -42,11 +41,11 @@ export type AccountOut = {
}
export function getAccountInfo () {
return requestAfterSilentLogin<AccountOut[], AccountIn>({
return requestAfterSilentLogin<AccountOut[], AccountIn>((userInfo) => ({
method: 'POST',
url: '/service-idea/account/selectAccounts',
data: {
userId: getStorage(StorageKeys.userInfo)?.userId,
userId: userInfo?.userId,
}
})
}))
}
import { requestAfterSilentLogin } from '@/utils/request'
import { getStorage, StorageKeys } from '@/utils/storage'
import { QuestionItem, type QuestionType } from '@/pages/game/play/types'
export const getQuestionList = (stageId: number) => {
return requestAfterSilentLogin<QuestionType[], { stageId: number, userId?: number }>({
return requestAfterSilentLogin<QuestionType[], { stageId: number, userId?: number }>(userInfo => ({
url: '/service-idea/stage/startStage',
method: 'GET',
data: { stageId, userId: getStorage(StorageKeys.userInfo)?.userId }
})
data: { stageId, userId: userInfo?.userId }
}))
}
export const enum StageStatus {
......@@ -65,20 +64,20 @@ export interface StageDetail extends Stage {
/** 获取关卡详情 */
export function getStageDetail (stageId: number) {
return requestAfterSilentLogin<StageDetail, { stageId: number, userId?: number }>({
return requestAfterSilentLogin<StageDetail, { stageId: number, userId?: number }>(userInfo => ({
method: 'GET',
url: '/service-idea/stage/stageDetail',
data: { stageId, userId: getStorage(StorageKeys.userInfo)?.userId }
})
data: { stageId, userId: userInfo?.userId }
}))
}
/** 获取关卡列表 */
export function getStageList () {
return requestAfterSilentLogin<Stage[], { chapter: number; userId?: number }>({
return requestAfterSilentLogin<Stage[], { chapter: number; userId?: number }>(userInfo => ({
method: 'GET',
url: '/service-idea/stage/listStages',
data: { chapter: 1, userId: getStorage(StorageKeys.userInfo)?.userId }
})
data: { chapter: 1, userId: userInfo?.userId }
}))
}
export interface CompleteQuestion extends QuestionItem {
......@@ -99,28 +98,40 @@ interface CompleteStageParamIn extends CompleteStageParam {
}
export interface CompleteStageOut {
/** 单题耗时 */
averageTime: number;
/** 排名档位 */
gear: number;
/** 成就等级:SAB */
level: StageLevel;
/** 下一档位 */
nextGear: number;
/** 下一档位时间 */
nextGearTime: number;
/** 积分后 */
pointAfter: number;
/** 积分前 */
pointBefore: number;
/** 排名 */
ranks: StageRank[];
/** 正确率 */
rate: number;
/** 耗时 */
resultTime: number;
/** S时间 */
sLevelTime: number;
/** 是否升档奖励 */
upGear: boolean;
}
/** 完成 */
export function completeStage (arg: CompleteStageParam) {
return requestAfterSilentLogin<CompleteStageOut, CompleteStageParamIn>({
return requestAfterSilentLogin<CompleteStageOut, CompleteStageParamIn>(userInfo => ({
method: 'POST',
url: '/service-idea/stage/completeStage',
data: {
...arg,
userId: getStorage(StorageKeys.userInfo)?.userId
userId: userInfo?.userId
}
})
}))
}
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"level-big-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536",
"w": 600,
"h": 536
},
"level-big-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536",
"w": 600,
"h": 536
},
"level-big-fail.png": {
"u": "https://cdn.jkwljy.com/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536",
"w": 600,
"h": 536
},
"level-big-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536",
"w": 600,
"h": 536
},
"level-small-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96",
"w": 96,
"h": 96
},
"level-small-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96",
"w": 96,
"h": 96
},
"level-small-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96",
"w": 96,
"h": 96
},
"rank.png": {
"u": "https://cdn.jkwljy.com/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96",
"w": 96,
"h": 96
},
"top-10.png": {
"u": "https://cdn.jkwljy.com/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96",
"w": 96,
"h": 96
},
"top-20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96",
"w": 96,
"h": 96
},
"top-30.png": {
"u": "https://cdn.jkwljy.com/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96",
"w": 96,
"h": 96
},
"upgear.png": {
"u": "https://cdn.jkwljy.com/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96",
"w": 96,
"h": 96
},
"btn-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112",
"w": 686,
"h": 112
}
} as const
import { useState, useImperativeHandle, forwardRef, useCallback } from 'react'
import { useState, useImperativeHandle, forwardRef, useCallback, type ForwardRefRenderFunction } from 'react'
import { View, Image } from '@tarojs/components'
import { switchTab } from '@tarojs/taro'
import styles from './index.module.scss'
type REfType = {
type TabbarRef = {
switchTab: (index: number, url: string) => void;
setSelected: (index: number) => void
setSelected: (index: number) => void;
}
const Tabbar = forwardRef<unknown, REfType>((_, ref) => {
const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
const [selected, setSelected] = useState(0)
const _switchTab = useCallback((index: number, url: string) => {
......@@ -41,6 +41,8 @@ const Tabbar = forwardRef<unknown, REfType>((_, ref) => {
</View>
</View>
)
})
}
export { TabbarRef }
export default Tabbar
export default forwardRef(Tabbar)
.title {
font-size: 36px;
font-weight: 500;
color: #465164;
line-height: 50px;
padding: 16px 0 24px 32px;
}
.achieve_item {
display: flex;
margin: 0 32px 24px 32px;
padding: 24px 48px 24px 24px;
align-items: center;
background: #F7F7F7;
border-radius: 32px;
}
.achieve_item_main {
flex: 1;
}
.main_text {
font-size: 32px;
font-weight: 600;
color: #465164;
line-height: 44px;
}
.tips_text {
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-top: 8px;
}
.rank_text {
font-size: 32px;
font-weight: 600;
color: #FF9D00;
line-height: 44px;
}
.achieve_icon {
width: 96px;
height: 96px;
margin-right: 24px;
}
.bonus_icon {
width: 56px;
height: 56px;
}
.bonus_text {
font-size: 24px;
font-weight: 500;
color: #00AEFF;
line-height: 30px;
margin-top: 4px;
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 2000;
background-color: #fff;
}
@supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) {
.footer {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
.wrap {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
}
.gap {
height: 160px;
}
.btn_continue {
background-image: url(https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112);
background-size: 100% 100%;
width: 686px;
margin: 16px 32px 32px 32px;
height: 112px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
font-weight: 600;
color: #FFFFFF;
line-height: 56px;
}
import { View, Image } from '@tarojs/components'
import assets from '@/assets/oss/assets-complete'
import { useMemo } from 'react'
import { useStoreState } from '@/store/hooks'
import { StageLevel } from '@/api'
import { cs } from '@/styles'
import styles from './complete-achieve.module.scss'
const getLevelBg = (s?: StageLevel): string => {
switch (s) {
case StageLevel.S: {
return assets['level-small-s.png'].u
}
case StageLevel.A: {
return assets['level-small-a.png'].u
}
case StageLevel.B: {
return assets['level-small-b.png'].u
}
}
return assets['level-small-b.png'].u
}
const getTopIcon = (s: number) => {
switch (s) {
case 10: {
return assets['top-10.png'].u
}
case 20: {
return assets['top-20.png'].u
}
case 30: {
return assets['top-30.png'].u
}
}
return null
}
const GameCompleteAchieve = () => {
const gameResult = useStoreState(state => state.gameModel.gameResult)
const level = useMemo(() => {
return getLevelBg(gameResult?.level)
}, [gameResult])
const topIcon = useMemo(() => {
return getTopIcon(gameResult?.gear ?? 0)
}, [gameResult])
return (
<>
<View className={styles.wrap}>
<View className={styles.title}>本关成就获得</View>
<View className={styles.achieve_item}>
<Image src={level} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>B等级</View>
<View className={styles.tips_text}>全对且用时≤1分30秒</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+30</View>
</View>
</View>
{topIcon && (
<View className={styles.achieve_item}>
<Image src={topIcon} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>TOP {gameResult?.gear ?? 0}%</View>
<View className={styles.tips_text}>恭喜你成为了最优秀的{gameResult?.gear ?? 0}%</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+20</View>
</View>
</View>
)}
<View className={styles.achieve_item}>
<Image src={assets['rank.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>全市排名</View>
<View className={styles.tips_text}>恭喜你进入了全市前100名</View>
</View>
<View className={styles.rank_text}>89名</View>
</View>
{gameResult?.upGear && (
<View className={styles.achieve_item}>
<Image src={assets['upgear.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>升档成功</View>
<View className={styles.tips_text}>提升到50%-60%</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+10</View>
</View>
</View>
)}
<View className={styles.gap}></View>
</View>
<View className={styles.footer}>
<View
className={styles.btn_continue}
hoverClass={styles.is_active}
>
继续
</View>
</View>
</>
)
}
export default GameCompleteAchieve
.head {
background-image: linear-gradient(to bottom, #B7CDEB 0%, #F1FAFF 87.0301573% , #FFFFFF 100%);
padding-bottom: 64px;
position: relative;
}
.bg {
width: 600px;
display: block;
margin: 0 auto;
height: 536px;
}
.tips {
position: absolute;
bottom: 158px;
left: 0;
right: 0;
text-align: center;
font-size: 48px;
line-height: 66px;
font-weight: bold;
}
.item_wrap {
padding: 0 70px;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: -14px;
}
.item {
display: flex;
align-items: center;
justify-content: center;
}
.icon {
width: 60px;
height: 60px;
margin-right: 6px;
}
.item_text {
width: 96px;
font-size: 28px;
font-weight: 500;
color: #465164;
text-align: center;
line-height: 40px;
}
import { View, Image, Text } from '@tarojs/components'
import { useMemo } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import assets from '@/assets/oss/assets-complete'
import { useFormatTick } from '@/hooks/use-format-tick'
import { StageLevel } from '@/api'
import { useStoreState } from '@/store/hooks'
import styles from './complete-head.module.scss'
const getLevelBigBg = (s?: StageLevel): string => {
switch (s) {
case StageLevel.S: {
return assets['level-big-s.png'].u
}
case StageLevel.A: {
return assets['level-big-a.png'].u
}
case StageLevel.B: {
return assets['level-big-b.png'].u
}
}
return assets['level-big-fail.png'].u
}
const getLevelText = (s?: StageLevel) => {
switch (s) {
case StageLevel.S: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#FF7C3F'
}
}
case StageLevel.A: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#7794BD'
}
}
case StageLevel.B: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#AA561C'
}
}
}
return {
text: '闯关失败',
second: '闯关失败',
color: '#465164'
}
}
const GameCompleteHead = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const gameResult = useStoreState(state => state.gameModel.gameResult)
const time = useFormatTick((gameResult?.resultTime ?? 0) * 1000)
const bg = useMemo(() => {
return getLevelBigBg(gameResult?.level)
}, [gameResult])
const text = useMemo(() => {
return getLevelText(gameResult?.level)
}, [gameResult])
const style = useMemo(() => {
return {
paddingTop: `${nav.top - 5}px`
}
}, [nav])
return (
<View style={style} className={styles.head}>
<Image src={bg} className={styles.bg}></Image>
<View style={{ color: text.color }} className={styles.tips}>{text.text}</View>
<View className={styles.item_wrap}>
<View className={styles.item}>
<Image src={require('../assets/bonus.png')} className={styles.icon}></Image>
<View className={styles.item_text}>+30</View>
</View>
<View className={styles.item}>
<Image src={require('../assets/right-count.png')} className={styles.icon}></Image>
<View className={styles.item_text}>全对</View>
</View>
<View className={styles.item}>
<Image src={require('../assets/time.png')} className={styles.icon}></Image>
<View className={styles.item_text}>{time.minutes}:{time.seconds}</View>
</View>
</View>
</View>
)
}
export default GameCompleteHead
export default definePageConfig({
navigationBarTitleText: 'pk-math',
navigationStyle: 'custom',
})
import GameCompleteHead from './components/complete-head'
import GameCompleteAchieve from './components/complete-achieve'
// import styles from './index.module.scss'
const GameComplete = () => {
return (
<>
<GameCompleteHead />
<GameCompleteAchieve />
</>
)
}
export default GameComplete
import { View, ScrollView, Button } from '@tarojs/components'
import { View, ScrollView } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useEffect } from 'react'
import { useRouter } from '@tarojs/taro'
......@@ -37,7 +37,6 @@ const GamePlay = () => {
{currentQuestion && (
<Question question={currentQuestion} />
)}
<Button onClick={actions.toggle}>23xxxxx4</Button>
</ScrollView>
{currentQuestion && (
<>
......
import { action, Action, computed, Computed, State, Thunk, thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType } from '@/api'
import { showLoading, hideLoading, showModal } from '@tarojs/taro'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, StageLevel } from '@/api'
import { showLoading, hideLoading, showModal, redirectTo, vibrateShort } from '@tarojs/taro'
import {
QuestionType,
QuestionAnswer,
......@@ -16,6 +16,7 @@ export interface GameModel {
/** 题目列表 */
questionList: QuestionType[];
stageDetail: StageDetail | null;
gameResult: CompleteStageOut | null;
gameStartTime: number;
updateState: Action<GameModel, Partial<State<GameModel>>>;
/** 当前题目 */
......@@ -53,7 +54,33 @@ export interface GameModel {
const gameModel: GameModel = {
questionList: [],
modalContinueVisible: true,
gameResult: {
/** 单题耗时 */
averageTime: 4,
/** 排名档位 */
gear: 10,
/** 成就等级:SAB */
level: StageLevel.S,
/** 下一档位 */
nextGear: 10,
/** 下一档位时间 */
nextGearTime: 3,
/** 积分后 */
pointAfter: 80,
/** 积分前 */
pointBefore: 76,
/** 排名 */
ranks: [],
/** 正确率 */
rate: 80,
/** 耗时 */
resultTime: 60,
/** S时间 */
sLevelTime: 70,
/** 是否升档奖励 */
upGear: true
},
modalContinueVisible: false,
gameStartTime: 0,
isSubmit: false,
......@@ -102,6 +129,7 @@ const gameModel: GameModel = {
}),
updateUserAnswer: action((state, char) => {
vibrateShort()
const index = state.currentInputIndex
const answers = state.questionList[state.currentQuestionIndex]?.answers
const val = answers?.[index]
......@@ -196,7 +224,11 @@ const gameModel: GameModel = {
})
actions.updateState({ isSubmit: true })
const { questionList, gameStartTime, stageDetail } = helpers.getState()
await completeStage(buildCompleteStageParam(questionList, stageDetail!, gameStartTime))
const { data: gameResult } = await completeStage(buildCompleteStageParam(questionList, stageDetail!, gameStartTime))
actions.updateState({ gameResult })
redirectTo({
url: '/pages/game/complete/index',
})
} catch (err) {
showModal({
title: '提示',
......
import assets from '@/assets/oss/assets-main'
import { createContext } from 'react'
import { type Stage, StageStatus, StageLevel, StageType } from '@/api'
import type { ImageSource } from '@/types'
export const SceneContext = createContext<{ ready: boolean }>({ ready: false })
export type ImageSource = {
w: number;
h: number;
u: string;
}
const PartBgPool = [
assets['part-bg-1.png'],
assets['part-bg-2.png'],
......
......@@ -3,7 +3,9 @@ import assets from '@/assets/oss/assets-round'
import classNames from 'classnames'
import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro'
import { type Stage, StageType, StageStatus, type ImageSource, StageLevel, CurrentRoundId, SceneContext } from './constants'
import type { ImageSource } from '@/types'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId, SceneContext } from './constants'
import StageTag from './stage-tag'
import styles from './stage.module.scss'
......
......@@ -2,6 +2,8 @@ import { View } from '@tarojs/components'
import { getMenuButtonBoundingClientRect, useDidShow, getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync } from '@tarojs/taro'
import { useState, useMemo, useEffect, useCallback } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '../../custom-tab-bar/index'
import { CurrentRoundId, SceneContext } from './components/scene/constants'
import MainHeader from './components/header'
import MainChapter from './components/chapter'
......@@ -19,7 +21,7 @@ const MainPage = () => {
useDidShow(() => {
fetchAccount()
const tabbar = getTabBar(page) as any
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
})
......
......@@ -10,6 +10,12 @@ export type UserInfo = {
export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>>
export type ImageSource = {
w: number;
h: number;
u: string;
}
export type PagingLike<T> = {
list: T[];
hasNextPage: boolean;
......
......@@ -66,14 +66,14 @@ async function request<T = unknown, P = unknown> (options: RequestOption<T, P>):
const token = getStorage(StorageKeys.token)
const userId = getStorage(StorageKeys.userInfo)?.userId
// const userId = getStorage(StorageKeys.userInfo)?.userId
if (token) {
header.Authorization = `Bearer ${token}`
}
if (userId) {
header.STUDENTUSERID = `${userId}`
}
// if (userId) {
// header.STUDENTUSERID = `${userId}`
// }
const doRequest = (baseUrl) => {
const base = options.baseUrl || baseUrl
......@@ -143,11 +143,9 @@ export async function requestAfterSilentLogin<T, P = void> (arg: RequestAfterSil
const userInfo = getStorage(StorageKeys.userInfo)
if (typeof arg === 'function') {
// eslint-disable-next-line no-return-await
return await request<T, P>(arg(userInfo))
}
// eslint-disable-next-line no-return-await
return await request<T, P>(arg)
}
......
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