完成宠物小程序基础功能开发
✨ 新功能: - 创建了4个主要Tab页面:宠物、助手、领养、我的 - 集成uview-ui-next UI框架 - 添加可爱的宠物主题图标 - 实现宠物列表展示和管理功能 - 配置微信小程序登录功能 🎨 界面优化: - 使用uView组件美化界面 - 统一的设计风格和配色方案 - 响应式布局适配 📦 技术栈: - uni-app + Vue3 - uview-ui-next UI框架 - 微信小程序平台
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<view class="pets-container">
|
||||
<u-navbar title="我的宠物" :border="false" bg-color="#ffffff">
|
||||
<template #right>
|
||||
<u-icon name="plus-circle-fill" color="#ff6b6b" size="24" @click="addPet"></u-icon>
|
||||
</template>
|
||||
</u-navbar>
|
||||
|
||||
<view class="pets-list" v-if="petsList.length > 0">
|
||||
<u-card v-for="pet in petsList" :key="pet.id" :margin="20" :padding="20" @click="viewPetDetail(pet)">
|
||||
<view class="pet-card-content">
|
||||
<u-avatar :src="pet.avatar || '/static/default-pet.png'" size="60" shape="circle"></u-avatar>
|
||||
<view class="pet-info">
|
||||
<u-text :text="pet.name" type="primary" size="16" bold></u-text>
|
||||
<u-text :text="pet.breed" type="info" size="14"></u-text>
|
||||
<u-text :text="`${pet.age}岁 · 陪伴${pet.companionDays}天`" type="tips" size="12"></u-text>
|
||||
</view>
|
||||
<view class="pet-actions">
|
||||
<u-button type="primary" size="mini" @click.stop="addRecord(pet)">记录</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</u-card>
|
||||
</view>
|
||||
|
||||
<u-empty v-else mode="data" text="还没有添加宠物哦">
|
||||
<template #bottom>
|
||||
<u-button type="primary" text="添加第一只宠物" @click="addPet"></u-button>
|
||||
</template>
|
||||
</u-empty>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
petsList: [
|
||||
// 示例数据
|
||||
{
|
||||
id: 1,
|
||||
name: '小橘',
|
||||
breed: '橘猫',
|
||||
age: 2,
|
||||
companionDays: 365,
|
||||
avatar: '/static/cat-avatar.jpg',
|
||||
gender: '公',
|
||||
weight: '4.5kg',
|
||||
birthday: '2022-01-15'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '小白',
|
||||
breed: '金毛',
|
||||
age: 3,
|
||||
companionDays: 1095,
|
||||
avatar: '/static/dog-avatar.jpg',
|
||||
gender: '母',
|
||||
weight: '25kg',
|
||||
birthday: '2021-03-20'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addPet() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/pets/add-pet'
|
||||
})
|
||||
},
|
||||
viewPetDetail(pet) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/pets/pet-detail?id=${pet.id}`
|
||||
})
|
||||
},
|
||||
addRecord(pet) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/pets/add-record?petId=${pet.id}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.pets-container {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.pet-card-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.pet-info {
|
||||
flex: 1;
|
||||
margin-left: 20rpx;
|
||||
|
||||
/deep/ .u-text {
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.pet-actions {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user