Ver Fonte

fix:修改演示逻辑

wangsisi há 2 semanas atrás
pai
commit
cd77fa7cc0

+ 73 - 19
src/views/old_mini/agri_file/index.vue

@@ -194,6 +194,8 @@ const router = useRouter();
 const tabBarHeight = computed(() => store.state.home.tabBarHeight);
 
 const DIAGNOSIS_GUIDE_STORAGE_KEY = "AGRI_FILE_DIAGNOSIS_REPORT_GUIDE";
+const ENTRY_FARM_DATA_KEY = "ENTRY_FARM_DATA";
+const CROP_ARCHIVE_KEY = "CROP_ARCHIVE_RECORDS";
 const guideVisible = ref(false);
 
 const defaultCover = require("@/assets/img/home/banner.png");
@@ -225,17 +227,43 @@ const navCards = [
     },
 ];
 
-const zoneList = ref([
-    { id: 1, name: "", count: 2, cover: defaultCover, longitude: 113.612409, latitude: 23.587036 },
-    { id: 2, name: "", count: 2, cover: defaultCover, longitude: 113.615809, latitude: 23.586636 },
-    { id: 3, name: "", count: 2, cover: defaultCover, longitude: 113.613609, latitude: 23.584436 },
-    { id: 4, name: "", count: 2, cover: defaultCover, longitude: 113.615609, latitude: 23.585036 },
-]);
+/** 读取用户新增农场时选中的点位 */
+function readEntryFarmCoordinate() {
+    try {
+        const data = JSON.parse(localStorage.getItem(ENTRY_FARM_DATA_KEY) || "null");
+        if (Array.isArray(data?.coordinate) && data.coordinate.length === 2) {
+            return [Number(data.coordinate[0]), Number(data.coordinate[1])];
+        }
+        const point =
+            data?.point ||
+            localStorage.getItem("GROWTH_REPORT_MAP_POINT") ||
+            localStorage.getItem("selectedFarmPoint");
+        if (typeof point === "string" && /^POINT\s*\(/i.test(point.trim())) {
+            return util.wktCastGeom(point).getFirstCoordinate();
+        }
+    } catch {
+        // ignore
+    }
+    return null;
+}
+
+function buildZoneList(coordinate = readEntryFarmCoordinate() || DEFAULT_CENTER) {
+    return [
+        {
+            id: 1,
+            name: "",
+            count: 2,
+            cover: defaultCover,
+            longitude: Number(coordinate[0]),
+            latitude: Number(coordinate[1]),
+        },
+    ];
+}
+
+const zoneList = ref(buildZoneList());
 
 const albumList = ref([
-    { id: 1, name: "", count: 0, cover: "" },
-    { id: 2, name: "", count: 125, cover: defaultCover },
-    { id: 3, name: "", count: 125, cover: defaultCover },
+    { id: 1, name: "", count: 125, cover: defaultCover },
 ]);
 
 const reportCover = require("@/assets/img/common/sd-1.jpg");
@@ -300,11 +328,21 @@ const patrolList = ref([
     },
 ]);
 
