Commit 1118e50d authored by raca's avatar raca

feat: 调试

parent 97841175
...@@ -13,3 +13,21 @@ export const pointToCard = ({ num }: { num: number }) => { ...@@ -13,3 +13,21 @@ export const pointToCard = ({ num }: { num: number }) => {
}) })
) )
} }
export type ExchangeParams = {
accountTo: 'POINT' | 'NAME_CARD' | 'CARD',
accountFrom: 'POINT' | 'NAME_CARD' | 'CARD',
num: number;
userId?: number;
}
export function accountExchange (data: ExchangeParams) {
return requestAfterSilentLogin<AccountOut[], ExchangeParams>(userInfo => ({
method: 'POST',
url: '/service-idea/account/accountExchange',
data: {
...data,
userId: userInfo?.userId
}
}))
}
...@@ -120,24 +120,6 @@ export const receivePoint = () => requestAfterSilentLogin<void, { userId?: numbe ...@@ -120,24 +120,6 @@ export const receivePoint = () => requestAfterSilentLogin<void, { userId?: numbe
data: { userId: user?.userId } data: { userId: user?.userId }
})) }))
export type ExchangeParams = {
accountTo: 'POINT' | 'NAME_CARD' | 'CARD',
accountFrom: 'POINT' | 'NAME_CARD' | 'CARD',
num: number;
userId?: number;
}
export function accountExchange (data: ExchangeParams) {
return requestAfterSilentLogin<void, ExchangeParams>(userInfo => ({
method: 'POST',
url: '/service-idea/stage/user/accountExchange',
data: {
...data,
userId: userInfo?.userId
}
}))
}
export function changeNickName (nickName: string) { export function changeNickName (nickName: string) {
return requestAfterSilentLogin<void, { nickName: string, userId?: number }>(userInfo => ({ return requestAfterSilentLogin<void, { nickName: string, userId?: number }>(userInfo => ({
method: 'GET', method: 'GET',
......
...@@ -54,14 +54,17 @@ export type PkRecords = { ...@@ -54,14 +54,17 @@ export type PkRecords = {
} & Pick<PkDetails, 'allPkNum' | 'userRanks' | 'winPkNum'> } & Pick<PkDetails, 'allPkNum' | 'userRanks' | 'winPkNum'>
export function fetchUserRecords (data: PkParams) { export function fetchUserRecords (data: PkParams) {
return requestAfterSilentLogin<PkRecords, PkParams>((userInfo) => ({ if (!data.stageId) {
method: 'GET', delete data.stageId
url: '/service-idea/pk/personal/stage/records', }
data: { return requestAfterSilentLogin<PkRecords, PkParams>((userInfo) => {
stageId: data.stageId, data.userId = data.userId || userInfo?.userId
userId: data.userId || userInfo?.userId, return {
method: 'GET',
url: '/service-idea/pk/personal/stage/records',
data
} }
})) })
} }
export type SubmitPkResultParams = { export type SubmitPkResultParams = {
......
...@@ -3,6 +3,7 @@ import { View, Text, Image, ScrollView } from '@tarojs/components' ...@@ -3,6 +3,7 @@ import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { convertDateTime } from '@/utils/day'
import assets from '@/assets/oss/assets-pk' import assets from '@/assets/oss/assets-pk'
import { badgeImages } from '../const' import { badgeImages } from '../const'
import { UserInfo, GameResultProps } from './game-result' import { UserInfo, GameResultProps } from './game-result'
...@@ -97,7 +98,7 @@ const GameResult = ({ record }: GameResultProps) => { ...@@ -97,7 +98,7 @@ const GameResult = ({ record }: GameResultProps) => {
src={record.result ? assets['win.png'].u : assets['lose.png'].u} src={record.result ? assets['win.png'].u : assets['lose.png'].u}
className={gameResultStyles.levelResult} className={gameResultStyles.levelResult}
/> />
<Text className={gameResultStyles.levelDate}>{record.createTime}</Text> <Text className={gameResultStyles.levelDate}>{convertDateTime(record.createTime)}</Text>
</View> </View>
<View className={styles.gameBody}> <View className={styles.gameBody}>
......
import { CSSProperties } from 'react' import { CSSProperties } from 'react'
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import { convertDateTime } from '@/utils/day'
import assets from '@/assets/oss/assets-pk' import assets from '@/assets/oss/assets-pk'
import assets2 from '@/assets/oss/assets-prepare' import assets2 from '@/assets/oss/assets-prepare'
import { PkRecord } from '@/api/pk' import { PkRecord } from '@/api/pk'
...@@ -27,7 +28,7 @@ const GameResult = ({ record }: GameResultProps) => { ...@@ -27,7 +28,7 @@ const GameResult = ({ record }: GameResultProps) => {
src={assets[record.result ? 'win.png' : 'lose.png'].u} src={assets[record.result ? 'win.png' : 'lose.png'].u}
className={styles.levelResult} className={styles.levelResult}
/> />
<Text className={styles.levelDate}>{record.createTime}</Text> <Text className={styles.levelDate}>{convertDateTime(record.createTime)}</Text>
</View> </View>
<View className={styles.gameBody}> <View className={styles.gameBody}>
......
...@@ -245,7 +245,7 @@ const StudyMarket = () => { ...@@ -245,7 +245,7 @@ const StudyMarket = () => {
bodyClassName={styles.moal_body} bodyClassName={styles.moal_body}
onClose={setFalse} onClose={setFalse}
maskClosable={false} maskClosable={false}
tilte={`兑换${currentGoods?.subTitle ?? currentGoods?.title ?? ''}`} tilte={`兑换${currentGoods?.subTitle ?? ''}`}
> >
{currentGoods?.subTitle === '改名卡' ? ( {currentGoods?.subTitle === '改名卡' ? (
<ExchangeRenameCard <ExchangeRenameCard
......
import { import {
action, Action, Thunk, thunk, State action, Action, Thunk, thunk, State
} from 'easy-peasy' } from 'easy-peasy'
import { getAccountInfo, getSetting, accountExchange, changeNickName, type ExchangeParams, type SettintType, updateUserInfo, type UpdateUserInfoIn, updateUserPhone } from '@/api' import { getAccountInfo, getSetting, type SettintType, updateUserInfo, type UpdateUserInfoIn, updateUserPhone, changeNickName } from '@/api'
import type { UserInfo } from '@/types' import type { UserInfo } from '@/types'
import { pointToCard } from '@/api/account' import { ExchangeParams, accountExchange, pointToCard } from '@/api/account'
import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro' import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro'
import { getStorage, StorageKeys, updateStorage } from '@/utils/storage' import { getStorage, StorageKeys, updateStorage } from '@/utils/storage'
import { Deferred } from '@/utils/deferred' import { Deferred } from '@/utils/deferred'
...@@ -176,8 +176,9 @@ const userModel: UserModel = { ...@@ -176,8 +176,9 @@ const userModel: UserModel = {
accountExchange: thunk(async (actions, payload) => { accountExchange: thunk(async (actions, payload) => {
try { try {
showLoading({ mask: true, title: '操作中...' }) showLoading({ mask: true, title: '操作中...' })
const { data } = await accountExchange(payload) const { data: list } = await accountExchange(payload)
console.log(data) const point = list.find(c => c.accountType === 'POINT')?.amount ?? 0
actions.updateState({ point })
hideLoading() hideLoading()
} catch (err) { } catch (err) {
hideLoading() hideLoading()
......
// 返回月和日,例如:6月16日
function formatMonthDay (date: Date): string {
const month = date.getMonth() + 1
const day = date.getDate()
return `${month}月${day}日`
}
// 返回时间,例如:18:00:00
function formatTime (date: Date): string {
const hours = date.getHours()
const minutes = date.getMinutes()
const seconds = date.getSeconds()
return `${hours.toString().padStart(2, '0')}:${minutes
.toString()
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
}
export function convertDateTime (input: string): string {
const date = new Date(input)
const monthDay = formatMonthDay(date)
const time = formatTime(date)
return `${monthDay} ${time}`
}
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