Browse Source

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

lxf 3 days ago
parent
commit
e4ab397e52

+ 1 - 1
src/components/pageComponents/ArchivesFarmTimeLine.vue

@@ -1083,7 +1083,7 @@ watch(
 
         .phenology-title {
             width: 18px;
-            height: 98.5%;
+            height: 99.5%;
             color: #fff;
             font-size: 12px;
             position: absolute;

+ 6 - 153
src/views/old_mini/agri_record/index.vue

@@ -42,7 +42,7 @@
     <select-region-popup v-model:show="showSelectRegionPopup" :title="titlePopup" @confirm="handleGoSelectRegion"
         @skip="handleSkipSelectRegion" />
 
-    <agri-execute-popup ref="agriExecutePopupRef" />
+    <agri-execute-popup v-if="!showSelectRegionPopup" ref="agriExecutePopupRef" />
 
     <start-interact-popup ref="startInteractPopupRef" />
 </template>
@@ -91,7 +91,7 @@ const getVarietyTabs = async (isShowPopup = true) => {
         varietyTabs.value = res.data || []
         if (varietyTabs.value.length > 0) {
             handleVarietyClick(varietyTabs.value[activeVariety.value || 0], activeVariety.value || 0)
-            if(isShowPopup) {
+            if (isShowPopup && !showSelectRegionPopup.value && agriExecutePopupRef.value) {
                 agriExecutePopupRef.value.showPopup(varietyTabs.value[activeVariety.value || 0].farmId);
             }
         }
@@ -115,16 +115,14 @@ const handleVarietyClick = (tab, index) => {
     if (tab.lastViewTime == null) {
         titlePopup.value = `勾选 ${tab.regionName} 区域`;
         showSelectRegionPopup.value = true;
+        VE_API.basic_farm.updateLastViewTime({
+            regionId: tab.regionId,
+        })
     }
 };
 
 const handleSkipSelectRegion = () => {
-    VE_API.basic_farm.updateLastViewTime({
-        regionId: currentVariety.value.regionId,
-    }).then(() => {
-        showSelectRegionPopup.value = false;
-        getVarietyTabs(false);
-    });
+    showSelectRegionPopup.value = false;
 };
 
 const handleGoSelectRegion = () => {
@@ -156,35 +154,11 @@ onActivated(() => {
     }
 });
 
-const receiveFarm = (json) => {
-    VE_API.monitor
-        .receiveFarm({
-            agriculturalStoreId: json.agriculturalStoreId,
-            farmId: json.farmId,
-        })
-        .then((res) => {
-            if (res.code === 0) {
-                showFarmPopup.value = true;
-                defaultGardenId.value = json.farmId;
-            } else {
-                ElMessage.warning(res.msg);
-            }
-            // 清空路由参数
-            router.replace({ path: route.path });
-        });
-};
-
 const store = useStore();
 const tabBarHeight = computed(() => store.state.home.tabBarHeight);
 const router = useRouter();
 const route = useRoute();
 
-const farmInfoRef = ref(null);
-
-function toFarmInfo() {
-    farmInfoRef.value.handleShow();
-}
-
 const handleLockClick = () => {
     wx.miniProgram.navigateTo({
         url: '/pages/subPages/phone_auth/index',
@@ -195,131 +169,10 @@ const handleLockClick = () => {
     // });
 }
 
-// 实时播报数据
-const broadcastList = ref([]);
-const loading = ref(false);
-const finished = ref(false);
-const currentPage = ref(1);
-const pageSize = ref(10);
-
-const getBroadcastList = async (page = 1, isLoadMore = false) => {
-    if (!gardenId.value) {
-        loading.value = false;
-        return;
-    }
-
-    // 如果正在加载,直接返回(避免重复请求)
-    if (loading.value) {
-        return;
-    }
-
-    loading.value = true;
-    try {
-        const res = await VE_API.monitor.broadcastPage({
-            farmId: gardenId.value,
-            limit: pageSize.value,
-            page: page,
-        });
-
-        const newData = res.data || [];
-        if (isLoadMore) {
-            broadcastList.value = [...broadcastList.value, ...newData];
-        } else {
-            broadcastList.value = newData;
-        }
-
-        // 判断是否还有更多数据
-        if (newData.length < pageSize.value) {
-            finished.value = true;
-        } else {
-            finished.value = false;
-            // 如果未完成,页码+1,为下次加载做准备
-            currentPage.value = page + 1;
-        }
-    } catch (error) {
-        console.error("获取播报列表失败:", error);
-        finished.value = true;
-    } finally {
-        // 确保 loading 状态被正确设置为 false
-        loading.value = false;
-    }
-};
-
-// 滚动加载更多
-const onLoad = async () => {
-    if (finished.value || loading.value) return;
-
-    // 判断是否是首次加载(页码为1)
-    const isLoadMore = currentPage.value > 1;
-    const pageToLoad = currentPage.value;
-
-    // 加载数据(页码会在 getBroadcastList 成功后自动更新)
-    await getBroadcastList(pageToLoad, isLoadMore);
-};
-
-// 卡片点击事件
-const handleCardClick = (card) => {
-    const params = {
-        farmId: gardenId.value,
-    };
-    router.push({
-        path: card.route,
-        query: { ...params, miniJson: JSON.stringify(params) },
-    });
-};
-
 // 播报相关事件
 const isSpeaking = ref(false);
 const speechSynthesis = window.speechSynthesis;
 
-const handleBroadcast = () => {
-    if (isSpeaking.value) {
-        // 如果正在播放,则停止
-        speechSynthesis.cancel();
-        isSpeaking.value = false;
-        return;
-    }
-
-    // 构建播报文本
-    let broadcastText = "实时播报:";
-
-    if (broadcastList.value.length === 0) {
-        broadcastText += "暂无更多播报";
-    } else {
-        broadcastList.value.forEach((item, index) => {
-            broadcastText += `${index + 1}、${item.title}。${item.content}。`;
-        });
-    }
-
-    // 创建语音合成对象
-    const utterance = new SpeechSynthesisUtterance(broadcastText);
-
-    // 设置语音参数
-    utterance.lang = "zh-CN";
-    utterance.rate = 0.8; // 语速
-    utterance.pitch = 1; // 音调
-    utterance.volume = 1; // 音量
-
-    // 播放开始事件
-    utterance.onstart = () => {
-        isSpeaking.value = true;
-    };
-
-    // 播放结束事件
-    utterance.onend = () => {
-        isSpeaking.value = false;
-    };
-
-    // 播放错误事件
-    utterance.onerror = (event) => {
-        isSpeaking.value = false;
-        console.error("播报错误:", event.error);
-    };
-
-    // 开始播报
-    speechSynthesis.speak(utterance);
-};
-
 // 组件卸载时停止语音播放
 onDeactivated(() => {
     showFarmPopup.value = false;

+ 7 - 23
src/views/old_mini/monitor/index.vue

@@ -40,7 +40,7 @@
                 <img class="example-img" src="@/assets/img/monitor/example.png" alt="">
             </template>
             <div class="archives-time-line-content">
-                <div class="report-box" v-if="hasReport">
+                <!-- <div class="report-box" v-if="hasReport">
                     <div class="box-content">
                         <div class="box-title" @click="handleReportClick">
                             <span>农情互动报告</span>
@@ -51,8 +51,8 @@
                         <span class="box-text">点击查看您的长势报告</span>
                     </div>
                     <img src="@/assets/img/monitor/report-icon.png" alt="" class="report-icon" />
-                </div>
-                <div class="time-line" :class="{ 'no-report': !hasReport }">
+                </div> -->
+                <div class="time-line">
                     <archives-farm-time-line key="monitor" :farmId="farmIdData" :regionId="regionData"></archives-farm-time-line>
                 </div>
             </div>
@@ -63,8 +63,8 @@
     <select-region-popup v-model:show="showSelectRegionPopup" :title="titlePopup" @confirm="handleGoSelectRegion"
         @skip="handleSkipSelectRegion" />
 
-    <!-- 农事执行弹窗 -->
-    <agri-execute-popup ref="agriExecutePopupRef" />
+    <!-- 农事执行弹窗(勾选区域引导弹窗显示时不展示) -->
+    <agri-execute-popup v-if="!showSelectRegionPopup" ref="agriExecutePopupRef" />
 
     <start-interact-popup ref="startInteractPopupRef" />
 </template>
@@ -105,7 +105,7 @@ const getVarietyTabs = async (isShowPopup = true) => {
         varietyTabs.value = res.data || []
         if (varietyTabs.value.length > 0) {
             handleVarietyClick(varietyTabs.value[activeVariety.value || 0], activeVariety.value || 0)
-            if(isShowPopup) {
+            if (isShowPopup && !showSelectRegionPopup.value && agriExecutePopupRef.value) {
                 agriExecutePopupRef.value.showPopup(varietyTabs.value[activeVariety.value || 0].farmId);
             }
         }
@@ -161,7 +161,6 @@ const defaultGardenId = ref(null);
 const isHeaderShow = ref(false);
 const isDefaultFarm = ref(false);
 const weatherInfoRef = ref(null);
-const hasReport = ref(false);
 onActivated(() => {
     sessionStorage.removeItem('interactionListScrollTop');
     // 用来接收我的农场跳转过来的农场详情逻辑
@@ -171,7 +170,6 @@ onActivated(() => {
         // 统一转换为布尔值
         isDefaultFarm.value = route.query.defaultFarm === "true" || route.query.defaultFarm === true;
     }
-    getReport();
 });
 
 const store = useStore();
@@ -221,7 +219,6 @@ const changeGarden = ({ id }) => {
     gardenId.value = id;
     // 更新 store 中的状态
     store.commit("home/SET_GARDEN_ID", id);
-    getReport();
     getVarietyTabs();
 
     startInteractPopupRef.value.getPhenologyInitOrConfirmStatus();
@@ -234,15 +231,6 @@ function handleReportClick() {
     });
 }
 
-const getReport = () => {
-    VE_API.farm.growthReportBySubject({ subjectId: gardenId.value, limit: 20 }).then(({ data }) => {
-        if (data && data.length > 0) {
-            hasReport.value = true;
-        } else {
-            hasReport.value = false;
-        }
-    });
-}
 </script>
 
 <style scoped lang="scss">
@@ -421,11 +409,7 @@ const getReport = () => {
             }
 
             .time-line {
-                height: calc(100% - 100px);
-
-                &.no-report {
-                    height: 100%;
-                }
+                height: 100%;
             }
         }
     }