diff --git a/xuan-deduct-uniapp/src/pages/mine/coins.vue b/xuan-deduct-uniapp/src/pages/mine/coins.vue index e779767..e773495 100644 --- a/xuan-deduct-uniapp/src/pages/mine/coins.vue +++ b/xuan-deduct-uniapp/src/pages/mine/coins.vue @@ -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) diff --git a/xuan-deduct-uniapp/src/pages/records/records.vue b/xuan-deduct-uniapp/src/pages/records/records.vue index 2884fb8..0a6546b 100644 --- a/xuan-deduct-uniapp/src/pages/records/records.vue +++ b/xuan-deduct-uniapp/src/pages/records/records.vue @@ -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