20260227-1
This commit is contained in:
@@ -55,11 +55,7 @@ const totalPoints = ref<number>(0)
|
||||
const records = ref<PointRecord[]>([])
|
||||
const loading = ref<boolean>(true)
|
||||
|
||||
const loadPoints = async () => {
|
||||
// 调用 service 获取积分 (需要supabaseService支持)
|
||||
// 暂时如果service没更新,先用mock
|
||||
// const res = await supabaseService.getUserPoints()
|
||||
// if (res != null) totalPoints.value = res
|
||||
const loadPoints = async (): Promise<void> => {
|
||||
try {
|
||||
const points = await supabaseService.getUserPoints()
|
||||
totalPoints.value = points
|
||||
@@ -68,26 +64,19 @@ const loadPoints = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const loadRecords = async () => {
|
||||
const loadRecords = async (): Promise<void> => {
|
||||
try {
|
||||
const list = await supabaseService.getPointRecords()
|
||||
const typedList: PointRecord[] = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i] as PointRecord
|
||||
typedList.push(item)
|
||||
}
|
||||
records.value = typedList
|
||||
records.value = list as PointRecord[]
|
||||
} catch (e) {
|
||||
console.error('获取积分记录失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
const loadData = async () => {
|
||||
const loadData = async (): Promise<void> => {
|
||||
loading.value = true
|
||||
await Promise.all<void>([
|
||||
loadPoints(),
|
||||
loadRecords()
|
||||
])
|
||||
await loadPoints()
|
||||
await loadRecords()
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -103,12 +92,20 @@ const handleExchange = () => {
|
||||
}
|
||||
|
||||
const getTypeText = (type: string): string => {
|
||||
if (type === 'signin') return '每日签到'
|
||||
if (type === 'shopping') return '购物奖励'
|
||||
if (type === 'redeem') return '积分兑换'
|
||||
if (type === 'admin') return '系统调整'
|
||||
if (type === 'register') return '注册赠送'
|
||||
return '积分变动'
|
||||
// 不支持 Record<string, string>,使用 if-else
|
||||
if (type == 'signin') {
|
||||
return '每日签到'
|
||||
} else if (type == 'shopping') {
|
||||
return '购物奖励'
|
||||
} else if (type == 'redeem') {
|
||||
return '积分兑换'
|
||||
} else if (type == 'admin') {
|
||||
return '系统调整'
|
||||
} else if (type == 'register') {
|
||||
return '注册赠送'
|
||||
} else {
|
||||
return '积分变动'
|
||||
}
|
||||
}
|
||||
|
||||
const formatTime = (timeStr: string): string => {
|
||||
|
||||
Reference in New Issue
Block a user