| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <div class="agricultural-detail">
- <custom-header name="农事详情"></custom-header>
- <div class="detail-content">
- <!-- 采样信息卡片 -->
- <div class="card-wrap">
- <div class="card-box sampling-card">
- <div class="sampling-title">采样时间: {{ imgInfo.samplingTime }}</div>
- <div class="sampling-desc">本次采样{{ imgInfo.regions }},拍摄了 {{ imgInfo.total }} 棵树</div>
- </div>
- </div>
- <!-- 农情照片卡片 -->
- <div class="card-wrap">
- <div class="card-box photo-card">
- <div class="card-title">农情照片</div>
- <div class="ratio-tip">{{ route.query.content }}</div>
- <div class="photo-grid">
- <div
- v-for="(photo, index) in imgInfo.imageList"
- :key="photo.id"
- class="photo-item"
- @click="handlePhotoClick(index)"
- >
- <img :src="photo.url" alt="农情照片" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { useRoute } from "vue-router";
- import { ref, onActivated, computed } from "vue";
- import customHeader from "@/components/customHeader.vue";
- import { showImagePreview } from 'vant';
- const route = useRoute();
- const previewImages = computed(() => {
- const list = imgInfo.value?.imageList || [];
- return list.map((item) => item?.url).filter(Boolean);
- });
- const handlePhotoClick = (index) => {
- const images = previewImages.value;
- const safeIndex = Math.min(Math.max(Number(index) || 0, 0), Math.max(images.length - 1, 0));
- showImagePreview({
- images,
- startPosition: safeIndex,
- closeable: true,
- showIndex: true,
- });
- };
- onActivated(() => {
- getFarmImagePage();
- });
- const imgInfo = ref({});
- const getFarmImagePage = () => {
- VE_API.monitor.getFarmImagePage({
- id: route.query.id
- }).then((res) => {
- if (res.code === 0) {
- imgInfo.value = res.data;
- }
- });
- };
- </script>
- <style lang="scss" scoped>
- .agricultural-detail {
- min-height: 100vh;
- width: 100%;
- background: #f2f3f5;
- .detail-content {
- padding: 12px;
- padding-bottom: 24px;
- box-sizing: border-box;
- .card-wrap {
- margin-bottom: 12px;
- .card-box {
- background: #fff;
- border-radius: 8px;
- padding: 12px 16px;
- box-sizing: border-box;
- }
- .sampling-card {
- .sampling-title {
- font-size: 16px;
- font-weight: 500;
- color: #333;
- margin-bottom: 6px;
- }
- .sampling-desc {
- font-size: 14px;
- color: rgba(0, 0, 0, 0.5);
- }
- }
- .photo-card {
- .card-title {
- font-size: 16px;
- font-weight: bold;
- color: #333;
- margin-bottom: 12px;
- }
- .ratio-tip {
- font-size: 14px;
- color: #2199f8;
- padding: 10px 12px;
- background: rgba(33, 153, 248, 0.08);
- border-radius: 8px;
- }
- .photo-grid {
- margin-top: 12px;
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- grid-gap: 6px;
- .photo-item {
- position: relative;
- width: 100%;
- padding-bottom: 100%;
- border-radius: 8px;
- overflow: hidden;
- background: #e5f5e5;
- img {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
- object-fit: cover;
- display: block;
- }
- }
- }
- }
- }
- }
- }
- .image-popup {
- width: 327px;
- border-radius: 8px;
- .popup-content {
- width: 100%;
- }
- }
- </style>
|