Commit 1118e50d authored by raca's avatar raca

feat: 调试

parent 97841175
......@@ -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
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) {
return requestAfterSilentLogin<void, { nickName: string, userId?: number }>(userInfo => ({
method: 'GET',
......
......@@ -54,14 +54,17 @@ export type PkRecords = {
} & Pick<PkDetails, 'allPkNum' | 'userRanks' | 'winPkNum'>
export function fetchUserRecords (data: PkParams) {
return requestAfterSilentLogin<PkRecords, PkParams>((userInfo) => ({
if (!data.stageId) {
delete data.stageId
}
return requestAfterSilentLogin<PkRecords, PkParams>((userInfo) => {
data.userId = data.userId || userInfo?.userId
return {
method: 'GET',
url: '/service-idea/pk/personal/stage/records',
data: {
stageId: data.stageId,
userId: data.userId || userInfo?.userId,
data
}
}))
})
}
export type SubmitPkResultParams = {
......
......@@ -3,6 +3,7 @@ import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import Modal from '@/components/Modal'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { convertDateTime } from '@/utils/day'
import assets from '@/assets/oss/assets-pk'
import { badgeImages } from '../const'
import { UserInfo, GameResultProps } from './game-result'
......@@ -97,7 +98,7 @@ const GameResult = ({ record }: GameResultProps) => {
src={record.result ? assets['win.png'].u : assets['lose.png'].u}
className={gameResultStyles.levelResult}
/>
<Text className={gameResultStyles.levelDate}>{record.createTime}</Text>
<Text className={gameResultStyles.levelDate}>{convertDateTime(record.createTime)}</Text>
</View>
<View className={styles.gameBody}>
......
import { CSSProperties } from 'react'
import { View, Text, Image } from '@tarojs/components'
import classNames from 'classnames'
import { convertDateTime } from '@/utils/day'
import assets from '@/assets/oss/assets-pk'
import assets2 from '@/assets/oss/assets-prepare'
import { PkRecord } from '@/api/pk'
......@@ -27,7 +28,7 @@ const GameResult = ({ record }: GameResultProps) => {
src={assets[record.result ? 'win.png' : 'lose.png'].u}
className={styles.levelResult}
/>
<Text className={styles.levelDate}>{record.createTime}</Text>
<Text className={styles.levelDate}>{convertDateTime(record.createTime)}</Text>
</View>
<View className={styles.gameBody}>
......
......@@ -245,7 +245,7 @@ const StudyMarket = () => {
bodyClassName={styles.moal_body}
onClose={setFalse}
maskClosable={false}
tilte={`兑换${currentGoods?.subTitle ?? currentGoods?.title ?? ''}`}
tilte={`兑换${currentGoods?.subTitle ?? ''}`}
>
{currentGoods?.subTitle === '改名卡' ? (
<ExchangeRenameCard
......
import {
action, Action, Thunk, thunk, State
} 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 { pointToCard } from '@/api/account'
import { ExchangeParams, accountExchange, pointToCard } from '@/api/account'
import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro'
import { getStorage, StorageKeys, updateStorage } from '@/utils/storage'
import { Deferred } from '@/utils/deferred'
......@@ -176,8 +176,9 @@ const userModel: UserModel = {
accountExchange: thunk(async (actions, payload) => {
try {
showLoading({ mask: true, title: '操作中...' })
const { data } = await accountExchange(payload)
console.log(data)
const { data: list } = await accountExchange(payload)
const point = list.find(c => c.accountType === 'POINT')?.amount ?? 0
actions.updateState({ point })
hideLoading()
} catch (err) {
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