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

@@ -38,39 +38,69 @@
</template>
<script>
import { animalService } from '../../api/services.js'
export default {
data() {
return {
animal: {
id: 1,
name: '小羊驼',
species: '羊驼',
price: 1000,
location: '西藏牧场',
images: [
'/static/animals/alpaca1.jpg',
'/static/animals/alpaca2.jpg'
],
description: '这是一只可爱的羊驼,性格温顺,喜欢与人互动。',
adoptionInfo: '认养后您将获得:\n1. 专属认养证书\n2. 定期照片和视频\n3. 牧场参观机会'
id: null,
name: '',
species: '',
price: 0,
location: '',
images: [],
description: '',
adoptionInfo: ''
}
}
},
onLoad(options) {
const id = options.id
if (id) {
this.loadAnimalDetail(id)
}
},
methods: {
handleAdopt() {
async loadAnimalDetail(id) {
try {
const data = await animalService.getDetail(id)
this.animal = data
} catch (error) {
console.error('获取动物详情失败:', error)
uni.showToast({
title: '获取数据失败',
icon: 'none'
})
}
},
async handleAdopt() {
uni.showModal({
title: '确认认养',
content: '确定要认养这只可爱的' + this.animal.name + '吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
uni.showToast({
title: '认养成功',
icon: 'success'
})
try {
await animalService.adopt(this.animal.id, {})
uni.showToast({
title: '认养成功',
icon: 'success'
})
} catch (error) {
console.error('认养失败:', error)
uni.showToast({
title: '认养失败',
icon: 'none'
})
}
}
}
})
},
handleContact() {
uni.makePhoneCall({
phoneNumber: '13800138000'
@@ -111,24 +141,23 @@ export default {
}
.species {
font-size: 28rpx;
color: #666;
}
.price {
font-size: 28rpx;
color: #ff9500;
color: #ff6b35;
font-weight: bold;
}
.location {
font-size: 26rpx;
color: #999;
font-size: 28rpx;
}
.section {
padding: 30rpx;
border-top: 1rpx solid #eee;
background: #fff;
margin-bottom: 20rpx;
}
.section-title {
@@ -136,16 +165,13 @@ export default {
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
display: block;
}
.description, .adoption-info {
font-size: 28rpx;
color: #666;
line-height: 1.6;
}
.adoption-info {
white-space: pre-line;
font-size: 28rpx;
}
.action-bar {
@@ -153,26 +179,25 @@ export default {
bottom: 0;
left: 0;
right: 0;
display: flex;
padding: 20rpx;
height: 120rpx;
background: #fff;
box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.1);
display: flex;
border-top: 1rpx solid #eee;
}
.btn {
flex: 1;
margin: 0 10rpx;
font-size: 28rpx;
border: none;
font-size: 32rpx;
}
.adopt {
background-color: #ff2d55;
background: #ff6b35;
color: #fff;
}
.contact {
background-color: #fff;
color: #ff2d55;
border: 1rpx solid #ff2d55;
background: #007aff;
color: #fff;
}
</style>