refactor(backend): 重构动物相关 API 接口

- 更新了动物数据结构和相关类型定义
- 优化了动物列表、详情、创建、更新和删除接口
- 新增了更新动物状态接口
- 移除了与认领记录相关的接口
-调整了 API 响应结构
This commit is contained in:
ylweng
2025-08-31 00:45:46 +08:00
parent 0cad74b06f
commit 8e5295b572
111 changed files with 15290 additions and 1972 deletions

View File

@@ -51,283 +51,160 @@
<uni-icons type="sound" size="16" color="#ff9500"></uni-icons>
<swiper class="notice-swiper" vertical autoplay circular :interval="3000">
<swiper-item v-for="(notice, index) in notices" :key="index">
<text class="notice-text">{{notice}}</text>
<text class="notice-text">{{ notice.title }}</text>
</swiper-item>
</swiper>
<uni-icons type="arrowright" size="14" color="#ccc"></uni-icons>
</view>
<!-- 推荐旅行计划 -->
<view class="section">
<!-- 推荐内容 -->
<view class="recommend-section">
<!-- 推荐旅行计划 -->
<view class="section-header">
<text class="section-title">推荐旅行计划</text>
<text class="section-more" @click="navigateTo('/pages/travel/list')">更多</text>
<text class="section-title">热门旅行计划</text>
<text class="more" @click="navigateTo('/pages/travel/list')">更多 ></text>
</view>
<scroll-view class="plan-list" scroll-x="true" show-scrollbar="false">
<view class="plan-card" v-for="(plan, index) in travelPlans" :key="index" @click="navigateTo(`/pages/travel/detail?id=${plan.id}`)">
<image :src="plan.coverImage" mode="aspectFill" class="plan-image" />
<view class="plan-info">
<text class="plan-destination">{{ plan.destination }}</text>
<text class="plan-date">{{ plan.startDate }} - {{ plan.endDate }}</text>
<view class="plan-meta">
<text class="plan-budget">¥{{ plan.budget }}</text>
<text class="plan-members">{{ plan.currentMembers }}/{{ plan.maxMembers }}</text>
</view>
</view>
<scroll-view class="horizontal-scroll" scroll-x="true">
<view class="scroll-item" v-for="(travel, index) in recommendedTravels" :key="index" @click="navigateToTravelDetail(travel.id)">
<image :src="travel.coverImage" class="item-image" />
<text class="item-title">{{ travel.destination }}</text>
<text class="item-price">¥{{ travel.budget }}</text>
</view>
</scroll-view>
</view>
<!-- 热门动物 -->
<view class="section">
<!-- 热门动物 -->
<view class="section-header">
<text class="section-title">热门动物</text>
<text class="section-more" @click="navigateTo('/pages/animal/list')">更多</text>
<text class="more" @click="navigateTo('/pages/animal/list')">更多 ></text>
</view>
<view class="animal-grid">
<view class="animal-card" v-for="(animal, index) in animals" :key="index" @click="navigateTo(`/pages/animal/detail?id=${animal.id}`)">
<image :src="animal.image" mode="aspectFill" class="animal-image" />
<view class="animal-tag" v-if="animal.isHot">热门</view>
<view class="animal-info">
<text class="animal-name">{{ animal.name }}</text>
<text class="animal-species">{{ animal.species }}</text>
<text class="animal-price">¥{{ animal.price }}</text>
</view>
</view>
</view>
</view>
<!-- 送花服务 -->
<view class="section">
<view class="section-header">
<text class="section-title">精选花束</text>
<text class="section-more" @click="navigateTo('/pages/flower/list')">更多</text>
</view>
<scroll-view class="flower-list" scroll-x="true" show-scrollbar="false">
<view class="flower-card" v-for="(flower, index) in flowers" :key="index" @click="navigateTo(`/pages/flower/detail?id=${flower.id}`)">
<image :src="flower.image" mode="aspectFill" class="flower-image" />
<view class="flower-info">
<text class="flower-name">{{ flower.name }}</text>
<text class="flower-desc">{{ flower.description }}</text>
<text class="flower-price">¥{{ flower.price }}</text>
</view>
<scroll-view class="horizontal-scroll" scroll-x="true">
<view class="scroll-item" v-for="(animal, index) in hotAnimals" :key="index" @click="navigateToAnimalDetail(animal.id)">
<image :src="animal.image" class="item-image" />
<text class="item-title">{{ animal.name }}</text>
<text class="item-price">¥{{ animal.price }}</text>
</view>
</scroll-view>
</view>
<!-- 底部导航栏 -->
<view class="tab-bar">
<view class="tab-item active">
<uni-icons type="home" size="24" color="#007aff"></uni-icons>
<text class="tab-text">首页</text>
</view>
<view class="tab-item" @click="navigateTo('/pages/discover/index')">
<uni-icons type="compass" size="24" color="#999"></uni-icons>
<text class="tab-text">发现</text>
</view>
<view class="tab-item" @click="navigateTo('/pages/message/index')">
<uni-icons type="chat" size="24" color="#999"></uni-icons>
<text class="tab-text">消息</text>
<view class="badge" v-if="unreadCount > 0">{{unreadCount > 99 ? '99+' : unreadCount}}</view>
</view>
<view class="tab-item" @click="navigateTo('/pages/user/center')">
<uni-icons type="person" size="24" color="#999"></uni-icons>
<text class="tab-text">我的</text>
<!-- 精选花束 -->
<view class="section-header">
<text class="section-title">精选花束</text>
<text class="more" @click="navigateTo('/pages/flower/list')">更多 ></text>
</view>
<scroll-view class="horizontal-scroll" scroll-x="true">
<view class="scroll-item" v-for="(flower, index) in featuredFlowers" :key="index" @click="navigateToFlowerDetail(flower.id)">
<image :src="flower.image" class="item-image" />
<text class="item-title">{{ flower.name }}</text>
<text class="item-price">¥{{ flower.price }}</text>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
import { homeService } from '../../api/services.js'
export default {
data() {
return {
banners: [
{ image: '/static/banners/banner1.jpg', link: '/pages/travel/list' },
{ image: '/static/banners/banner2.jpg', link: '/pages/animal/list' },
{ image: '/static/banners/banner3.jpg', link: '/pages/flower/list' }
],
notices: [
'欢迎来到结伴客,找到志同道合的旅伴!',
'新用户注册即送50积分可兑换精美礼品',
'推荐好友加入双方各得30积分奖励'
],
travelPlans: [
{
id: 1,
destination: '西藏拉萨',
startDate: '10月1日',
endDate: '10月7日',
budget: 5000,
currentMembers: 3,
maxMembers: 6,
coverImage: '/static/travel/tibet.jpg'
},
{
id: 2,
destination: '云南大理',
startDate: '10月5日',
endDate: '10月12日',
budget: 3500,
currentMembers: 2,
maxMembers: 4,
coverImage: '/static/travel/yunnan.jpg'
},
{
id: 3,
destination: '新疆喀什',
startDate: '10月10日',
endDate: '10月20日',
budget: 6000,
currentMembers: 4,
maxMembers: 8,
coverImage: '/static/travel/xinjiang.jpg'
},
{
id: 4,
destination: '青海湖',
startDate: '10月15日',
endDate: '10月20日',
budget: 4000,
currentMembers: 2,
maxMembers: 5,
coverImage: '/static/travel/qinghai.jpg'
}
],
animals: [
{
id: 1,
name: '小羊驼',
species: '羊驼',
price: 1000,
isHot: true,
image: '/static/animals/alpaca.jpg'
},
{
id: 2,
name: '小绵羊',
species: '绵羊',
price: 800,
isHot: false,
image: '/static/animals/sheep.jpg'
},
{
id: 3,
name: '小花猪',
species: '猪',
price: 600,
isHot: true,
image: '/static/animals/pig.jpg'
},
{
id: 4,
name: '小公鸡',
species: '鸡',
price: 300,
isHot: false,
image: '/static/animals/chicken.jpg'
}
],
flowers: [
{
id: 1,
name: '浪漫玫瑰',
description: '11朵红玫瑰',
price: 199,
image: '/static/flowers/rose.jpg'
},
{
id: 2,
name: '向日葵花束',
description: '9朵向日葵',
price: 179,
image: '/static/flowers/sunflower.jpg'
},
{
id: 3,
name: '百合花束',
description: '7朵白百合',
price: 229,
image: '/static/flowers/lily.jpg'
}
],
unreadCount: 5
banners: [],
notices: [],
recommendedTravels: [],
hotAnimals: [],
featuredFlowers: []
}
},
onLoad() {
// 获取系统信息设置状态栏高度
const systemInfo = uni.getSystemInfoSync();
this.statusBarHeight = systemInfo.statusBarHeight;
// 加载数据
this.loadData();
onShow() {
this.loadHomeData()
},
methods: {
loadData() {
// 实际开发中这里应该从API获取数据
console.log('加载首页数据');
async loadHomeData() {
try {
// 获取轮播图
const banners = await homeService.getBanners()
this.banners = banners
// 获取公告
const notices = await homeService.getNotices()
this.notices = notices
// 获取推荐旅行计划
const travels = await homeService.getRecommendedTravels()
this.recommendedTravels = travels
// 获取热门动物
const animals = await homeService.getHotAnimals()
this.hotAnimals = animals
// 获取精选花束
const flowers = await homeService.getFeaturedFlowers()
this.featuredFlowers = flowers
} catch (error) {
console.error('获取首页数据失败:', error)
uni.showToast({
title: '数据加载失败',
icon: 'none'
})
}
},
navigateTo(url) {
uni.navigateTo({
url: url
});
uni.navigateTo({ url })
},
navigateToSearch() {
uni.navigateTo({
url: '/pages/search/index'
});
uni.navigateTo({ url: '/pages/search/index' })
},
navigateToTravelDetail(id) {
uni.navigateTo({ url: `/pages/travel/detail?id=${id}` })
},
navigateToAnimalDetail(id) {
uni.navigateTo({ url: `/pages/animal/detail?id=${id}` })
},
navigateToFlowerDetail(id) {
uni.navigateTo({ url: `/pages/flower/detail?id=${id}` })
}
}
}
</script>
<style>
/* 移除图标字体相关样式 */
/* 页面样式 */
<style scoped>
.container {
min-height: 100vh;
background-color: #f8f9fa;
padding-bottom: 100rpx; /* 为底部导航留出空间 */
padding-bottom: 20rpx;
}
.status-bar {
height: var(--status-bar-height);
width: 100%;
background-color: #fff;
}
.search-bar {
padding: 20rpx 30rpx;
background-color: #ffffff;
background-color: #fff;
}
.search-input {
display: flex;
align-items: center;
background: #f5f5f5;
border-radius: 50rpx;
padding: 15rpx 30rpx;
}
.search-input .iconfont {
font-size: 32rpx;
color: #999;
margin-right: 10rpx;
}
.search-input input {
flex: 1;
font-size: 28rpx;
height: 60rpx;
background-color: #f0f0f0;
border-radius: 30rpx;
padding: 0 20rpx;
}
.placeholder {
font-size: 28rpx;
color: #999;
}
.banner-swiper {
height: 300rpx;
margin: 0 30rpx 30rpx;
border-radius: 20rpx;
overflow: hidden;
}
.banner-image {
@@ -337,21 +214,21 @@ export default {
.feature-grid {
display: flex;
justify-content: space-around;
padding: 20rpx 30rpx 30rpx;
background-color: #ffffff;
background-color: #fff;
padding: 30rpx 0;
margin-bottom: 20rpx;
}
.feature-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.feature-icon {
width: 100rpx;
height: 100rpx;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
display: flex;
align-items: center;
@@ -359,40 +236,20 @@ export default {
margin-bottom: 15rpx;
}
.feature-icon .iconfont {
font-size: 50rpx;
.travel {
background-color: #e6f1ff;
}
.feature-icon.travel {
background-color: rgba(0, 122, 255, 0.1);
.animal {
background-color: #ffe6eb;
}
.feature-icon.travel .iconfont {
color: #007aff;
.flower {
background-color: #fff5e6;
}
.feature-icon.animal {
background-color: rgba(255, 45, 85, 0.1);
}
.feature-icon.animal .iconfont {
color: #ff2d55;
}
.feature-icon.flower {
background-color: rgba(255, 149, 0, 0.1);
}
.feature-icon.flower .iconfont {
color: #ff9500;
}
.feature-icon.promotion {
background-color: rgba(52, 199, 89, 0.1);
}
.feature-icon.promotion .iconfont {
color: #34c759;
.promotion {
background-color: #e6f9ed;
}
.feature-text {
@@ -403,285 +260,80 @@ export default {
.notice-bar {
display: flex;
align-items: center;
background-color: #fff8e6;
padding: 15rpx 30rpx;
margin: 0 30rpx 20rpx;
border-radius: 10rpx;
}
.notice-bar .iconfont {
font-size: 32rpx;
color: #ff9500;
margin-right: 15rpx;
background-color: #fff;
margin-bottom: 20rpx;
}
.notice-swiper {
height: 40rpx;
flex: 1;
height: 40rpx;
margin: 0 10rpx;
}
.notice-text {
font-size: 24rpx;
font-size: 26rpx;
color: #ff9500;
line-height: 40rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.section {
margin-bottom: 30rpx;
background-color: #ffffff;
padding: 30rpx 0;
.recommend-section {
background-color: #fff;
padding: 0 30rpx 30rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx 20rpx;
margin: 30rpx 0 20rpx;
}
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
position: relative;
padding-left: 20rpx;
}
.section-title::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 30rpx;
background-color: #007aff;
border-radius: 4rpx;
}
.section-more {
font-size: 24rpx;
color: #999;
}
.plan-list {
white-space: nowrap;
padding: 0 30rpx;
}
.plan-card {
display: inline-block;
width: 300rpx;
margin-right: 20rpx;
background: #ffffff;
border-radius: 15rpx;
overflow: hidden;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}
.plan-image {
width: 100%;
height: 180rpx;
}
.plan-info {
padding: 15rpx;
}
.plan-destination {
display: block;
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.plan-date {
display: block;
font-size: 22rpx;
color: #666;
margin-bottom: 10rpx;
}
.plan-meta {
display: flex;
justify-content: space-between;
align-items: center;
}
.plan-budget {
.more {
font-size: 26rpx;
color: #ff9500;
font-weight: bold;
}
.plan-members {
font-size: 22rpx;
color: #999;
}
.animal-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
padding: 0 30rpx;
.horizontal-scroll {
white-space: nowrap;
margin-bottom: 30rpx;
}
.animal-card {
background: #ffffff;
border-radius: 15rpx;
overflow: hidden;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
position: relative;
.scroll-item {
display: inline-block;
width: 200rpx;
margin-right: 20rpx;
vertical-align: top;
}
.animal-image {
width: 100%;
.item-image {
width: 200rpx;
height: 200rpx;
}
.animal-tag {
position: absolute;
top: 15rpx;
right: 15rpx;
background-color: #ff2d55;
color: #fff;
font-size: 20rpx;
padding: 5rpx 10rpx;
border-radius: 10rpx;
}
.animal-info {
padding: 15rpx;
}
.animal-name {
display: block;
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 5rpx;
}
.animal-species {
display: block;
font-size: 22rpx;
color: #999;
margin-bottom: 10rpx;
}
.animal-price {
.item-title {
display: block;
font-size: 26rpx;
color: #ff9500;
font-weight: bold;
}
.flower-list {
white-space: nowrap;
padding: 0 30rpx;
}
.flower-card {
display: inline-block;
width: 240rpx;
margin-right: 20rpx;
background: #ffffff;
border-radius: 15rpx;
overflow: hidden;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}
.flower-image {
width: 100%;
height: 240rpx;
}
.flower-info {
padding: 15rpx;
}
.flower-name {
display: block;
font-size: 26rpx;
font-weight: bold;
color: #333;
margin-bottom: 5rpx;
}
.flower-desc {
display: block;
font-size: 22rpx;
color: #999;
margin-bottom: 10rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.flower-price {
display: block;
font-size: 26rpx;
color: #ff9500;
.item-price {
font-size: 24rpx;
color: #ff6b35;
font-weight: bold;
}
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 100rpx;
background-color: #ffffff;
display: flex;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.tab-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.tab-item .iconfont {
font-size: 40rpx;
color: #999;
margin-bottom: 5rpx;
}
.tab-item.active .iconfont {
color: #007aff;
}
.tab-text {
font-size: 20rpx;
color: #999;
}
.tab-item.active .tab-text {
color: #007aff;
}
.badge {
position: absolute;
top: 0;
right: 50%;
transform: translateX(10rpx);
background-color: #ff2d55;
color: #fff;
font-size: 20rpx;
min-width: 32rpx;
height: 32rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
padding: 0 6rpx;
}
</style>