Bläddra i källkod

feat:对接农场设施接口和新增新用户页面

wangsisi 20 timmar sedan
förälder
incheckning
0d1a2dc383

BIN
src/assets/img/monitor/example.png


+ 48 - 43
src/views/old_mini/agri_record/index.vue

@@ -30,6 +30,13 @@
                     {{ v.regionName }}
                 </div>
             </div>
+            <template v-if="true">
+                <div class="lock-img" @click="handleLockClick">
+                    <img src="@/assets/img/home/lock-blue.png" alt="" class="lock-img-item" />
+                    <div class="lock-text">解锁某某某某某,解锁某某某某某</div>
+                </div>
+                <img class="example-img" src="@/assets/img/monitor/example.png" alt="">
+            </template>
             <div class="archives-time-line-content">
                 <archives-farm-time-line :farmId="farmIdData" pageType="agri_record"></archives-farm-time-line>
             </div>
@@ -50,14 +57,13 @@
 import customHeader from "@/components/customHeader.vue";
 import { ref, computed, onActivated, onDeactivated, onMounted } from "vue";
 import { useStore } from "vuex";
-import { Badge, List } from "vant";
+import wx from "weixin-js-sdk";
 import weatherInfo from "@/components/weatherInfo.vue";
 import { useRouter, useRoute } from "vue-router";
 import farmInfoPopup from "../home/components/farmInfoPopup.vue";
 import tipPopup from "@/components/popup/tipPopup.vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import ArchivesFarmTimeLine from "@/components/pageComponents/ArchivesFarmTimeLine.vue";
