| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- <template>
- <div class="growth-report-page" :style="{ height: `calc(100vh - ${tabBarHeight}px)` }">
- <div class="report-content">
- <div class="map-container" ref="mapContainer"></div>
- <!-- Overlay 宿主:无范围时挂到地图方框下方 -->
- <div ref="noRangeTipRef" class="no-range-tip" :style="{ display: noFarmRange ? 'inline-flex' : 'none' }"
- @click.stop="goAddZone('farm')">
- <span>勾画区域,获地块级长势报告</span>
- <el-icon class="no-range-tip__arrow">
- <ArrowRight />
- </el-icon>
- </div>
- </div>
- <!-- 左上角:位置切换 -->
- <div class="location-bar">
- <el-icon class="location-bar__icon">
- <LocationFilled />
- </el-icon>
- <span class="location-bar__name van-ellipsis">{{ locationName }}</span>
- <span v-if="hasSelectedFarm()" class="location-bar__action" @click="handleSwitchFarm">切换农场</span>
- </div>
- <div class="growth-top">
- <!-- 浮窗:长势互动(按 物候 → 异常 → 土壤根系 依次展示) -->
- <div v-if="currentCard" class="interact-float">
- <div class="interact-card" :class="`interact-card--${currentCard.kind}`">
- <el-icon class="interact-card__close" @click="dismissCurrentCard">
- <Close />
- </el-icon>
- <div class="interact-card__qa">
- <div class="interact-card__question">
- <div class="interact-card__question-icon">
- <img class="interact-card__question-icon-img" :src="currentCard.icon" alt="">
- </div>
- <span>{{ currentCard.title }}</span>
- </div>
- <!-- 物候 / 土壤根系:选项卡片 -->
- <div v-if="currentCard.kind === 'options'" class="interact-card__options">
- <div
- v-for="item in currentCard.options"
- :key="item.id"
- class="interact-option"
- :class="{
- selected: selectedOptionId === item.id,
- disabled: interactSubmitting,
- }"
- @click="handleInteractOptionClick(item)"
- >
- <span class="interact-option__text">{{ item.name }}</span>
- </div>
- </div>
- <!-- 异常:结论描述 + 立即巡园 -->
- <div v-else class="interact-card__abnormal">
- <div class="interact-card__desc">{{ currentCard.desc }}</div>
- <div class="interact-card__cta" @click="handlePatrolNow">
- 立即巡园
- <el-icon><ArrowRightBold /></el-icon>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="growth-top__content">
- <div class="invite-group">
- <div class="invite-btn" @click="handleLocateToCenter">
- <img class="current-icon" src="@/assets/img/home/current.png" alt="">
- </div>
- <div class="invite-btn" @click="handleInvite('service')">
- <img class="invite-icon" src="@/assets/img/home/user-icon.png" alt="">
- 邀请农服
- </div>
- <div class="invite-btn" @click="handleInvite('farmer')">
- <img class="invite-icon" src="@/assets/img/home/user-icon.png" alt="">
- 邀请农户
- </div>
- </div>
- </div>
- </div>
- <crop-alert-panel :crop-name="currentCropName" :farm-id="selectedFarmId" :county-code="countyCode"
- @zone-change="handleZoneChange" @height-change="handlePanelHeightChange" />
- </div>
- <!-- 恢复种植弹窗 -->
- <restore-planting-popup />
- </template>
- <script setup>
- import { computed, nextTick, onActivated, onMounted, ref } from "vue";
- import { useRouter } from "vue-router";
- import { useStore } from "vuex";
- import { ElMessage } from "element-plus";
- import { ArrowRight, Close, LocationFilled } from "@element-plus/icons-vue";
- import { convertPointToArray } from "@/utils/index";
- import { fetchRegeo, toLocationParam } from "@/utils/tiandituLocation";
- import GrowthReportMap from "./growthReportMap.js";
- import CropAlertPanel from "./components/CropAlertPanel.vue";
- import wx from "weixin-js-sdk";
- import restorePlantingPopup from "@/components/popup/restorePlantingPopup.vue";
- const router = useRouter();
- const DEFAULT_MAP_POINT = "POINT(113.6142086995688 23.585836479509055)";
- const LOCATION_SESSION_KEY = "GROWTH_REPORT_LOCATION";
- const MAP_POINT_STORAGE_KEY = "GROWTH_REPORT_MAP_POINT";
- /** 无农场时逆地理得到的区县码,供点位预警使用 */
- const COUNTY_CODE_STORAGE_KEY = "GROWTH_REPORT_COUNTY_CODE";
- const periodIcon = require("@/assets/img/agricultural/period.png");
- const lightningIcon = require("@/assets/img/agricultural/lightning.png");
- const soilIcon = require("@/assets/img/agricultural/soil.png");
- const store = useStore();
- const tabBarHeight = computed(() => store.state.home.tabBarHeight);
- const mapContainer = ref(null);
- const noRangeTipRef = ref(null);
- const growthReportMap = new GrowthReportMap();
- const locationName = ref("");
- /** status≠1 时展示中心勾画引导 */
- const noFarmRange = ref(false);
- const selectedFarmId = ref(localStorage.getItem("selectedFarmId") || "");
- /** 无农场时区县码(逆地理 adcode) */
- const countyCode = ref(localStorage.getItem(COUNTY_CODE_STORAGE_KEY) || "");
- /** CropAlertPanel 当前选中分区 */
- const panelZoneId = ref(null);
- /** 面板叠在地图上的高度,中心点按「面板以上」可视区计算 */
- const panelOverlayHeight = ref(280);
- const currentCropName = computed(() => {
- // 依赖 selectedFarmId,切换农场后重新读缓存
- void selectedFarmId.value;
- const farm = getSelectedFarm();
- return (
- farm.variety_name ||
- farm.crop_name ||
- farm.farm_variety ||
- ""
- );
- });
- const getSelectedFarm = () => {
- try {
- return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
- } catch {
- return {};
- }
- };
- /** 登录写入的用户定位:lng,lat */
- const getMiniUserLocationText = () => localStorage.getItem("MINI_USER_LOCATION") || "";
- /** 登录写入的用户定位 POINT;无 POINT 时用 lng,lat 拼 */
- const getMiniUserLocationPoint = () => {
- const point =
- localStorage.getItem("MINI_USER_LOCATION_POINT") ||
- store.state.home.miniUserLocationPoint ||
- "";
- if (typeof point === "string" && /^POINT\s*\(/i.test(point.trim())) {
- return point.trim();
- }
- const text = getMiniUserLocationText();
- if (text.includes(",")) {
- const [lng, lat] = text.split(",").map((s) => s.trim());
- if (lng && lat) return `POINT(${lng} ${lat})`;
- }
- return DEFAULT_MAP_POINT;
- };
- const hasSelectedFarm = () => {
- const farm = getSelectedFarm();
- const id =
- selectedFarmId.value ||
- localStorage.getItem("selectedFarmId") ||
- farm.farm_id ||
- farm.id;
- return id != null && id !== "";
- };
- /** 地图中心优先用农场 farm_location */
- const resolveFarmLocationWkt = (farm = getSelectedFarm()) => {
- const candidates = [farm.farm_location, farm.wkt, farm.geom_wkt, localStorage.getItem("selectedFarmPoint")];
- for (const item of candidates) {
- if (typeof item === "string" && /^POINT\s*\(/i.test(item.trim())) {
- return item.trim();
- }
- }
- return getMiniUserLocationPoint();
- };
- /** 有农场用农场点,无农场用登录用户点位 */
- const resolveMapCenterPoint = (farm = getSelectedFarm()) => {
- if (hasSelectedFarm()) return resolveFarmLocationWkt(farm);
- return getMiniUserLocationPoint();
- };
- const currentMapPoint = ref(resolveMapCenterPoint());
- const syncSelectedFarmId = () => {
- const next = String(
- localStorage.getItem("selectedFarmId") || getSelectedFarm().farm_id || getSelectedFarm().id || ""
- );
- // 切农场后旧 panelZoneId 属于上一农场,必须先清掉再等 CropAlertPanel 回传
- if (next !== selectedFarmId.value) {
- panelZoneId.value = null;
- }
- selectedFarmId.value = next;
- };
- /** status=1 有范围;否则展示勾画引导(无农场不展示) */
- async function fetchFarmRangeStatus() {
- const farm = getSelectedFarm();
- const farmId = selectedFarmId.value || farm.farm_id || farm.id;
- // 只信面板当前分区,禁止回退 selectedFarmData.zone_id(易与 farm_id 错配)
- const zoneId = panelZoneId.value;
- // 无农场不展示勾画引导
- if (farmId == null || farmId === "") {
- noFarmRange.value = false;
- await syncNoRangeGuide();
- return;
- }
- if (zoneId == null || zoneId === "") {
- noFarmRange.value = true;
- await syncNoRangeGuide();
- return;
- }
- try {
- const res = await VE_API.questionnaire.checkZoneRange({
- farm_id: farmId,
- zone_id: zoneId,
- });
- noFarmRange.value = Number(res?.data?.status) !== 1;
- } catch (e) {
- console.warn("[growth_report] checkZoneRange failed", e);
- noFarmRange.value = true;
- }
- await syncNoRangeGuide();
- }
- /** 无范围时在地图中心点画示意方框 + 下方提示 */
- async function syncNoRangeGuide() {
- await nextTick();
- if (!growthReportMap.kmap) return;
- if (!noFarmRange.value) {
- growthReportMap.clearNoRangeGuide();
- return;
- }
- const coordinate =
- growthReportMap.getCurrentCoordinate() ||
- convertPointToArray(currentMapPoint.value)?.map(Number);
- if (!coordinate?.length) return;
- growthReportMap.showNoRangeGuide(coordinate, noRangeTipRef.value);
- }
- const goAddZone = (type) => {
- router.push({
- path: "/add_zone",
- query: {
- type,
- isSuccessPopup: "1",
- },
- });
- };
- // ---------- 顶部巡园互动浮窗 ----------
- /** 卡片队列:物候(pheno) → 异常(abnormal) → 土壤根系(soil_root),缺失分块不入队 */
- const interactCards = ref([]);
- const currentCardIndex = ref(0);
- const interactDismissed = ref(false);
- const currentCard = computed(() =>
- interactDismissed.value ? null : interactCards.value[currentCardIndex.value] || null
- );
- const selectedOptionId = ref(null);
- const interactSubmitting = ref(false);
- /** 防止切换分区时旧请求回写 */
- let interactFetchToken = 0;
- function formatToday() {
- const d = new Date();
- const y = d.getFullYear();
- const m = String(d.getMonth() + 1).padStart(2, "0");
- const day = String(d.getDate()).padStart(2, "0");
- return `${y}-${m}-${day}`;
- }
- function getRequestErrorMessage(err) {
- const data = err?.response?.data;
- if (typeof data === "string" && data) return data;
- if (data?.msg) return data.msg;
- if (data?.message) return data.message;
- if (err?.message) return err.message;
- return "提交失败,请稍后再试";
- }
- /** interact_options / options 可能是 JSON 字符串、字符串数组或 {label,value} 数组 */
- function parseInteractOptions(raw) {
- let list = raw;
- if (typeof raw === "string") {
- try {
- list = JSON.parse(raw);
- } catch {
- return [];
- }
- }
- if (!Array.isArray(list)) return [];
- return list
- .map((item, index) => ({
- id: index + 1,
- name:
- item && typeof item === "object"
- ? String(item.label ?? item.value ?? "")
- : String(item),
- }))
- .filter((item) => item.name);
- }
- function resolveSectionOptions(section = {}) {
- return parseInteractOptions(section.interact_options ?? section.options);
- }
- /** getTypesTask 分块 → 按顺序的浮窗卡片(无对应分块则不显示) */
- function buildInteractCards(data = {}, ctx = {}) {
- const cards = [];
- const pushOptionsCard = (key, section, icon) => {
- if (!section) return;
- const title =
- section.interact_problem ||
- section.question ||
- section.interact_title ||
- section.interaction_title ||
- section.title ||
- "";
- const options = resolveSectionOptions(section);
- if (!title && !options.length) return;
- cards.push({ key, kind: "options", icon, title, options, raw: section, ...ctx });
- };
- // 1. 物候:问题 + 选项;status 有值(已提交)则不再展示(0/空 视为无值)
- const phenoStatus = data.pheno?.status;
- const phenoAnswered =
- phenoStatus != null && phenoStatus !== "" && Number(phenoStatus) !== 0;
- if (!phenoAnswered) {
- pushOptionsCard("pheno", data.pheno, periodIcon);
- }
- // 2. 异常:结论标题 + 描述 + 立即巡园
- if (data.abnormal) {
- const section = data.abnormal;
- const title = section.title || section.interaction_title || "";
- const desc =
- section.highlight ||
- section.interaction_theme ||
- section.interaction_reason ||
- section.inspection_guide ||
- "";
- if (title || desc) {
- cards.push({
- key: "abnormal",
- kind: "abnormal",
- icon: lightningIcon,
- title,
- desc,
- raw: section,
- ...ctx,
- });
- }
- }
- // 3. 土壤根系:问题 + 选项;is_answered=1 已答则不展示
- if (Number(data.soil_root?.is_answered) !== 1) {
- pushOptionsCard("soil_root", data.soil_root, soilIcon);
- }
- return cards;
- }
- function clearInteractCard() {
- interactCards.value = [];
- currentCardIndex.value = 0;
- interactDismissed.value = false;
- selectedOptionId.value = null;
- }
- function applyInteractCards(data = {}, ctx = {}) {
- interactCards.value = buildInteractCards(data, ctx);
- currentCardIndex.value = 0;
- interactDismissed.value = false;
- selectedOptionId.value = null;
- }
- /** 关闭当前卡 → 展示下一张;最后一张则整体收起 */
- function dismissCurrentCard() {
- selectedOptionId.value = null;
- if (currentCardIndex.value < interactCards.value.length - 1) {
- currentCardIndex.value += 1;
- } else {
- interactDismissed.value = true;
- }
- }
- /** 选项卡(物候/土壤)提交成功后才切下一张 */
- async function submitInteractOption(item) {
- const card = currentCard.value;
- if (!card || card.kind !== "options" || interactSubmitting.value) return;
- selectedOptionId.value = item.id;
- interactSubmitting.value = true;
- try {
- let res;
- if (card.key === "pheno") {
- // 物候感知结果沿用原有保存接口
- res = await VE_API.questionnaire.saveInteractResult({
- zone_id: Number(card.zoneId),
- date: formatToday(),
- period_code: card.raw?.period_code || "",
- });
- } else {
- // 土壤根系:与异常互动同接口,按 fw_code 提交选项
- res = await VE_API.questionnaire.confirmAbnormalInteract({
- farm_id: card.farmId,
- zone_id: card.zoneId,
- calc_date: card.calcDate,
- crop_type: card.cropType,
- fw_code: card.raw?.fw_code || "",
- options: item.name,
- });
- }
- if (res?.code === 200) {
- ElMessage.success(res?.msg || "提交成功");
- dismissCurrentCard();
- return;
- }
- ElMessage.error(res?.msg || "提交失败,请稍后再试");
- } catch (err) {
- ElMessage.error(getRequestErrorMessage(err));
- } finally {
- interactSubmitting.value = false;
- }
- }
- async function handleInteractOptionClick(item) {
- if (interactSubmitting.value || !item?.name || !currentCard.value) return;
- await submitInteractOption(item);
- }
- /** 异常卡「立即巡园」只跳转,不切到下一张(避免直接跳到土壤) */
- const handlePatrolNow = () => {
- const card = currentCard.value;
- if (!card) return;
- router.push({
- path: "/abnormal_track",
- query: {
- id: card.zoneId,
- ...(card.zoneId !== "" ? { zoneId: card.zoneId } : {}),
- },
- });
- };
- /** 首页巡园要点:getTypesTask 一次返回 pheno / abnormal / soil_root */
- async function fetchInteractTask() {
- const farm = getSelectedFarm();
- // 与 checkZoneRange 一致:只用面板选中分区,避免缓存旧 zone
- const zoneId = panelZoneId.value;
- const farmId = selectedFarmId.value || farm.farm_id || farm.id;
- const cropType = resolveCropCode(farm);
- if (
- zoneId == null ||
- zoneId === "" ||
- farmId == null ||
- farmId === "" ||
- !cropType
- ) {
- clearInteractCard();
- return;
- }
- const token = ++interactFetchToken;
- try {
- const res = await VE_API.pheno.getTypesTask({
- crop_type: cropType,
- farm_id: farmId,
- zone_id: zoneId,
- calc_date: formatToday(),
- });
- if (token !== interactFetchToken) return;
- if (res?.code !== 200) {
- clearInteractCard();
- return;
- }
- applyInteractCards(res?.data || {}, {
- zoneId,
- farmId,
- cropType,
- calcDate: formatToday(),
- });
- } catch (e) {
- if (token !== interactFetchToken) return;
- console.warn("[growth_report] getTypesTask failed", e);
- clearInteractCard();
- }
- }
- /** 农场品类编码:接口 crop_code / crop_type 对应缓存 category_code */
- function resolveCropCode(farm = getSelectedFarm()) {
- return farm.category_code || farm.categorycode || farm.crop_code || farm.crop_type || "";
- }
- const handleZoneChange = (zoneId) => {
- panelZoneId.value = zoneId != null && zoneId !== "" ? zoneId : null;
- fetchFarmRangeStatus();
- fetchInteractTask();
- };
- /** 面板高度变化:地图中心改到「面板以上」区域的几何中心 */
- const handlePanelHeightChange = (panelHeight) => {
- const next = Math.max(0, Number(panelHeight) || 0);
- panelOverlayHeight.value = next;
- growthReportMap.setBottomOverlayHeight(next);
- if (!growthReportMap.kmap) return;
- growthReportMap.syncVisibleCenter(
- convertPointToArray(currentMapPoint.value)?.map(Number)
- );
- };
- async function getLocationName(point = currentMapPoint.value) {
- // 已选农场且带 county_address:直接使用,不再请求逆地理
- const farm = getSelectedFarm();
- const farmCountyAddress = String(farm?.county_address ?? "").trim();
- if (hasSelectedFarm() && farmCountyAddress) {
- locationName.value = farmCountyAddress;
- return;
- }
- let locationParam = "";
- // 无农场:逆地理用登录点 MINI_USER_LOCATION(lng,lat)
- if (!hasSelectedFarm()) {
- locationParam = toLocationParam(getMiniUserLocationText());
- }
- if (!locationParam) {
- const locationPoint =
- point ||
- localStorage.getItem("selectedFarmPoint") ||
- getMiniUserLocationPoint();
- if (!locationPoint) return;
- const farmLocation = convertPointToArray(locationPoint);
- if (Array.isArray(farmLocation) && farmLocation.length >= 2) {
- locationParam = `${farmLocation[0]},${farmLocation[1]}`;
- } else if (typeof farmLocation === "string" && farmLocation.includes(",")) {
- locationParam = toLocationParam(farmLocation);
- } else {
- return;
- }
- }
- try {
- const { result } = await fetchRegeo({ location: locationParam });
- locationName.value = result?.address_component
- ? result.address_component.city + result.address_component.district
- : (result?.address || "") + "";
- // 无农场时用 adcode 同步给点位预警面板
- if (!hasSelectedFarm()) {
- const adcode = result?.ad_info?.adcode;
- if (adcode != null && adcode !== "") {
- const code = String(adcode);
- countyCode.value = code;
- localStorage.setItem(COUNTY_CODE_STORAGE_KEY, code);
- } else {
- countyCode.value = "";
- localStorage.removeItem(COUNTY_CODE_STORAGE_KEY);
- }
- }
- } catch (e) {
- console.warn("[growth_report] getLocationName failed", e);
- }
- }
- function saveCurrentMapPoint(point) {
- if (!point) return;
- currentMapPoint.value = point;
- localStorage.setItem(MAP_POINT_STORAGE_KEY, point);
- }
- const initMap = async () => {
- await nextTick();
- if (!mapContainer.value) return;
- growthReportMap.setBottomOverlayHeight(panelOverlayHeight.value);
- if (growthReportMap.kmap) {
- growthReportMap.kmap.map?.updateSize?.();
- const coordinate = convertPointToArray(currentMapPoint.value)?.map(Number);
- if (coordinate?.length === 2) {
- growthReportMap.setMapPosition(coordinate);
- }
- await syncNoRangeGuide();
- return;
- }
- const location = currentMapPoint.value || store.state.home.miniUserLocationPoint || DEFAULT_MAP_POINT;
- currentMapPoint.value = location;
- growthReportMap.initMap(location, mapContainer.value);
- await syncNoRangeGuide();
- };
- function applySelectedLocation() {
- const raw = sessionStorage.getItem(LOCATION_SESSION_KEY);
- if (!raw) return false;
- sessionStorage.removeItem(LOCATION_SESSION_KEY);
- let saved = null;
- try {
- saved = JSON.parse(raw);
- } catch {
- return false;
- }
- if (!saved?.point && !saved?.coordinate) return false;
- const point = saved.point || `POINT(${saved.coordinate[0]} ${saved.coordinate[1]})`;
- const coordinate = (saved.coordinate || convertPointToArray(point)).map(Number);
- saveCurrentMapPoint(point);
- if (growthReportMap.kmap && coordinate?.length === 2) {
- growthReportMap.setMapPosition(coordinate);
- }
- getLocationName(point);
- return true;
- }
- /** 有农场落到 farm_location;无农场落到登录用户点位 */
- function syncMapFromSelectedFarm() {
- const point = resolveMapCenterPoint();
- if (!point) return false;
- saveCurrentMapPoint(point);
- const coordinate = convertPointToArray(point)?.map(Number);
- if (growthReportMap.kmap && coordinate?.length === 2) {
- growthReportMap.setMapPosition(coordinate);
- }
- getLocationName(point);
- return true;
- }
- /** 定位按钮:地图回到农场 / 用户点位中心 */
- const handleLocateToCenter = () => {
- if (!growthReportMap.kmap) return;
- const point = resolveMapCenterPoint() || currentMapPoint.value;
- if (!point) return;
- saveCurrentMapPoint(point);
- const coordinate = convertPointToArray(point)?.map(Number);
- if (coordinate?.length === 2) {
- growthReportMap.setMapPosition(coordinate);
- }
- };
- const handleSwitchFarm = () => {
- router.push("/all_garden");
- };
- const handleSwitchLocation = () => {
- // 以已确认的 currentMapPoint 为准,避免地图临时中心覆盖已选位置
- const mapCenter =
- currentMapPoint.value ||
- store.state.home.miniUserLocationPoint ||
- DEFAULT_MAP_POINT;
- router.push({
- path: "/entry_select_location",
- query: {
- mapCenter,
- iconType: "current",
- from: "growth_report",
- },
- });
- };
- const handleInvite = (type) => {
- const isService = type === "service";
- let inviteName = "好友";
- try {
- const userInfo = JSON.parse(localStorage.getItem("localUserInfo") || "{}");
- inviteName = userInfo.nickName || userInfo.userName || userInfo.name || inviteName;
- } catch {
- // ignore
- }
- const inviteType = isService ? "service" : "farmer";
- const adminId = localStorage.getItem("MINI_USER_ID") || "";
- const query = {
- askInfo: { title: "邀请完善信息", content: "是否分享该邀请给好友" },
- shareText: isService ? "邀请您完善农服信息" : "邀请您完善地块种植信息",
- targetUrl: `invite_welcome`,
- paramsPage: JSON.stringify({ inviteName, inviteType, adminId }),
- imageUrl: 'https://birdseye-img.sysuimars.com/farm-h5/field.png',
- };
- wx.miniProgram.navigateTo({
- url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
- });
- }
- onMounted(() => {
- // syncSelectedFarmId();
- // syncMapFromSelectedFarm();
- getLocationName();
- // initMap();
- // fetchFarmRangeStatus();
- // fetchInteractTask();
- });
- onActivated(() => {
- syncSelectedFarmId();
- const applied = applySelectedLocation();
- if (!applied) syncMapFromSelectedFarm();
- initMap();
- // 范围校验 / 互动卡片等 CropAlertPanel 通过 zoneChange 回传后再拉,避免旧 zone 竞态
- });
- </script>
- <style lang="scss" scoped>
- .growth-report-page {
- width: 100%;
- height: 100%;
- background: #0A0A0A;
- box-sizing: border-box;
- .interact-float {
- margin-bottom: 6px;
- pointer-events: none;
- padding: 1px;
- background: linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, rgba(153, 153, 153, 0.25) 100%);
- border-radius: 14px;
- backdrop-filter: blur(4px);
- .interact-card {
- position: relative;
- pointer-events: auto;
- overflow: hidden;
- border-radius: 14px;
- padding: 10px;
- background: linear-gradient(180deg, rgba(26, 25, 29, 0.6) 0%, rgba(18, 18, 22, 0.6) 100%);
- }
- .interact-card__head {
- position: relative;
- }
- .interact-card__tab {
- display: inline-flex;
- align-items: center;
- gap: 5px;
- height: 32px;
- padding: 0 32px 10px 8px;
- color: #fff;
- font-size: 16px;
- span {
- margin-top: -3px;
- }
- }
- .interact-card__star {
- width: 16px;
- height: 14px;
- }
- .interact-card__close {
- position: absolute;
- top: 12px;
- right: 10px;
- font-size: 16px;
- color: rgba(255, 255, 255, 0.5);
- cursor: pointer;
- }
- .interact-card__question {
- font-size: 16px;
- color: #fff;
- display: flex;
- align-items: center;
- gap: 12px;
- padding-right: 20px;
- > span {
- flex: 1;
- min-width: 0;
- }
- .interact-card__question-icon {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 31px;
- height: 31px;
- background: rgba(255, 255, 255, 0.05);
- border: 1px solid rgba(255, 255, 255, 0.12);
- border-radius: 8px;
- .interact-card__question-icon-img {
- width: 15px;
- }
- }
- }
- .interact-card__options {
- display: flex;
- gap: 8px;
- margin-top: 10px;
- }
- /* 异常卡:结论描述 + 立即巡园 */
- .interact-card__abnormal {
- display: flex;
- align-items: center;
- gap: 12px;
- margin-top: 10px;
- }
- .interact-card__desc {
- flex: 1;
- min-width: 0;
- font-size: 14px;
- line-height: 21px;
- color: rgba(255, 255, 255, 0.6);
- overflow: hidden;
- word-break: break-all;
- }
- .interact-card__cta {
- flex-shrink: 0;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 2px;
- height: 32px;
- padding: 0 10px 0 15px;
- border-radius: 24px;
- background: linear-gradient(90deg, #FFEBC9 0%, #FFCA6D 100%);
- color: #000000;
- font-size: 12px;
- white-space: nowrap;
- box-sizing: border-box;
- cursor: pointer;
- }
- .interact-option {
- position: relative;
- flex: 1;
- min-width: 0;
- height: 41px;
- line-height: 41px;
- border-radius: 6px;
- background: rgba(255, 255, 255, 0.05);
- border: 1px solid rgba(255, 255, 255, 0.12);
- text-align: center;
- box-sizing: border-box;
- cursor: pointer;
- &__text {
- display: block;
- padding: 0 6px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: 14px;
- color: rgba(255, 255, 255, 0.7);
- }
- &.selected {
- border-color: rgba(255, 255, 255, 0.5);
- background: rgba(255, 255, 255, 0.1);
- .interact-option__text {
- color: #fff;
- }
- // &::after {
- // content: "";
- // position: absolute;
- // top: -1px;
- // right: -1px;
- // width: 18px;
- // height: 14px;
- // background: url("@/assets/img/home/checked-bg-top.png") no-repeat bottom right / 18px 13px;
- // }
- }
- &.disabled {
- opacity: 0.65;
- pointer-events: none;
- }
- }
- }
- .location-bar {
- position: fixed;
- top: 12px;
- left: 12px;
- z-index: 16;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- max-width: calc(100% - 24px);
- height: 32px;
- padding: 0 12px;
- border-radius: 16px;
- background: rgba(0, 0, 0, 0.4);
- backdrop-filter: blur(4px);
- color: #fff;
- font-size: 14px;
- box-sizing: border-box;
- &__icon {
- font-size: 16px;
- flex-shrink: 0;
- }
- &__name {
- max-width: calc(100vw - 80px);
- }
- &__action {
- flex-shrink: 0;
- color: #FFD489;
- }
- }
- .growth-top {
- width: 100%;
- position: fixed;
- top: 52px;
- z-index: 15;
- pointer-events: none;
- padding: 0 12px;
- box-sizing: border-box;
- .growth-top__content {
- display: flex;
- align-items: flex-start;
- justify-content: end;
- }
- }
- .invite-group {
- pointer-events: none;
- .invite-btn {
- pointer-events: auto;
- height: 48px;
- width: 48px;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- border-radius: 10px;
- border: 1px solid rgba(255, 255, 255, 0.2);
- background: rgba(20, 20, 22, 0.8);
- gap: 6px;
- color: rgba(255, 255, 255, 0.6);
- font-size: 10px;
- .invite-icon {
- width: 16px;
- }
- .current-icon {
- width: 20px;
- }
- }
- .invite-btn+.invite-btn {
- margin-top: 10px;
- }
- }
- .report-content {
- position: relative;
- height: 100%;
- box-sizing: border-box;
- .map-container {
- width: 100%;
- height: 100%;
- }
- }
- .no-range-tip {
- display: none;
- align-items: center;
- gap: 2px;
- max-width: calc(100vw - 48px);
- height: 36px;
- padding: 0 14px;
- border-radius: 18px;
- background: rgba(40, 48, 36, 0.72);
- backdrop-filter: blur(4px);
- color: #fff;
- font-size: 14px;
- white-space: nowrap;
- box-sizing: border-box;
- cursor: pointer;
- &__arrow {
- font-size: 14px;
- flex-shrink: 0;
- }
- }
- }
- </style>
|