Browse Source

Merge branch 'farmer' of http://www.sysuimars.cn:3000/feiniao/feiniao-farm-h5 into farmer

刘秀芳 6 days ago
parent
commit
c954285ec3
1 changed files with 12 additions and 47 deletions
  1. 12 47
      src/views/old_mini/monitor/subPages/agriculturalDetail.vue

+ 12 - 47
src/views/old_mini/monitor/subPages/agriculturalDetail.vue

@@ -6,8 +6,8 @@
             <!-- 采样信息卡片 -->
             <div class="card-wrap">
                 <div class="card-box sampling-card">
-                    <div class="sampling-title">采样时间: {{ samplingTime }}</div>
-                    <div class="sampling-desc">{{ samplingDesc }}</div>
+                    <div class="sampling-title">采样时间: {{ imgInfo.samplingTime }}</div>
+                    <div class="sampling-desc">本次飞巡采样了1区、2区和5区,拍摄了 120棵树</div>
                 </div>
             </div>
 
@@ -18,66 +18,32 @@
                     <div class="ratio-tip">出现新梢的果树占比为5%</div>
                     <div class="photo-grid">
                         <div
-                            v-for="photo in photoList"
+                            v-for="photo in imgInfo.imageList"
                             :key="photo.id"
                             class="photo-item"
-                            @click="handlePhotoClick(photo)"
+                            @click="handlePhotoClick(photo.url)"
                         >
                             <img :src="photo.url" alt="农情照片" />
                         </div>
                     </div>
                 </div>
-
             </div>
         </div>
     </div>
 </template>
 
 <script setup>
-import { useRouter, useRoute } from "vue-router";
+import { useRoute } from "vue-router";
 import { ref, onMounted } from "vue";
 import customHeader from "@/components/customHeader.vue";
 import { showImagePreview } from 'vant';
 
-const router = useRouter();
 const route = useRoute();
 
-// 从路由 miniJson 解析 id
-const detailId = ref(null);
-if (route.query.miniJson) {
-    try {
-        const mini = JSON.parse(route.query.miniJson);
-        detailId.value = mini.id ?? null;
-    } catch (_) {
-        console.error("解析 miniJson 失败", _);
-    }
-}
-
-// 采样时间、描述(后续可接接口)
-const samplingTime = ref("2025.05.06");
-const samplingDesc = ref("本次飞巡采样了1区、2区和5区,拍摄了120棵树");
-
-// 农情照片示例列表(后续可替换为接口数据)
-const photoList = ref(
-    Array.from({ length: 25 }).map((_, index) => ({
-        id: index + 1,
-        url: "https://picsum.photos/200/200?random=10",
-    }))
-);
-
-// 图片弹窗相关
-const showImagePopup = ref(false);
-const imgType = ref("");
-const imageList = ref([]);
-const currentImageData = ref({});
-
 const handlePhotoClick = (photo) => {
-    const images = photoList.value.map((item) => item.url);
-    const startIndex = photoList.value.findIndex((item) => item.id === photo.id);
-
     showImagePreview({
-        images,
-        startPosition: startIndex > -1 ? startIndex : 0,
+        images: [photo],
+        startPosition: 0,
         closeable: true,
         showIndex: true,
     });
@@ -87,16 +53,15 @@ onMounted(() => {
     getFarmImagePage();
 });
 
+const imgInfo = ref({});
 const getFarmImagePage = () => {
     VE_API.monitor.getFarmImagePage({
-        // farmId: route.query.farmId,
-        // regionId: route.query.regionId,
-        farmId: 766,
-        regionId: 2,
-        // uploadDate: route.query.date,
+        farmId: route.query.farmId,
+        regionId: route.query.regionId,
+        uploadDate: route.query.date,
     }).then((res) => {
         if (res.code === 0) {
-            photoList.value = res.data;
+            imgInfo.value = res.data;
         }
     });
 };