刘秀芳 6 dní pred
rodič
commit
210a034579

+ 3 - 1
src/views/old_mini/agri_file/index.vue

@@ -16,7 +16,7 @@
                     <img class="nav-card__icon" :src="item.icon" alt="" />
                     <span class="nav-card__label">{{ t(item.labelKey) }}</span>
                 </div>
-                <div v-if="item.key === 'report' && guideVisible" class="report-guide-bubble">
+                <div v-if="item.key === 'report' && guideVisible && !noFarms" class="report-guide-bubble">
                     <span class="report-guide-bubble__arrow"></span>
                     <div class="report-guide-bubble__content">
                         {{ t("agriFile.diagnosisReportGuidePrefix") }}
@@ -145,6 +145,7 @@ function getMiniUserId() {
     return store.state.home.miniUserId || localStorage.getItem("MINI_USER_ID");
 }
 
+const noFarms = ref(true);
 // ---------- 业务逻辑 ----------
 /** 无果园信息时展示「完善农场信息」弹窗 */
 async function checkCompleteFarmPopup() {
@@ -156,6 +157,7 @@ async function checkCompleteFarmPopup() {
     try {
         const res = await VE_API.questionnaire.getFarms({ id });
         const list = Array.isArray(res?.data) ? res.data : [];
+        noFarms.value = list.length === 0;
         showCompleteFarmPopup.value = list.length === 0;
     } catch (e) {
         console.warn("[agri_file] getFarms failed", e);

+ 38 - 20
src/views/old_mini/agri_file/pages/regionAlbums.vue

@@ -94,6 +94,14 @@ const showUploadPopup = ref(false);
 const farmId = computed(() => route.query.farm_id || "");
 const zoneId = computed(() => route.query.zone_id || "");
 
+const getSelectedFarm = () => {
+    try {
+        return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
+    } catch {
+        return {};
+    }
+};
+
 const regionName = computed(
     () => zoneNameFromApi.value || route.query.name || t("agriFile.zoneOne")
 );
@@ -232,26 +240,36 @@ const handleAdd = () => {
     showUploadPopup.value = true;
 };
 
-const handleUploadConfirm = ({ images, description }) => {
-    // TODO: 正式上传相册接口确定后在此提交
-    // images: OSS 相对路径数组;description: 描述文案
-    ElMessage.success(`已选择 ${images.length} 张照片${description ? ",描述已填写" : ""}`);
-    // 临时本地插入,便于联调样式;正式接口返回后改为 fetchAlbumImages()
-    const today = new Date();
-    const y = today.getFullYear();
-    const m = String(today.getMonth() + 1).padStart(2, "0");
-    const d = String(today.getDate()).padStart(2, "0");
-    const uploadDate = `${y}-${m}-${d}`;
-    const localItems = images.map((filename, index) => ({
-        id: `local-${Date.now()}-${index}`,
-        filename,
-        uploadDate,
-        growText: description || "",
-        watermarkMsg: "",
-        url: `${base_img_url2}${filename}${resize_300 || ""}`,
-        fullUrl: `${base_img_url2}${filename}`,
-    }));
-    imageList.value = [...localItems, ...imageList.value];
+const handleUploadConfirm = async ({ images, date } = {}) => {
+    const cloud_url = Array.isArray(images) ? images : [];
+    if (!cloud_url.length) {
+        ElMessage.warning("请先上传照片");
+        return;
+    }
+    const farm = getSelectedFarm();
+    const farmIdVal = farmId.value || farm.farm_id || farm.id || "";
+    const zoneIdVal = zoneId.value || farm.zone_id || farm.zoneId || "";
+    if (!farmIdVal || !zoneIdVal) {
+        ElMessage.warning("缺少农场或地块信息");
+        return;
+    }
+    try {
+        const res = await VE_API.questionnaire.uploadImages({
+            cloud_url,
+            farm_id: farmIdVal,
+            zone_id: zoneIdVal,
+            category_code: farm.category_code || "",
+            zone_name: regionName.value || farm.variety_name || "",
+            create_time: date,
+        });
+        if (res?.code === 200) {
+            await fetchAlbumImages();
+            return;
+        }
+        ElMessage.error(res?.msg || "上传失败,请稍后再试");
+    } catch {
+        ElMessage.error("上传失败,请稍后再试");
+    }
 };
 
 const goBack = () => {

+ 10 - 0
src/views/old_mini/entry_information/components/selectVariety.vue

@@ -164,8 +164,18 @@ let selectedUid = 0;
 
 const itemPreviewMaps = new Map();
 
+function getResidentPoint() {
+    try {
+        const saved = JSON.parse(sessionStorage.getItem(LOCATION_KEY) || "null");
+        return saved?.point || "";
+    } catch {
+        return "";
+    }
+}
+
 function getDefaultPoint() {
     return (
+        getResidentPoint() ||
         localStorage.getItem("MINI_USER_LOCATION_POINT") ||
         store.state.home.miniUserLocationPoint ||
         DEFAULT_POINT