-const cropArchiveList = ref([
-    { id: 1, date: "2025-04-18", zone_name: "", content: "" },
-    { id: 2, date: "2025-04-18", zone_name: "", content: "" },
-    { id: 3, date: "2025-04-10", zone_name: "", content: "" },
-]);
+const MOCK_CROP_ARCHIVE = [
+    { id: "mock-2", date: "2025-04-18", contentKey: "agriFile.cropArchiveAbnormal" },
+    { id: "mock-3", date: "2025-04-10", contentKey: "agriFile.cropArchiveMetric" },
+];
+
+const cropArchiveList = ref([]);
+
+function readCropArchiveAnswers() {
+    try {
+        const list = JSON.parse(localStorage.getItem(CROP_ARCHIVE_KEY) || "[]");
+        return Array.isArray(list) ? list : [];
+    } catch {
+        return [];
+    }
+}
 
 const setMarkerEl = (id, el) => {
     if (el) markerEls[id] = el;
@@ -312,6 +350,8 @@ const setMarkerEl = (id, el) => {
 };
 
 const getFarmCenter = () => {
+    const entryCoordinate = readEntryFarmCoordinate();
+    if (entryCoordinate) return entryCoordinate;
     try {
         const farm = JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
         const wkt = farm.wkt || farm.geom_wkt || farm.farm_location;
@@ -350,9 +390,19 @@ const bindZoneOverlays = () => {
     });
 };
 
+const syncZoneFromEntry = () => {
+    const coordinate = readEntryFarmCoordinate() || getFarmCenter();
+    const zoneName = zoneList.value[0]?.name || "";
+    zoneList.value = buildZoneList(coordinate).map((item) => ({
+        ...item,
+        name: zoneName,
+    }));
+};
+
 const initAlbumMap = async () => {
     await nextTick();
     if (!mapContainer.value) return;
+    syncZoneFromEntry();
     const center = getFarmCenter();
     fileMap.initMap(`POINT(${center[0]} ${center[1]})`, mapContainer.value);
     await nextTick();
@@ -384,11 +434,15 @@ const fillMockLabels = () => {
         subject: t("agriFile.patrolSubject"),
         issue: t("agriFile.patrolIssue"),
     }));
