1
This commit is contained in:
+37
-50
@@ -210,6 +210,27 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 配置数据
|
||||
const ACTION_ITEMS_CONFIG = [
|
||||
{ id: 1, icon: '📝', text: '添加记录', action: 'addRecord' },
|
||||
{ id: 2, icon: '💬', text: 'AI聊天', action: 'chatWithPet' },
|
||||
{ id: 3, icon: '📊', text: '健康档案', action: 'viewHealth' },
|
||||
{ id: 4, icon: '📸', text: '成长时光', action: 'viewTimeline' },
|
||||
{ id: 5, icon: '📋', text: '所有记录', action: 'viewRecords' },
|
||||
{ id: 6, icon: '🔔', text: '提醒设置', action: 'showReminder' }
|
||||
]
|
||||
|
||||
const PET_EMOJI_MAP = {
|
||||
'橘猫': '🐱',
|
||||
'金毛': '🐶',
|
||||
'垂耳兔': '🐰',
|
||||
'哈士奇': '🐕',
|
||||
'波斯猫': '😸',
|
||||
'泰迪': '🐩',
|
||||
'仓鼠': '🐹',
|
||||
'鹦鹉': '🦜'
|
||||
}
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -218,37 +239,8 @@ export default {
|
||||
currentTabIndex: 0,
|
||||
petRecords: [],
|
||||
petExpenses: [],
|
||||
mainActionItems: [
|
||||
{ id: 1, icon: '📝', text: '添加记录', action: 'addRecord' },
|
||||
{ id: 2, icon: '💬', text: 'AI聊天', action: 'chatWithPet' },
|
||||
{ id: 3, icon: '📊', text: '健康档案', action: 'viewHealth' },
|
||||
{ id: 4, icon: '📸', text: '成长时光', action: 'viewTimeline' },
|
||||
{ id: 5, icon: '📋', text: '所有记录', action: 'viewRecords' },
|
||||
{ id: 6, icon: '🔔', text: '提醒设置', action: 'showReminder' }
|
||||
],
|
||||
recentInteractions: [
|
||||
{
|
||||
id: 1,
|
||||
petEmoji: '🐱',
|
||||
title: '小橘完成了今日散步',
|
||||
time: '2小时前',
|
||||
typeIcon: '🚶'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
petEmoji: '🐶',
|
||||
title: '小白吃完了晚餐',
|
||||
time: '4小时前',
|
||||
typeIcon: '🍽️'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
petEmoji: '🐱',
|
||||
title: '小橘的体重记录已更新',
|
||||
time: '1天前',
|
||||
typeIcon: '⚖️'
|
||||
}
|
||||
]
|
||||
mainActionItems: ACTION_ITEMS_CONFIG,
|
||||
recentInteractions: []
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
@@ -304,26 +296,12 @@ export default {
|
||||
|
||||
// 获取宠物表情符号
|
||||
getPetEmoji(breed) {
|
||||
const emojiMap = {
|
||||
'橘猫': '🐱',
|
||||
'金毛': '🐶',
|
||||
'垂耳兔': '🐰',
|
||||
'哈士奇': '🐕',
|
||||
'波斯猫': '😸',
|
||||
'泰迪': '🐩',
|
||||
'仓鼠': '🐹',
|
||||
'鹦鹉': '🦜'
|
||||
}
|
||||
return emojiMap[breed] || '🐾'
|
||||
return PET_EMOJI_MAP[breed] || '🐾'
|
||||
},
|
||||
|
||||
loadPets() {
|
||||
try {
|
||||
let pets = uni.getStorageSync('pets') || []
|
||||
|
||||
// 如果没有宠物数据,添加一些模拟数据
|
||||
if (pets.length === 0) {
|
||||
pets = [
|
||||
// 生成默认宠物数据
|
||||
generateDefaultPets() {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
name: '小橘',
|
||||
@@ -474,7 +452,16 @@ export default {
|
||||
personality: ['慵懒', '贪吃', '老成'],
|
||||
lastRecord: '2024-01-11'
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
|
||||
loadPets() {
|
||||
try {
|
||||
let pets = uni.getStorageSync('pets') || []
|
||||
|
||||
// 如果没有宠物数据,使用默认数据
|
||||
if (pets.length === 0) {
|
||||
pets = this.generateDefaultPets()
|
||||
// 保存模拟数据到本地存储
|
||||
uni.setStorageSync('pets', pets)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user