fix: 修复记录页面和签到功能

- records.vue: 加载记录时传递userId参数
- coins.vue: 签到后同步金币数据到数据库
This commit is contained in:
H1d3rOne committed 2026-03-10 04:30:36 +08:00
1 parent 879eb05052
commit fbb155643d
2 files changed
+22 -3

No files matched your search

+17 -3
View File
@@ -180,7 +180,7 @@ export default {
})
}
},
signIn() {
async signIn() {
if (this.signedToday) {
uni.showToast({ title: '今日已签到', icon: 'none' })
return
@@ -201,9 +201,23 @@ export default {
}
const reward = this.getDayReward((this.streakDays - 1) % 7)
this.coins += reward
uni.setStorageSync('userCoins', this.coins)
try {
const userInfoStr = uni.getStorageSync('userInfo')
if (userInfoStr) {
const userInfo = JSON.parse(userInfoStr)
const result = await api.userApi.addCoins(userInfo.userId, reward, 'signin', `每日签到(连续${this.streakDays}天)`)
if (result && result.success) {
this.coins = result.data.coins || 0
uni.setStorageSync('userCoins', this.coins)
}
}
} catch (e) {
console.error('签到添加金币失败:', e)
this.coins += reward
uni.setStorageSync('userCoins', this.coins)
}
uni.setStorageSync('lastSignInDate', todayStr)
uni.setStorageSync('streakDays', this.streakDays)
@@ -118,7 +118,12 @@ export default {
try {
console.log('加载测算记录...', { page: this.page, size: this.size, keyword: this.keyword })
const userInfoStr = uni.getStorageSync('userInfo')
const userInfo = userInfoStr ? JSON.parse(userInfoStr) : null
const userId = userInfo?.userId || 'default_user'
const data = await api.recordApi.getList({
userId: userId,
page: this.page,
size: this.size,
keyword: this.keyword || undefined