-import wx from "weixin-js-sdk";
 
 const handleFarmInfoClick = () =>{
     const query = {
@@ -146,44 +152,15 @@ function toFarmInfo() {
     farmInfoRef.value.handleShow();
 }
 
-// 功能卡片数据
-const functionCards = ref([
-    {
-        title: "农事规划",
-        route: "/plan",
-    },
-    {
-        title: "农场报告",
-        status: "最新",
-        route: "/farm_report",
-        className: "blue",
-    },
-    {
-        title: "农事方案",
-        route: "/agricultural_plan",
-    },
-    {
-        title: "复核成效",
-        status: "最新",
-        route: "/review-results",
-        className: "yellow",
-    },
-]);
-
-const getStayCount = () => {
-    VE_API.monitor
-        .getCountByStatusAndFarmId({
-            farmId: gardenId.value,
-            startStatus: 1,
-            endStatus: 3,
-        })
-        .then((res) => {
-            functionCards.value[0].status = null;
-            if (res.data && res.data != 0) {
-                functionCards.value[0].status = res.data + " 待完成";
-            }
-        });
-};
+const handleLockClick = () => {
+    wx.miniProgram.navigateTo({
+        url: '/pages/subPages/phone_auth/index',
+    });
+
+    // wx.miniProgram.navigateTo({
+    //     url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
+    // });
+}
 
 // 实时播报数据
 const broadcastList = ref([]);
@@ -340,9 +317,7 @@ onMounted(() => {
         currentPage.value = 1;
         finished.value = false;
         broadcastList.value = [];
-        getStayCount();
         getVarietyTabs();
-        // 不在这里手动加载,让 List 组件的 immediate-check 自动触发首次加载
     }
 });
 
@@ -354,7 +329,6 @@ const changeGarden = ({ id }) => {
     currentPage.value = 1;
     finished.value = false;
     broadcastList.value = [];
-    getStayCount();
     getBroadcastList(1, false);
     getVarietyTabs();
 };
@@ -376,6 +350,37 @@ const changeGarden = ({ id }) => {
         background-color: rgba(0, 0, 0, 0.52);
         z-index: 11;
     }
+    .lock-img {
+        position: fixed;
+        top: 50%;
+        left: 50%;
+        transform: translate(-50%, -20%);
+        width: 100%;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        flex-direction: column;
+        gap: 16px;
+
+        .lock-img-item {
+            width: 57px;
+        }
+
+        .lock-text {
+            font-size: 16px;
+            color: #000;
+            padding: 0 24px;
+            height: 34px;
+            line-height: 34px;
+            background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 50%, rgba(255, 255, 255, 0) 100%);
+        }
+    }
+
+    .example-img{
+        width: 100%;
+        height: 100%;
+        object-fit: contain;
+    }
     .weather-info {
         width: calc(100% - 20px);
         position: absolute;

+ 35 - 20
src/views/old_mini/home/subPages/prescriptionPage.vue

@@ -246,9 +246,9 @@ onActivated(() => {
     // 为 productList 的每个 group 设置默认选中第一项
 });
 
-onMounted(() => {
-    getCurrentAndNextPhenology();
-});
+// onMounted(() => {
+//     getCurrentAndNextPhenology();
+// });
 
 const loadingPage = ref(false);
 const basicForm = ref({
@@ -571,24 +571,39 @@ async function submit() {
         //     expertMiniUserId: '81881',
         // }
         // const res = await VE_API.basic_farm.saveBasicFarmInfoByExpert(params);
-        const param = {
-            ...route.query,
-            expertMiniUserId: '81881',
-            speciesContainer: JSON.parse(route.query.speciesContainer),
-        }
-        const res = await VE_API.basic_farm.saveBasicFarmInfoByExpertV3(param);
-        if (res.code === 0) {
-            // showSuccessPopup.value = true;
-
-            // 设置选中当前新增的农场
-            localStorage.setItem("selectedFarmId", res.data.id);
-            localStorage.setItem("selectedFarmName", res.data.name);
-            router.replace('/home');
-            // return true;
-        } else {
-            ElMessage.error(res.msg || '提交失败,请重试');
-            return false;
+        let paramsData = null
+        if(route.query.subjectId) {
+            paramsData = {
+                ...draftData,
+                subjectId: route.query.subjectId,
+            }
+        }else{
+            paramsData = {
+                ...route.query,
+                expertMiniUserId: '81881',
+                basicInfo: draftData,
+                speciesContainer: JSON.parse(route.query.speciesContainer),
+            }
         }
+
+        const apiCall = route.query.subjectId ? VE_API.basic_farm.saveBasicFarmInfo(paramsData) : VE_API.basic_farm.saveBasicFarmInfoByExpertV3(paramsData);
+        apiCall.then((res) => {
+            if (res.code === 0) {
+                // showSuccessPopup.value = true;
+                if(route.query.subjectId) {
+                    router.go(-1);
+                }else{
+                    // 设置选中当前新增的农场
+                    localStorage.setItem("selectedFarmId", res.data.id);
+                    localStorage.setItem("selectedFarmName", res.data.name);
+                    router.replace('/growth_report');
+                }
+                // return true;
+            } else {
+                ElMessage.error(res.msg || '提交失败,请重试');
+                return false;
+            }
+        })
     } catch (error) {
         console.error('提交失败:', error);
         ElMessage.error('提交失败,请重试');

+ 68 - 71
src/views/old_mini/monitor/index.vue

@@ -12,7 +12,9 @@
                 <div class="line-title" @click="handlePage">作物档案</div>
                 <div class="header-right">
                     <div class="add-variety-btn" @click="handleAddVariety">
-                        <el-icon size="12"><Plus /></el-icon>
+                        <el-icon size="12">
+                            <Plus />
+                        </el-icon>
                         <span>新增品种</span>
                     </div>
                     <el-date-picker style="width: 110px" v-model="date" type="year" placeholder="全部日期" />
@@ -20,16 +22,18 @@
             </div>
             <!-- 品种选择 -->
             <div class="variety-tabs" v-if="varietyTabs.length > 0">
-                <div
-                    v-for="(v, index) in varietyTabs"
-                    :key="index"
-                    class="variety-tab"
-                    :class="{ 'variety-tab--active': activeVariety === index }"
-                    @click="handleVarietyClick(v,index)"
-                >
+                <div v-for="(v, index) in varietyTabs" :key="index" class="variety-tab"
+                    :class="{ 'variety-tab--active': activeVariety === index }" @click="handleVarietyClick(v, index)">
                     {{ v.regionName }}
                 </div>
             </div>
+            <template v-if="!hasReport">
+                <div class="lock-img" @click="handleLockClick">
+                    <img src="@/assets/img/home/lock-blue.png" alt="" class="lock-img-item" />
+                    <div class="lock-text">解锁某某某某某,解锁某某某某某</div>
+                </div>
+                <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="box-content">
@@ -50,35 +54,23 @@
         </div>
     </div>
 
-    <tip-popup
-        v-model:show="showFarmPopup"
-        type="success"
-        text="农场领取成功"
-        :overlay-style="{ 'backdrop-filter': 'blur(4px)' }"
-        :closeOnClickOverlay="false"
-        :zIndex="9999"
-    />
+    <tip-popup v-model:show="showFarmPopup" type="success" text="农场领取成功"
+        :overlay-style="{ 'backdrop-filter': 'blur(4px)' }" :closeOnClickOverlay="false" :zIndex="9999" />
 
     <!-- 勾选区域引导弹窗 -->
-    <select-region-popup
-        v-model:show="showSelectRegionPopup"
-        :image="selectRegionImage"
-        title="勾选 妃子笑 区域"
-        sub-title="精准匹配农情信息,高效管理分区"
-        @confirm="handleGoSelectRegion"
-        @skip="handleSkipSelectRegion"
-    />
+    <select-region-popup v-model:show="showSelectRegionPopup" :image="selectRegionImage" title="勾选 妃子笑 区域"
+        sub-title="精准匹配农情信息,高效管理分区" @confirm="handleGoSelectRegion" @skip="handleSkipSelectRegion" />
 
     <!-- 农事执行弹窗 -->
-    <agri-execute-popup v-model:show="showAgriExecutePopup" :popupData="agriExecuteData"
-        @executed="handleAgriExecuted" @close="handleClosePopup" />
+    <agri-execute-popup v-model:show="showAgriExecutePopup" :popupData="agriExecuteData" @executed="handleAgriExecuted"
+        @close="handleClosePopup" />
 </template>
 
 <script setup>
 import { ref, computed, onActivated, onDeactivated, onMounted } from "vue";
 import customHeader from "@/components/customHeader.vue";
 import { useStore } from "vuex";
-import { Badge, List } from "vant";
+import wx from "weixin-js-sdk";
 import weatherInfo from "@/components/weatherInfo.vue";
 import { useRouter, useRoute } from "vue-router";
 import tipPopup from "@/components/popup/tipPopup.vue";
@@ -104,16 +96,16 @@ const getVarietyTabs = async () => {
             subjectId: gardenId.value,
         });
         varietyTabs.value = res.data || []
-        if(varietyTabs.value.length > 0) {
-            handleVarietyClick(varietyTabs.value[0],0)
+        if (varietyTabs.value.length > 0) {
+            handleVarietyClick(varietyTabs.value[0], 0)
         }
     } catch (error) {
         console.error("获取主体分区列表失败:", error);
     }
 };
 
-const farmIdData= ref(null);
-const handleVarietyClick = (tab,index) => {
+const farmIdData = ref(null);
+const handleVarietyClick = (tab, index) => {
     activeVariety.value = index;
     farmIdData.value = tab.farmId;
 };
@@ -194,44 +186,15 @@ function toFarmInfo() {
     farmInfoRef.value.handleShow();
 }
 
-// 功能卡片数据
-const functionCards = ref([
-    {
-        title: "农事规划",
-        route: "/plan",
-    },
-    {
-        title: "农场报告",
-        status: "最新",
-        route: "/farm_report",
-        className: "blue",
-    },
-    {
-        title: "农事方案",
-        route: "/agricultural_plan",
-    },
-    {
-        title: "复核成效",
-        status: "最新",
-        route: "/review-results",
-        className: "yellow",
-    },
-]);
-
-const getStayCount = () => {
-    VE_API.monitor
-        .getCountByStatusAndFarmId({
-            farmId: gardenId.value,
-            startStatus: 1,
-            endStatus: 3,
-        })
-        .then((res) => {
-            functionCards.value[0].status = null;
-            if (res.data && res.data != 0) {
-                functionCards.value[0].status = res.data + " 待完成";
-            }
-        });
-};
+const handleLockClick = () => {
+    wx.miniProgram.navigateTo({
+        url: '/pages/subPages/phone_auth/index',
+    });
+
+    // wx.miniProgram.navigateTo({
+    //     url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
+    // });
+}
 
 // 实时播报数据
 const broadcastList = ref([]);
@@ -330,7 +293,6 @@ const changeGarden = ({ id }) => {
     currentPage.value = 1;
     finished.value = false;
     broadcastList.value = [];
-    getStayCount();
     getBroadcastList(1, false);
     checkHasUnrepliedTriggeredInteraction();
     getReport();
@@ -351,7 +313,7 @@ const handleClosePopup = () => {
 }
 
 const getReport = () => {
-    VE_API.farm.growthReportBySubject({subjectId: gardenId.value, limit: 20}).then(({ data }) => {
+    VE_API.farm.growthReportBySubject({ subjectId: gardenId.value, limit: 20 }).then(({ data }) => {
         if (data && data.length > 0) {
             hasReport.value = true;
         } else {
@@ -379,6 +341,38 @@ const getReport = () => {
         z-index: 11;
     }
 
+    .lock-img {
+        position: fixed;
+        top: 50%;
+        left: 50%;
+        transform: translate(-50%, -20%);
+        width: 100%;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        flex-direction: column;
+        gap: 16px;
+
+        .lock-img-item {
+            width: 57px;
+        }
+
+        .lock-text {
+            font-size: 16px;
+            color: #000;
+            padding: 0 24px;
+            height: 34px;
+            line-height: 34px;
+            background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 50%, rgba(255, 255, 255, 0) 100%);
+        }
+    }
+
+    .example-img{
+        width: 100%;
+        height: 100%;
+        object-fit: contain;
+    }
+
     .weather-info {
         width: calc(100% - 20px);
         position: absolute;
@@ -412,10 +406,12 @@ const getReport = () => {
                     border-radius: 20px;
                 }
             }
+
             .header-right {
                 display: flex;
                 align-items: center;
                 gap: 12px;
+
                 .add-variety-btn {
                     display: flex;
                     align-items: center;
@@ -493,6 +489,7 @@ const getReport = () => {
 
             .time-line {
                 height: calc(100% - 100px);
+
                 &.no-report {
                     height: 100%;
                 }

+ 55 - 22
src/views/old_mini/monitor/subPages/farmInfo.vue

@@ -2,7 +2,10 @@
     <custom-header name="农场信息" bgColor="#f2f3f5"></custom-header>
     <div class="farm-details-page">
         <div class="farm-info">
-            <div class="map-area" ref="mapContainer"></div>
+            <div class="map-wrap">
+                <div class="map-area" ref="mapContainer"></div>
+                <div class="map-text" @click="handleEditMap">点击编辑地块</div>
+            </div>
             <div class="info-box">
                 <div class="section-header">
                     <div class="line-title">基本信息</div>
@@ -44,23 +47,23 @@
                 <div class="info-list">
                     <div class="info-row">
                         <span class="info-label">土壤类型:</span>
-                        <span class="info-value">砂质土</span>
+                        <span class="info-value">{{ basicFarmInfo.soil }}</span>
                     </div>
                     <div class="info-row">
                         <span class="info-label">灌溉方式:</span>
                         <div class="info-value crop-tags">
-                            <span v-for="crop in farmInfo.cropList" :key="crop.id" class="crop-tag">
-                                {{ crop.name }}
+                            <span v-for="method in basicFarmInfo.irrigation" :key="method.code" class="crop-tag">
+                                {{ method.name }}
                             </span>
                         </div>
                     </div>
                     <div class="info-row info-row-column">
                         <span class="info-label">农机设备:</span>
-                        <div class="info-value">
+                        <div class="info-value device-value">
                             <div class="device-box">
-                                <div class="device-item" v-for="device in farmDevices" :key="device.id">
+                                <div class="device-item" v-for="device in basicFarmInfo.machineryList" :key="device.code">
                                     <span class="device-name">{{ device.name }}</span>
-                                    <span class="device-count">{{ device.count }}架</span>
+                                    <span class="device-count">{{ device.quantity || 0 }}{{ device.unit}}</span>
                                 </div>
                             </div>
                         </div>
@@ -68,8 +71,8 @@
                     <div class="info-row info-row-column">
                         <span class="info-label">希望改善问题:</span>
                         <div class="info-value problem-tags">
-                            <span v-for="item in improveProblems" :key="item" class="problem-tag">
-                                {{ item }}
+                            <span v-for="item in basicFarmInfo.improvementProblems" :key="item.code" class="problem-tag">
+                                {{ item.name }}
                             </span>
                         </div>
                     </div>
@@ -135,6 +138,7 @@ const destroyMap = () => {
 
 onMounted(() => {
     fetchFarmSubjectDetail();
+    fetchBasicFarmFormData();
 });
 
 function fetchFarmSubjectDetail() {
@@ -146,16 +150,21 @@ function fetchFarmSubjectDetail() {
         });
     });
 }
-const farmDevices = [
-    { id: 1, name: "植保无人机", count: 10 },
-    { id: 2, name: "植保无人机", count: 10 },
-    { id: 3, name: "植保无人机", count: 10 },
-    { id: 4, name: "植保无人机", count: 10 },
-    { id: 5, name: "植保无人机", count: 10 },
-    { id: 6, name: "植保无人机", count: 10 },
-];
 
-const improveProblems = ["土壤改良", "树势增强", "品质提升"];
+const basicFarmInfo = ref({});
+function fetchBasicFarmFormData() {
+    VE_API.basic_farm.fetchBasicFarmFormData({ subjectId: route.query.subjectId }).then(({ data,code }) => {
+        if(code === 0) {
+            basicFarmInfo.value = {
+                ...data,
+                soil:data.soilTypes.find(item => item.selected).name,
+                irrigation:data.irrigationMethods.filter(item => item.selected),
+                machineryList:data.machinery.filter(item => item.selected),
+                improvementProblems:data.improvementAreas.filter(item => item.selected),
+            }
+        }
+    });
+}
 
 const handleEditFarmInfo = () => {
     // // 回显地块:存到 polygonData,创建页会优先使用这里的数据
@@ -189,6 +198,11 @@ const handleEditFarmInfo = () => {
 const handleEditFarmFacility = () => {
     router.push(`/prescription?subjectId=${route.query.subjectId}`);
 };
+
+// 点击编辑地块
+const handleEditMap = () => {
+    router.push("/draw_area");
+};
 </script>
 
 <style lang="scss" scoped>
@@ -220,10 +234,24 @@ const handleEditFarmFacility = () => {
         border-radius: 8px;
         padding: 10px;
 
-        .map-area {
-            width: 100%;
-            height: 142px;
-            clip-path: inset(0px round 5px);
+        .map-wrap{
+            position: relative;
+            .map-area {
+                width: 100%;
+                height: 142px;
+                clip-path: inset(0px round 5px);
+            }
+            .map-text {
+                position: absolute;
+                right: 13px;
+                bottom: 8px;
+                font-size: 12px;
+                color: #ffffff;
+                background: rgba(0, 0, 0, 0.5);
+                padding: 8px 12px;
+                border-radius: 25px;
+                border: 1px solid rgba(255, 255, 255, 0.5);
+            }
         }
 
         .info-box {
@@ -286,6 +314,10 @@ const handleEditFarmFacility = () => {
                         }
                     }
 
+                    .device-value {
+                        width: 100%;
+                    }
+
                     .device-box {
                         padding: 6px;
                         border-radius: 4px;
@@ -296,6 +328,7 @@ const handleEditFarmFacility = () => {
 
                         .device-item {
                             display: flex;
+                            align-items: center;
                             padding: 4px 0;
                             gap: 15px;
                             font-size: 13px;