-    cropArchiveList.value = cropArchiveList.value.map((item, index) => ({
-        ...item,
-        zone_name: albumName,
-        content: t(index % 2 === 0 ? "agriFile.cropArchiveMetric" : "agriFile.cropArchiveAbnormal"),
-    }));
+    cropArchiveList.value = [
+        ...readCropArchiveAnswers(),
+        ...MOCK_CROP_ARCHIVE.map((item) => ({
+            id: item.id,
+            date: item.date,
+            zone_name: albumName,
+            content: t(item.contentKey),
+        })),
+    ];
 };
 
 const goAddZone = (type) => {

+ 25 - 10
src/views/old_mini/agri_file/pages/albumMap.vue

@@ -33,6 +33,7 @@ const fileMap = new FileMap();
 
 const defaultCover = require("@/assets/img/home/banner.png");
 const DEFAULT_MAP_LOCATION = "POINT(113.6142086995688 23.585836479509055)";
+const ENTRY_FARM_DATA_KEY = "ENTRY_FARM_DATA";
 
 const userLocation = ref(
     store.state.home.miniUserLocation ||
@@ -40,20 +41,14 @@ const userLocation = ref(
         "113.61702297075017,23.584863449735067"
 );
 
+/** 与外层农情相册一致:仅一个分区一 */
 const MOCK_ZONES = [
-    { id: 1, nameKey: "agriFile.zoneOne", dlng: -0.00115, dlat: 0.00055, delta: 0.00155 },
-    { id: 2, nameKey: "agriFile.zoneTwo", dlng: 0.00105, dlat: -0.00095, delta: 0.00128 },
+    { id: 1, nameKey: "agriFile.zoneOne", dlng: 0, dlat: 0, delta: 0.00155 },
 ];
 
 const MOCK_PHOTOS = [
-    { id: 1, dlng: -0.00185, dlat: 0.00115 },
-    { id: 2, dlng: 0.00155, dlat: 0.00075 },
-    { id: 3, dlng: -0.00055, dlat: -0.00135 },
-    { id: 4, dlng: 0.00135, dlat: -0.00075 },
-    { id: 5, dlng: -0.00235, dlat: -0.00015 },
-    { id: 6, dlng: 0.00015, dlat: 0.00155 },
-    { id: 7, dlng: 0.00255, dlat: -0.00135 },
-    { id: 8, dlng: -0.00015, dlat: -0.00195 },
+    // 略偏北,避免与下方「分区一」标签重叠
+    { id: 1, dlng: 0, dlat: 0.00042 },
 ];
 
 function squarePolygonWkt(lng, lat, delta = 0.0014) {
@@ -108,7 +103,26 @@ function toPointWkt(value) {
     return wkbHexToPointWkt(value);
 }
 
+function getEntryFarmPoint() {
+    try {
+        const data = JSON.parse(localStorage.getItem(ENTRY_FARM_DATA_KEY) || "null");
+        if (Array.isArray(data?.coordinate) && data.coordinate.length === 2) {
+            return `POINT(${Number(data.coordinate[0])} ${Number(data.coordinate[1])})`;
+        }
+        const point = toPointWkt(data?.point);
+        if (point) return point;
+    } catch {
+        // ignore
+    }
+    return (
+        toPointWkt(localStorage.getItem("GROWTH_REPORT_MAP_POINT")) ||
+        toPointWkt(localStorage.getItem("selectedFarmPoint"))
+    );
+}
+
 function getFarmMapLocation() {
+    const entryPoint = getEntryFarmPoint();
+    if (entryPoint) return entryPoint;
     const farmData = getFarmData();
     const candidates = [farmData.wkt, farmData.geom_wkt, farmData.farm_location];
     for (const item of candidates) {
@@ -120,6 +134,7 @@ function getFarmMapLocation() {
 
 function getDefaultMapLocation() {
     return (
+        getEntryFarmPoint() ||
         toPointWkt(localStorage.getItem("MINI_USER_LOCATION_POINT")) ||
         toPointWkt(store.state.home.miniUserLocationPoint) ||
         getFarmMapLocation()

+ 34 - 79
src/views/old_mini/agri_file/pages/growthTrack.vue

@@ -22,10 +22,6 @@
                             <span class="growth-hero__tag growth-hero__tag--zone">{{ zoneName }}</span>
                         </div>
                         <div class="growth-hero__reason">{{ reason }}</div>
-                    </div> 
-                    <div class="growth-hero__share" @click="handleShare">
-                        <Icon name="share" />
-                        <span>{{ t("agriFile.forward") }}</span>
                     </div>
                 </div>
             </div>
@@ -80,12 +76,6 @@
                 </div>
             </div>
         </div>
-        <div class="guide-card__upload" @click="handleUploadClick">
-            <el-icon>
-                <Plus />
-            </el-icon>
-            <span>{{ t("agriFile.uploadPhoto") }}</span>
-        </div>
         <album-upload-popup v-model:show="showUploadPopup" @confirm="handleUploadConfirm" />
         <tip-popup v-model:show="showSuccessPopup" type="executeSuccess" text="您已上传成功" text2="请等待诊断报告生成" hideBtn>
             <template #footer>
@@ -101,14 +91,12 @@
 <script setup>
 import { computed, nextTick, onActivated, ref } from "vue";
 import { useRoute, useRouter } from "vue-router";
-import { Icon } from 'vant';
 import { ElMessage } from "element-plus";
 import customHeader from "@/components/customHeader.vue";
 import albumUploadPopup from "../components/albumUploadPopup.vue";
 import leaveConfirmPopup from "@/components/popup/leaveConfirmPopup.vue";
 import tipPopup from "@/components/popup/tipPopup.vue";
 import { useI18n } from "@/i18n";
-import wx from "weixin-js-sdk";
 
 const { t } = useI18n();
 const route = useRoute();
@@ -160,46 +148,47 @@ const situationList = [
     { nameKey: "agriFile.rootAbnormal" },
 ];
 
-const handleShare = () => {
-    const query = {
-        askInfo: { title: "转发巡园要点", content: "是否分享给好友" },
-        shareText: "速长窗口不追肥?后期发育慢人一步,直接掉队!",
-        targetUrl: "growth_track",
-        paramsPage: JSON.stringify({
-            id: route.query.id,
-            type: route.query.type,
-            fromShare: 1,
-        }),
-        imageUrl: "https://birdseye-img.sysuimars.com/temp/field.png",
-    };
-    wx.miniProgram.navigateTo({
-        url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
-    });
-};
+/** 作物档案本地记录(提交互动后写入,农事档案页读取) */
+const CROP_ARCHIVE_KEY = "CROP_ARCHIVE_RECORDS";
+
+function formatToday() {
+    const now = new Date();
+    const y = now.getFullYear();
+    const m = String(now.getMonth() + 1).padStart(2, "0");
+    const d = String(now.getDate()).padStart(2, "0");
+    return `${y}-${m}-${d}`;
+}
+
+function saveCropArchiveAnswer(record) {
+    let list = [];
+    try {
+        list = JSON.parse(localStorage.getItem(CROP_ARCHIVE_KEY) || "[]");
+    } catch {
+        list = [];
+    }
+    if (!Array.isArray(list)) list = [];
+    list.unshift(record);
+    localStorage.setItem(CROP_ARCHIVE_KEY, JSON.stringify(list));
+}
 
 const handleSubmit = () => {
     if (selectedOptionId.value == null) {
         ElMessage.warning(t("agriFile.pleaseSelectOption"));
         return;
     }
-    ElMessage.success(t("agriFile.submitSuccess"));
-};
-
-const needDraw = ref(true);
-
-/** 先跳小程序校验定位;通过后由小程序直接打开勾画/病虫害/上传目标页 */
-const handleUploadClick = () => {
-    const query = [
-        `needDraw=${needDraw.value ? 1 : 0}`,
-        `isAbnormal=${isAbnormal.value ? 1 : 0}`,
-        route.query.id ? `id=${encodeURIComponent(String(route.query.id))}` : "",
-        route.query.type ? `type=${encodeURIComponent(String(route.query.type))}` : "",
-    ]
-        .filter(Boolean)
-        .join("&");
-    wx.miniProgram.navigateTo({
-        url: `/pages/subPages/farm_location_check/index?${query}`,
+    const option = interactOptions.value.find(
+        (item) => item.id === selectedOptionId.value
+    );
+    saveCropArchiveAnswer({
+        id: `answer-${Date.now()}`,
+        date: formatToday(),
+        zone_name: t("agriFile.zoneOne"),
+        content: option?.name || "",
+        optionId: option?.id ?? selectedOptionId.value,
     });
+    selectedOptionId.value = null;
+    ElMessage.success(t("agriFile.submitSuccess"));
+    router.replace("/agri_file");
 };
 
 const handleUploadConfirm = () => {
@@ -308,17 +297,6 @@ onActivated(() => {
                 align-items: center;
                 gap: 8px;
             }
-
-            &__share {
-                // flex: none;
-                display: flex;
-                align-items: center;
-                gap: 4px;
-                padding: 4px 14px;
-                border-radius: 25px;
-                background: rgba(19, 125, 209, 0.5);
-                color: #fff;
-            }
         }
     }
 
@@ -471,29 +449,6 @@ onActivated(() => {
         }
     }
 
-    .guide-card__upload {
-        position: fixed;
-        right: 7px;
-        bottom: 94px;
-        z-index: 10;
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        justify-content: center;
-        width: 58px;
-        height: 58px;
-        border-radius: 50%;
-        background: #2199f8;
-        color: #fff;
-        box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.1);
-        font-size: 15px;
-    }
-
-    .guide-card__upload span {
-        margin-top: 3px;
-        font-size: 10px;
-    }
-
     .guide-title {
         position: relative;
         z-index: 1;

+ 2 - 11
src/views/old_mini/agri_file/pages/regionAlbums.vue

@@ -31,7 +31,6 @@
                 >
                     <div class="album-group__header">
                         <div class="album-group__date">{{ group.dateLabel }}</div>
-                        <div class="album-group__remark">{{ group.remark || '备注备注备注备注' }}</div>
                     </div>
                     <div class="album-group__grid">
                         <div
@@ -47,10 +46,6 @@
             </div>
         </div>
 
-        <div class="region-albums__fab" @click="handleAdd">
-            <el-icon :size="28" color="#fff"><Plus /></el-icon>
-        </div>
-
         <album-upload-popup
             v-model:show="showUploadPopup"
             @confirm="handleUploadConfirm"
@@ -60,7 +55,7 @@
             v-model:show="showPreview"
             :images="previewImages"
             :start-index="previewIndex"
-            :show-remark="true"
+            :show-remark="false"
             @remark-change="handleRemarkChange"
             @remark-confirm="handleRemarkConfirm"
         />
@@ -71,7 +66,7 @@
 import { computed, onActivated, onDeactivated, onMounted, ref } from "vue";
 import { useRoute, useRouter } from "vue-router";
 import { ElMessage } from "element-plus";
-import { ArrowLeftBold, Plus } from "@element-plus/icons-vue";
+import { ArrowLeftBold } from "@element-plus/icons-vue";
 import { base_img_url2, resize_300 } from "@/api/config";
 import { useI18n } from "@/i18n";
 import ImagePreviewPopup from "@/components/popup/ImagePreviewPopup.vue";
@@ -253,10 +248,6 @@ const handleRemarkConfirm = ({ index, remark, image }) => {
     }
 };
 
-const handleAdd = () => {
-    showUploadPopup.value = true;
-};
-
 const handleUploadConfirm = ({ images, description }) => {
     // TODO: 正式上传相册接口确定后在此提交
     // images: OSS 相对路径数组;description: 描述文案

+ 63 - 10
src/views/old_mini/entry_information/components/baInformation.vue

@@ -83,8 +83,11 @@ const FORM_KEY = "ENTRY_BA_FORM";
 const STEP_KEY = "ENTRY_INFORMATION_STEP";
 /** 本地标记:用户已新增农场 */
 const HAS_FARM_KEY = "HAS_ENTRY_FARM";
+/** 新增农场信息(点位、品类等) */
+const ENTRY_FARM_DATA_KEY = "ENTRY_FARM_DATA";
 /** 默认定位:河北宁晋县 */
 const DEFAULT_POINT = "POINT(114.91863572509733 37.67702031436258)";
+const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
 /** 河北主要作物(固定下拉选项) */
 const CROP_OPTIONS = ["玉米", "冬小麦", "水稻", "马铃薯", "大豆", "谷子", "高粱", "莜麦"];
 
@@ -96,7 +99,7 @@ let previewMap = null;
 const form = reactive({
     name: "",
     phone: "",
-    crop: "",
+    crop: undefined,
     location: "",
 });
 
@@ -142,7 +145,7 @@ function restoreFormDraft() {
     if (!draft) return;
     if (draft.name != null) form.name = draft.name;
     if (draft.phone != null) form.phone = draft.phone;
-    if (draft.crop != null) form.crop = draft.crop;
+    if (draft.crop) form.crop = draft.crop;
 }
 
 function utilWktToCoordinate(point) {
@@ -205,24 +208,73 @@ const goSelectLocation = () => {
 function clearFormDraft() {
     form.name = "";
     form.phone = "";
-    form.crop = "";
+    form.crop = undefined;
     form.location = "";
     sessionStorage.removeItem(FORM_KEY);
     sessionStorage.removeItem(LOCATION_KEY);
     sessionStorage.removeItem(STEP_KEY);
 }
 
+/** 根据点位反查地区名(区县优先) */
+async function resolveRegionName(point) {
+    const coordinate = utilWktToCoordinate(point);
+    if (!coordinate) return "";
+    try {
+        const { result } = await VE_API.old_mini_map.location({
+            key: MAP_KEY,
+            location: `${coordinate[1]},${coordinate[0]}`,
+        });
+        return (
+            result?.ad_info?.district ||
+            result?.ad_info?.city ||
+            result?.address_component?.district ||
+            result?.address_component?.city ||
+            ""
+        );
+    } catch {
+        return "";
+    }
+}
+
 const handleNext = async () => {
     if (!formRef.value) return;
     try {
         await formRef.value.validate();
-        localStorage.setItem(HAS_FARM_KEY, "1");
-        clearFormDraft();
-        router.replace("/growth_report");
-        ElMessage.success("上传成功,报告正在生成中...");
     } catch {
-        // 校验未通过
+        return;
+    }
+
+    const saved = readJson(LOCATION_KEY);
+    let region = saved?.region || "";
+    if (!region && form.location) {
+        region = await resolveRegionName(form.location);
     }
+    if (!region) {
+        ElMessage.warning("无法识别种植点位所属地区,请重新选择");
+        return;
+    }
+
+    const crop = form.crop;
+    const point = form.location || saved?.point || "";
+    const farmData = {
+        name: form.name,
+        phone: form.phone,
+        crop,
+        point,
+        coordinate: saved?.coordinate || null,
+        region,
+        adcode: saved?.adcode || "",
+    };
+    localStorage.setItem(ENTRY_FARM_DATA_KEY, JSON.stringify(farmData));
+    if (point) {
+        localStorage.setItem("GROWTH_REPORT_MAP_POINT", point);
+        localStorage.setItem("selectedFarmPoint", point);
+    }
+    VE_API.questionnaire.generateReport({ region, crop }).catch(() => {});
+    localStorage.setItem(HAS_FARM_KEY, "1");
+    clearFormDraft();
+    router.replace("/growth_report");
+    ElMessage.success("上传成功,报告正在生成中...");
 };
 
 onMounted(() => {
@@ -384,13 +436,14 @@ onBeforeUnmount(() => {
                 justify-content: flex-end;
                 margin: 0;
                 font-size: 15px;
-                color: #2199f8;
+                color: #1a1a1a;
                 line-height: 32px;
                 transform: none;
             }
 
+            /* EP:is-transparent 表示未选中的占位态,不是隐藏文字 */
             :deep(.el-select__placeholder.is-transparent) {
-                color: transparent;
+                color: #2199f8;
             }
 
             :deep(.el-select__suffix) {

+ 2 - 1
src/views/old_mini/entry_information/map/selectLocationMap.js

@@ -13,7 +13,8 @@ export let mapLocation = reactive({
 });
 
 export const POINT_ICON = {
-  resident: require("@/assets/img/map/current-point.png"),
+  // resident: require("@/assets/img/map/current-point.png"),
+  resident: require("@/assets/img/map/zhongzhi-point.png"),
   plant: require("@/assets/img/map/zhongzhi-point.png"),
   current: require("@/assets/img/home/garden-point.png"),
 };

+ 25 - 6
src/views/old_mini/entry_information/selectLocation.vue

@@ -56,13 +56,15 @@ const iconSrc =
 const userLocation = ref(
     store.state.home.miniUserLocation || localStorage.getItem("MINI_USER_LOCATION") || DEFAULT_USER_LOCATION
 );
-/** 搜索选中时带出的区县编码 */
+/** 搜索选中时带出的区县编码、地区名 */
 const selectedAdcode = ref("");
+const selectedRegion = ref("");
 
 const selectLocationMap = new SelectLocationMap({
     iconSrc,
     onMapClick: () => {
         selectedAdcode.value = "";
+        selectedRegion.value = "";
     },
 });
 
@@ -82,16 +84,25 @@ function toPointWkt(coordinate) {
 }
 
 async function fetchAdcodeByCoordinate(coordinate) {
-    if (!coordinate?.length) return "";
+    if (!coordinate?.length) return { adcode: "", region: "" };
     try {
         const { result } = await VE_API.old_mini_map.location({
             key: MAP_KEY,
             location: `${coordinate[1]},${coordinate[0]}`,
         });
         const adcode = result?.ad_info?.adcode;
-        return adcode != null && adcode !== "" ? String(adcode) : "";
+        const region =
+            result?.ad_info?.district ||
+            result?.ad_info?.city ||
+            result?.address_component?.district ||
+            result?.address_component?.city ||
+            "";
+        return {
+            adcode: adcode != null && adcode !== "" ? String(adcode) : "",
+            region: region || "",
+        };
     } catch {
-        return "";
+        return { adcode: "", region: "" };
     }
 }
 
@@ -107,14 +118,18 @@ onUnmounted(() => {
 const handleLocationChange = (payload) => {
     if (!payload?.coordinateArray) {
         selectedAdcode.value = "";
+        selectedRegion.value = "";
         return;
     }
     selectedAdcode.value = payload.adcode ? String(payload.adcode) : "";
+    selectedRegion.value =
+        payload.item?.district || payload.item?.city || payload.city || "";
     selectLocationMap.setMapPosition(payload.coordinateArray);
 };
 
 const handleLocate = () => {
     selectedAdcode.value = "";
+    selectedRegion.value = "";
     const point =
         localStorage.getItem("MINI_USER_LOCATION_POINT") ||
         store.state.home.miniUserLocationPoint ||
@@ -133,8 +148,11 @@ const handleSubmit = async () => {
     }
     const point = toPointWkt(coordinate);
     let adcode = selectedAdcode.value;
-    if (!adcode) {
-        adcode = await fetchAdcodeByCoordinate(coordinate);
+    let region = selectedRegion.value;
+    if (!adcode || !region) {
+        const meta = await fetchAdcodeByCoordinate(coordinate);
+        adcode = adcode || meta.adcode;
+        region = region || meta.region;
     }
     sessionStorage.setItem(
         sessionKey,
@@ -142,6 +160,7 @@ const handleSubmit = async () => {
             point,
             coordinate: [Number(coordinate[0]), Number(coordinate[1])],
             adcode: adcode || "",
+            region: region || "",
         })
     );
     router.back();

+ 23 - 2
src/views/old_mini/growth_report/index.vue

@@ -80,6 +80,17 @@ const DEFAULT_MAP_POINT = "POINT(113.6142086995688 23.585836479509055)";
 const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
 const LOCATION_SESSION_KEY = "GROWTH_REPORT_LOCATION";
 const MAP_POINT_STORAGE_KEY = "GROWTH_REPORT_MAP_POINT";
+const ENTRY_FARM_DATA_KEY = "ENTRY_FARM_DATA";
+
+function readEntryFarmData() {
+    try {
+        return JSON.parse(localStorage.getItem(ENTRY_FARM_DATA_KEY) || "null");
+    } catch {
+        return null;
+    }
+}
+
+const entryFarmData = readEntryFarmData();
 
 const menuIcon = require("@/assets/img/common/farm-active.png");
 
@@ -96,12 +107,13 @@ const mapContainer = ref(null);
 const growthReportMap = new GrowthReportMap();
 const locationName = ref("");
 const currentMapPoint = ref(
-    localStorage.getItem(MAP_POINT_STORAGE_KEY) ||
+    entryFarmData?.point ||
+        localStorage.getItem(MAP_POINT_STORAGE_KEY) ||
         localStorage.getItem("selectedFarmPoint") ||
         store.state.home.miniUserLocationPoint ||
         DEFAULT_MAP_POINT
 );
-const currentCropName = ref("水稻");
+const currentCropName = ref(entryFarmData?.crop || "水稻");
 const activeMenuKey = ref("hot-drought-2");
 const panelHeight = ref(280);
 const inviteBottom = computed(() => panelHeight.value);
@@ -150,6 +162,13 @@ function saveCurrentMapPoint(point) {
     localStorage.setItem(MAP_POINT_STORAGE_KEY, point);
 }
 
+function syncEntryFarmData() {
+    const data = readEntryFarmData();
+    if (!data) return;
+    if (data.crop) currentCropName.value = data.crop;
+    if (data.point) saveCurrentMapPoint(data.point);
+}
+
 const initMap = async () => {
     await nextTick();
     if (!mapContainer.value) return;
@@ -331,11 +350,13 @@ const handlePanelHeightChange = (height) => {
 };
 
 onMounted(() => {
+    syncEntryFarmData();
     getLocationName();
     initMap();
     tryOpenInviteEntryPopup();
 });
 onActivated(() => {
+    syncEntryFarmData();
     const applied = applySelectedLocation();
     if (!applied) getLocationName();
     initMap();