From fbb155643d9829c420c8d4ec91dbbea63871adce Mon Sep 17 00:00:00 2001 From: H1d3rOne Date: Tue, 10 Mar 2026 04:30:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=92=8C=E7=AD=BE=E5=88=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - records.vue: 加载记录时传递userId参数 - coins.vue: 签到后同步金币数据到数据库 --- xuan-deduct-uniapp/src/pages/mine/coins.vue | 20 ++++++++++++++++--- .../src/pages/records/records.vue | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) 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