Commit 4fa13543 authored by m's avatar m
parents 0669d574 2d413a31
......@@ -36,3 +36,11 @@ export function getAccountInfo () {
}
}))
}
export function getSetting () {
return requestAfterSilentLogin<{pointToCard: number}, {}>(() => ({
method: 'GET',
url: '/service-idea/inlet/config/getConfig',
data: {}
}))
}
import { type CompleteStageParam, type StageDetail, StageLevel, type CompleteQuestion } from '@/api'
import { getLogManager } from '@tarojs/taro'
import { getStorage, StorageKeys } from '@/utils/storage'
import { type QuestionType, isBlankQuestion, isVerticalDivisionQuestion, isSelectionQuestion } from '../types'
const logger = getLogManager({ level: 1 })
export function convertQuestion (question: QuestionType): QuestionType {
if (isVerticalDivisionQuestion(question)) {
const { questionItems } = question
......@@ -36,7 +40,13 @@ export function convertQuestion (question: QuestionType): QuestionType {
}
export function buildCompleteStageParam (questionList: QuestionType[], stageDetail: StageDetail, resultTime: number): CompleteStageParam {
const correctNum = questionList.map(c => determinQuestion(c)).filter(Boolean).length
const wrongList = questionList.map(c => !determinQuestion(c)).filter(Boolean)
const wrongLength = wrongList.length
if (wrongLength > 0) {
logger.debug(getStorage(StorageKeys.userInfo)?.userId, '错误列表', wrongList)
console.log('错误列表', wrongList)
}
const { sTime, aTime, bTime } = stageDetail
......@@ -45,6 +55,8 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
const num = questionList.length
let levelTime: number = 0
const correctNum = num - wrongLength
if (correctNum === num) {
if (resultTime <= sTime) {
level = StageLevel.S
......
import { View } from '@tarojs/components'
import { useRouter, showToast, getMenuButtonBoundingClientRect, useDidShow, getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync, showModal } from '@tarojs/taro'
import {
useRouter, showToast, getMenuButtonBoundingClientRect, useDidShow,
getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync, showModal,
nextTick
} from '@tarojs/taro'
import { useState, useMemo, useCallback } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { getTribeInfo, joinTribe } from '@/api/group'
......@@ -41,7 +45,7 @@ const MainPage = () => {
tabbar?.setSelected(0)
fetchStage().then((list) => {
setTimeout(() => {
nextTick(() => {
if (!list.find(c => c.status === StageStatus.CURRENT)) {
setIsReady(true)
} else {
......@@ -49,7 +53,7 @@ const MainPage = () => {
setIsReady(true)
})
}
}, 1000)
})
})
fetchTribeInfo().then((res) => {
......
......@@ -45,9 +45,12 @@ const StudyMarket = () => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [currentGoods, setCurrentGoods] = useState<ExchangeGoods | null>(null)
const point = useStoreState(state => state.userModel.point)
const setting = useStoreState(state => state.userModel.setting)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const getSetting = useStoreActions(actions => actions.userModel.getSetting)
useDidShow(() => {
getSetting()
fetchAccount()
})
......@@ -70,7 +73,7 @@ const StudyMarket = () => {
title={item.subTitle}
cover={item.img}
stock={item.stock}
price={item.price}
price={setting.pointToCard}
disabled={item.stock !== null && item.stock < 1}
subtitle={item.description}
onClick={() => {
......
import {
action, Action, Thunk, thunk, State
} from 'easy-peasy'
import { getAccountInfo } from '@/api'
import { getAccountInfo, getSetting } from '@/api'
import type { UserInfo } from '@/types'
import { pointToCard } from '@/api/account'
import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro'
......@@ -15,6 +15,8 @@ export interface UserModel {
updateState: Action<UserModel, Partial<State<UserModel>>>;
fetchAccount: Thunk<UserModel, void, void, AppStoreModel>;
updateUserInfo: Action<UserModel, UserInfo>;
setting: { pointToCard: number };
getSetting: Thunk<UserModel, void, void, AppStoreModel>;
exchangeItem: Thunk<UserModel, { name: string; num: number; }, void, AppStoreModel>;
}
......@@ -23,6 +25,15 @@ const userModel: UserModel = {
userInfo: getStorage(StorageKeys.userInfo)!,
cardNum: 0,
point: 0,
setting: { pointToCard: Infinity },
getSetting: thunk(async (actions) => {
try {
const { data } = await getSetting()
actions.updateState({ setting: data })
} catch (err) {
actions.updateState({ setting: { pointToCard: Infinity } })
}
}),
exchangeItem: thunk(async (actions, payload) => {
try {
showLoading({ mask: true, title: '兑换中...' })
......
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