This commit is contained in:
2026-01-18 20:17:59 +08:00
parent 7e05f5e76f
commit de9c14f070
23 changed files with 1825 additions and 71 deletions

View File

@@ -178,13 +178,40 @@ export default {
},
// 加载用户统计数据
loadUserStats() {
// 这里应该调用API获取实际数据
// 暂时使用模拟数据
this.stats = {
billCount: 128,
days: 45,
familyMembers: 3
async loadUserStats() {
try {
// 获取账单总数
const billRes = await this.$api.bill.list.get({
page: 1,
limit: 1
})
if (billRes && billRes.code === 1) {
this.stats.billCount = billRes.data?.total || 0
}
// 获取家庭成员数
const membersRes = await this.$api.family.members.get()
if (membersRes && membersRes.code === 1) {
this.stats.familyMembers = membersRes.data?.length || 0
}
// 获取记账天数(计算从第一个账单到现在的天数)
const firstBillRes = await this.$api.bill.list.get({
page: 1,
limit: 1,
order: 'asc'
})
if (firstBillRes && firstBillRes.code === 1 && firstBillRes.data?.list?.length > 0) {
const firstBill = firstBillRes.data.list[0]
const firstDate = new Date(firstBill.date)
const now = new Date()
const diffTime = Math.abs(now - firstDate)
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
this.stats.days = diffDays
}
} catch (error) {
console.error('加载统计数据失败', error)
// 失败时保持默认值
}
},
@@ -201,24 +228,26 @@ export default {
// 页面跳转
navigateTo(url) {
if (!this.isLogin && url !== '/pages/ucenter/login/index') {
if (!this.isLogin) {
uni.navigateTo({
url: '/pages/ucenter/login/index'
})
return
}
// 功能开发中提示
uni.showToast({
title: '功能开发中',
icon: 'none',
duration: 2000
// 直接跳转,不显示"功能开发中"
uni.navigateTo({
url: url
})
},
// 编辑个人资料
handleEditProfile() {
this.navigateTo('/pages/ucenter/profile')
uni.showToast({
title: '功能开发中',
icon: 'none',
duration: 2000
})
},
// 数据导出