101 lines
1.8 KiB
Vue
101 lines
1.8 KiB
Vue
<template>
|
|
<view class="content">
|
|
|
|
<view class="">
|
|
|
|
<view class="">
|
|
养殖情况
|
|
</view>
|
|
<imgCard v-for="(item,index) in imgList" :imgUrl='item' :key="index" @tap='previewImage(index)'></imgCard>
|
|
|
|
</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
|
|
} from "@/api/chick.js"
|
|
import {
|
|
onLoad
|
|
} from "@dcloudio/uni-app"
|
|
import {
|
|
reactive,
|
|
ref
|
|
} from "vue";
|
|
const img = ref("")
|
|
const updateImgFn = () => {
|
|
uplodeImg().then(res => {
|
|
img.value = res.data.image
|
|
addAnimalPicAPI({
|
|
poultry_id: Number(animal_id.value),
|
|
pic: res.data.image
|
|
}).then(res => {
|
|
imgList.unshift(img.value)
|
|
})
|
|
})
|
|
}
|
|
const imgList = reactive([])
|
|
const animal_id = ref("")
|
|
onLoad((option) => {
|
|
animal_id.value = option.id
|
|
animalPicListAPI({
|
|
poultry_id: option.id
|
|
}).then(res => {
|
|
res.data.forEach(item => {
|
|
imgList.push(item.pic)
|
|
})
|
|
})
|
|
|
|
})
|
|
const previewImage = (index) => {
|
|
uni.previewImage({
|
|
urls: imgList,
|
|
current: index,
|
|
|
|
})
|
|
}
|
|
</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> |