mkm
/
yanzhiAPP
Template
2
0
Fork 0
yanzhiAPP/pages/poultry/histroyFeed.vue

101 lines
1.8 KiB
Vue
Raw Normal View History

2023-10-25 19:55:18 +08:00
<template>
<view class="content">
<view class="">
2023-10-26 20:18:04 +08:00
2023-10-25 19:55:18 +08:00
<view class="">
养殖情况
</view>
2023-10-26 20:18:04 +08:00
<imgCard v-for="(item,index) in imgList" :imgUrl='item' :key="index" @tap='previewImage(index)'></imgCard>
2023-10-25 19:55:18 +08:00
</view>
<view class="up-plant-btn" @click="updateImgFn">
上传新的种植情况
</view>
</view>
</template>
<script setup>
import imgCard from "@/components/imgCard.vue"
import uplodeImg from "@/utils/uplodeImg.js"
import {
animalPicListAPI,
addAnimalPicAPI
2023-10-26 20:18:04 +08:00
} from "@/api/chick.js"
2023-10-25 19:55:18 +08:00
import {
onLoad
} from "@dcloudio/uni-app"
import {
reactive,
ref
} from "vue";
2023-10-26 20:18:04 +08:00
const img = ref("")
2023-10-25 19:55:18 +08:00
const updateImgFn = () => {
uplodeImg().then(res => {
2023-10-26 20:18:04 +08:00
img.value = res.data.image
2023-10-25 19:55:18 +08:00
addAnimalPicAPI({
2023-10-26 20:18:04 +08:00
poultry_id: Number(animal_id.value),
2023-10-25 19:55:18 +08:00
pic: res.data.image
}).then(res => {
2023-10-26 20:18:04 +08:00
imgList.unshift(img.value)
2023-10-25 19:55:18 +08:00
})
})
}
const imgList = reactive([])
const animal_id = ref("")
onLoad((option) => {
animal_id.value = option.id
animalPicListAPI({
2023-10-26 20:18:04 +08:00
poultry_id: option.id
2023-10-25 19:55:18 +08:00
}).then(res => {
res.data.forEach(item => {
2023-10-26 20:18:04 +08:00
imgList.push(item.pic)
2023-10-25 19:55:18 +08:00
})
})
})
2023-10-26 20:18:04 +08:00
const previewImage = (index) => {
uni.previewImage({
urls: imgList,
current: index,
})
}
2023-10-25 19:55:18 +08:00
</script>
<style lang="scss" scoped>
.card {
margin-bottom: 20rpx;
.tit {
display: flex;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1px solid #EBF1EF;
}
.card-li {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
.up-plant-btn {
width: 371.5rpx;
height: 66.59rpx;
color: #00A15E;
margin: 40rpx auto;
border: 1px solid #00A15E;
font-weight: bold;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
display: flex;
align-items: center;
justify-content: center;
}
</style>