lxf пре 3 дана
родитељ
комит
a836d3922d

+ 119 - 110
src/App.vue

@@ -20,116 +20,99 @@
         <component v-else :is="Component" />
     </router-view>
 
+
     <Tabbar class="tabbar" route fixed v-show="showTab" active-color="#2199F8" inactive-color="#898989">
-        <tabbar-item replace to="/home" v-if="curRole == 0 || curRole == 2">
-            <span>首页</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/home-active.png')
-                            : require('@/assets/img/tab_bar/home.png')
-                    "
-                />
-            </template>
-        </tabbar-item>
-        <!-- 专家 -->
-        <!-- <tabbar-item replace to="/farm_manage" v-if="curRole == 1">
-            <span>农场管理</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/home-active.png')
-                            : require('@/assets/img/tab_bar/home.png')
-                    "
-                />
-            </template>
-        </tabbar-item> -->
-        <!-- <tabbar-item replace to="/task_condition">
-            <span>农事服务</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/service-active.png')
-                            : require('@/assets/img/tab_bar/service.png')
-                    "
-                />
-            </template>
-        </tabbar-item> -->
-        <tabbar-item replace to="/monitor">
-            <span>农事服务</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/service-active.png')
-                            : require('@/assets/img/tab_bar/service.png')
-                    "
-                />
-            </template>
-        </tabbar-item>
-        <!-- <tabbar-item replace to="/monitor" v-if="curRole == 0">
-            <span>农场监测</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/farm-active.png')
-                            : require('@/assets/img/tab_bar/farm.png')
-                    "
-                />
-            </template>
-        </tabbar-item> -->
-        <!-- <tabbar-item replace to="/expert_prescription" v-if="curRole == 1">
-            <span>农事方案</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/farm-active.png')
-                            : require('@/assets/img/tab_bar/farm.png')
-                    "
-                />
-            </template>
-        </tabbar-item> -->
-        <tabbar-item replace to="/agri_record">
-            <span>农事记录</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/farm-active.png')
-                            : require('@/assets/img/tab_bar/farm.png')
-                    "
-                />
-            </template>
-        </tabbar-item>
-        <tabbar-item replace to="/user">
-            <span>用户管理</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/user-active.png')
-                            : require('@/assets/img/tab_bar/user.png')
-                    "
-                />
-            </template>
-        </tabbar-item>
-        <tabbar-item replace to="/mine">
-            <span>个人中心</span>
-            <template #icon="props">
-                <img
-                    :src="
-                        props.active
-                            ? require('@/assets/img/tab_bar/mine-active.png')
-                            : require('@/assets/img/tab_bar/mine.png')
-                    "
-                />
-            </template>
-        </tabbar-item>
+        <!-- 托管农户:首页、作物档案、农事记录 -->
+        <template v-if="userType === 2">
+            <tabbar-item replace to="/home">
+                <span>首页</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/home-active.png')
+                                : require('@/assets/img/tab_bar/home.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+            <tabbar-item replace to="/monitor">
+                <span>作物档案</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/tree-active.png')
+                                : require('@/assets/img/tab_bar/tree.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+            <tabbar-item replace to="/agri_record">
+                <span>农事记录</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/task-active.png')
+                                : require('@/assets/img/tab_bar/task.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+        </template>
+
+        <!-- 普通农户:首页、农事服务、用户管理、个人中心(保留原逻辑) -->
+        <template v-else>
+            <tabbar-item replace to="/home" v-if="curRole == 0 || curRole == 2">
+                <span>首页</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/home-active.png')
+                                : require('@/assets/img/tab_bar/home.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+            <tabbar-item replace to="/task_condition">
+                <span>农事服务</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/service-active.png')
+                                : require('@/assets/img/tab_bar/service.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+            <tabbar-item replace to="/user">
+                <span>用户管理</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/user-active.png')
+                                : require('@/assets/img/tab_bar/user.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+            <tabbar-item replace to="/mine">
+                <span>个人中心</span>
+                <template #icon="props">
+                    <img
+                        :src="
+                            props.active
+                                ? require('@/assets/img/tab_bar/mine-active.png')
+                                : require('@/assets/img/tab_bar/mine.png')
+                        "
+                    />
+                </template>
+            </tabbar-item>
+        </template>
     </Tabbar>
 
     <!-- 开启底部安全区适配 -->
@@ -142,7 +125,7 @@ import { Tabbar, TabbarItem } from "vant";
 import { nextTick, watch, onMounted, ref } from "vue";
 import { useRoute, useRouter } from "vue-router";
 import { useStore } from "vuex";
-import {NH,NZ,EXPERT} from "@/common/user_role";
+import { NH, NZ, EXPERT } from "@/common/user_role";
 const store = useStore();
 const route = useRoute();
 const router = useRouter();
@@ -151,9 +134,35 @@ const router = useRouter();
 const showTab = ref(false);
 // 0: 农户, 1: 专家, 2:农资农服
 const curRole = ref(0);
+// USER_TYPE: 1 普通农户,2 托管农户
+const userType = ref(1);
 
 let tabBarHeight = 0;
+
+// 获取用户是否为托管农户,并缓存 USER_TYPE
+const fetchUserType = () => {
+    VE_API.farm
+        .userFarmSelectOption({ userType: 2 })
+        .then(({ data }) => {
+            if (Array.isArray(data) && data.length > 0) {
+                // 有托管农户数据
+                userType.value = 1;
+                localStorage.setItem("USER_TYPE", "1");
+            } else {
+                userType.value = 2;
+                localStorage.setItem("USER_TYPE", "2");
+            }
+        })
+        .catch(() => {
+            // 请求失败时保留默认值,并写入一次缓存
+            localStorage.setItem("USER_TYPE", String(userType.value));
+        });
+};
+
 onMounted(() => {
+    // 进入首页时请求接口,确定是否为托管农户
+    fetchUserType();
+
     setTimeout(() => {
         curRole.value = store.state.app.curRole;
         if (route.meta.showTabbar) {

BIN
src/assets/img/home/home-user.png


BIN
src/assets/img/home/pest.png


BIN
src/assets/img/tab_bar/task-active.png


BIN
src/assets/img/tab_bar/task.png


BIN
src/assets/img/tab_bar/tree-active.png


BIN
src/assets/img/tab_bar/tree.png


+ 6 - 0
src/router/globalRoutes.js

@@ -399,6 +399,12 @@ export default [
         name: "RemindCustomer",
         component: () => import("@/views/old_mini/task_condition/components/remindCustomer.vue"),
     },
+    // 知识库
+    {
+        path: "/knowledge_list",
+        name: "KnowledgeList",
+        component: () => import("@/views/old_mini/home/subPages/knowledgeList.vue"),
+    },
     // 成果报告
     {
         path: "/achievement_report",

+ 59 - 33
src/views/old_mini/home/components/knowledgeCard.vue

@@ -1,55 +1,78 @@
 <template>
     <div class="knowledge-card">
         <div class="knowledge-header">
-                <div class="knowledge-title">
-                    <div
-                        class="title-item"
-                        :class="{ active: activeKnowledgeId === 6 }"
-                        @click="handleKnowledgeClick(6)">
-                        种植知识库
-                    </div>
-                    <div
-                        class="title-item"
-                        :class="{ active: activeKnowledgeId === 7 }"
-                        @click="handleKnowledgeClick(7)">
-                        实战知识库
-                    </div>
+            <div class="knowledge-title">
+                <div class="title-item" :class="{ active: activeKnowledgeId === 6 }" @click="handleKnowledgeClick(6)">
+                    种植知识库
                 </div>
-                <div class="more-text">更多<el-icon class="more-icon"><ArrowRight /></el-icon></div>
+                <div class="title-item" :class="{ active: activeKnowledgeId === 7 }" @click="handleKnowledgeClick(7)">
+                    实战知识库
+                </div>
+            </div>
+            <div class="more-text" @click="handleMoreClick">
+                更多<el-icon class="more-icon"><ArrowRight /></el-icon>
             </div>
-            <div class="knowledge-content">
-                <div class="knowledge-item" @click="handleBannerClick(item.id)" v-for="(item, index) in knowledgeList" :key="index">
-                    <img class="thumb" :src="item.media?.[0]" alt="" />
-                    <div class="card-body-left">
-                        <div class="title van-multi-ellipsis--l2">{{ item.title }}</div>
-                        <div class="date">{{item.createTime }}</div>
-                    </div>
+        </div>
+        <div class="knowledge-content">
+            <div
+                class="knowledge-item"
+                @click="handleBannerClick(item.id)"
+                v-for="(item, index) in knowledgeList"
+                :key="index"
+            >
+                <img class="thumb" :src="item.media?.[0]" alt="" />
+                <div class="card-body-left">
+                    <div class="title van-multi-ellipsis--l2">{{ item.title }}</div>
+                    <div class="date">{{ formatDate(item.createTime) }}</div>
                 </div>
-                <div class="no-data" v-if="knowledgeList.length === 0">暂无数据</div>
             </div>
+            <div class="no-data" v-if="knowledgeList.length === 0">暂无数据</div>
+        </div>
     </div>
 </template>
 
 <script setup>
-import { onMounted, ref } from 'vue';
-import { useRouter } from 'vue-router';
+import { onMounted, ref } from "vue";
+import { useRouter } from "vue-router";
 
 const router = useRouter();
 const activeKnowledgeId = ref(6);
 
+// 按 topicId 缓存知识列表,避免每次切换都请求接口
+const knowledgeCache = ref({});
+
 const handleKnowledgeClick = (index) => {
     activeKnowledgeId.value = index;
+
+    // 如果已经有缓存,直接用缓存数据
+    if (knowledgeCache.value[index]) {
+        knowledgeList.value = knowledgeCache.value[index];
+        return;
+    }
+
+    // 没有缓存时再发起请求
     getKnowledgeList();
 };
 
 const handleBannerClick = (id) => {
     router.push(`/warning_detail?id=${id}`);
-}
+};
+
+const handleMoreClick = () => {
+    router.push(`/knowledge_list?topicId=${activeKnowledgeId.value}`);
+};
 
-const knowledgeList = ref([])
+const knowledgeList = ref([]);
 onMounted(() => {
+    // 默认 topicId 首次进入时请求一次
     getKnowledgeList();
-})
+});
+
+const formatDate = (dateString) => {
+    if (!dateString) return "";
+    // 将 2026-01-06T00:00:00 格式转换为 2026-01-06
+    return dateString.split("T")[0];
+};
 
 const getKnowledgeList = () => {
     const params = {
@@ -58,10 +81,12 @@ const getKnowledgeList = () => {
         topicId: activeKnowledgeId.value,
     };
     VE_API.home.warningPageList(params).then(({ data }) => {
-        knowledgeList.value = [...data, ...data];
-    })
-}
+        knowledgeList.value = data;
 
+        // 按当前 topicId 缓存,后续切换直接读取
+        knowledgeCache.value[activeKnowledgeId.value] = data;
+    });
+};
 </script>
 
 <style lang="scss" scoped>
@@ -71,11 +96,12 @@ const getKnowledgeList = () => {
         display: flex;
         align-items: center;
         justify-content: space-between;
+        padding: 6px 0 2px 0;
         .knowledge-title {
             display: flex;
             align-items: center;
             gap: 10px;
-            color: #BFBFBF;
+            color: #bfbfbf;
             .title-item {
                 cursor: pointer;
                 font-size: 18px;
@@ -87,7 +113,7 @@ const getKnowledgeList = () => {
         }
         .more-text {
             font-size: 13px;
-            color: #4E5969;
+            color: #4e5969;
             cursor: pointer;
             display: flex;
             align-items: center;
@@ -141,4 +167,4 @@ const getKnowledgeList = () => {
         margin-top: 20px;
     }
 }
-</style>
+</style>

+ 19 - 12
src/views/old_mini/home/index.vue

@@ -16,14 +16,14 @@
             :isGarden="false"
             @changeGarden="changeGarden"
         ></weather-info>
-        <div class="farm-monitor-container">
+        <div class="farm-monitor-container" :class="{ 'farmer-role': userType == 2 }">
             <div class="farm-monitor-left" @click="handleCardClick(monitorCards.left)">
                 <div class="title">
                     <span>{{ monitorCards.left.title }}</span>
-                    <el-icon class="icon" v-if="monitorCards.left.title !== '农情采集'"><ArrowRightBold /></el-icon>
+                    <el-icon class="icon" v-if="userType == 2"><ArrowRightBold /></el-icon>
                 </div>
                 <div class="content">{{ monitorCards.left.content }}</div>
-                <div class="arrow">
+                <div class="arrow" v-if="userType != 2">
                     <el-icon class="icon"><ArrowRightBold /></el-icon>
                 </div>
             </div>
@@ -32,7 +32,7 @@
                     v-for="(item, index) in monitorCards.right"
                     :key="index"
                     class="right-item"
-                    :class="{ expert: index === 1, 'one': curRole == 0 }"
+                    :class="{ expert: index === 1 }"
                     @click="handleCardClick(item)"
                 >
                     <div class="title">
@@ -43,7 +43,7 @@
                 </div>
             </div>
         </div>
-        <template v-if="curRole == 0">
+        <template v-if="userType == 2">
             <knowledge-card />
         </template>
         <template v-else>
@@ -163,10 +163,9 @@ onActivated(() => {
     }
 });
 
-
-const curRole = ref(localStorage.getItem("SET_USER_CUR_ROLE"));
+const userType = ref(localStorage.getItem("USER_TYPE"));
 onMounted(() => {
-    if (curRole.value == 2) {
+    if (userType.value != 2) {
         monitorCards.value.right.push({
             title: "新增客户",
             content: "农情先知  高效管理",
@@ -276,6 +275,17 @@ const handleBannerClick = () => {
         margin: 10px;
         gap: 6px;
         height: 134px;
+        &.farmer-role {
+            height: 104px;
+            .farm-monitor-left {
+                background: url("@/assets/img/home/farm-bg-4.png") no-repeat center center / 100% 100%;
+            }
+            .farm-monitor-right {
+                .right-item {
+                    background: url("@/assets/img/home/farm-bg-5.png") no-repeat center center / 100% 100%;
+                }
+            }
+        }
         .farm-monitor-left,
         .farm-monitor-right {
             .title {
@@ -309,7 +319,7 @@ const handleBannerClick = () => {
             flex: 1;
             height: 100%;
             margin-top: 2px;
-            padding: 25px 16px;
+            padding: 25px 12px;
             box-sizing: border-box;
             max-width: 170px;
             background: url("@/assets/img/home/farm-bg-1.png") no-repeat center center / 105% 106%;
@@ -331,9 +341,6 @@ const handleBannerClick = () => {
             .expert {
                 background: url("@/assets/img/home/farm-bg-3.png") no-repeat center center / 100% 100%;
             }
-            .one {
-                background: url("@/assets/img/home/farm-bg-5.png") no-repeat center center / 100% 100%;
-            }
         }
     }
 }

+ 111 - 0
src/views/old_mini/home/subPages/knowledgeList.vue

@@ -0,0 +1,111 @@
+<template>
+    <div class="service-records-page">
+        <custom-header name="知识库"></custom-header>
+        <div class="record-list" v-if="knowledgeList && knowledgeList.length">
+            <div v-for="(item, index) in knowledgeList" :key="index" class="record-card">
+                <img class="thumb" :src="item.media && item.media[0]" alt="暂无图片" />
+                <div class="card-body" @click="handleItemClick(item)">
+                    <div class="card-body-left">
+                        <div class="title van-multi-ellipsis--l2">{{ item.title }}</div>
+                        <div class="date">{{ formatDate(item.createTime) }}</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div v-else class="empty-wrap">
+            <div class="empty-text">暂无数据</div>
+        </div>
+    </div>
+</template>
+<script setup>
+import { ref, onMounted } from "vue";
+import customHeader from "@/components/customHeader.vue";
+import { useRouter, useRoute } from "vue-router";
+const router = useRouter();
+const route = useRoute();
+// 服务记录列表数据
+const knowledgeList = ref([]);
+const topicId = ref(6);
+onMounted(() => {
+    topicId.value = route.query.topicId;
+    getKnowledgeList();
+});
+
+const getKnowledgeList = async () => {
+    const params = {
+        page: 1,
+        limit: 10,
+        topicId: topicId.value,
+    };
+    VE_API.home.warningPageList(params).then(({ data }) => {
+        knowledgeList.value = data;
+    });
+};
+
+const formatDate = (dateStr) => {
+    if (!dateStr) return "";
+    // 将 2026-01-06T00:00:00 格式转换为 2026-01-06
+    return dateStr.split("T")[0];
+};
+
+const handleItemClick = (item) => {
+    router.push(`/warning_detail?id=${item.id}`);
+};
+</script>
+<style lang="scss" scoped>
+.service-records-page {
+    width: 100%;
+    min-height: 100vh;
+    background: #f5f5f5;
+    .record-list {
+        padding: 10px 12px;
+        display: flex;
+        flex-direction: column;
+        gap: 10px;
+    }
+    .record-card {
+        display: flex;
+        gap: 12px;
+        padding: 12px 10px;
+        background: #ffffff;
+        border-radius: 12px;
+        align-items: center;
+        height: 98px;
+        box-sizing: border-box;
+        .thumb {
+            width: 112px;
+            height: 74px;
+            border-radius: 8px;
+            object-fit: cover;
+            flex: none;
+        }
+        .card-body {
+            flex: 1;
+            height: 100%;
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+            .card-body-left {
+                width: 100%;
+                height: 95%;
+                display: flex;
+                flex-direction: column;
+                justify-content: space-between;
+                .date {
+                    font-size: 13px;
+                    color: #86909c;
+                    margin-top: 4px;
+                }
+            }
+        }
+    }
+    .empty-wrap {
+        padding-top: 40px;
+        text-align: center;
+        .empty-text {
+            font-size: 14px;
+            color: #86909c;
+        }
+    }
+}
+</style>

+ 4 - 11
src/views/old_mini/modify_work/reviewWork.vue

@@ -159,7 +159,7 @@
 
             <!-- 按钮 -->
             <div class="up-btn-group" v-show="isPlan">
-                <template v-if="curRole === '2'">
+                <template v-if="curRole == '2'">
                     <div
                         class="up-btn"
                         :class="{ btn: workItem.executeEvidence && workItem.executeEvidence.length }"
@@ -186,12 +186,6 @@
                 </div>
                 <div class="fixed-btn excute" @click="generateReport">生成成果报告</div>
             </div>
-            <div
-                class="fixed-btn-wrap center"
-                v-if="curRole == '0' && workItem.reviewImage && workItem.reviewImage.length"
-            >
-                <div class="fixed-btn excute" @click="handleShare">转发</div>
-            </div>
 
             <!-- 组合照片(用于生成合成图片) -->
             <div class="review-hide-box">
@@ -264,7 +258,7 @@ const route = useRoute();
 const router = useRouter();
 const uploadExecuteRef = ref(null);
 const workItem = ref({});
-const curRole = ref("");
+const curRole = ref(localStorage.getItem("SET_USER_CUR_ROLE"));
 // 农事规划页面-显示上传农事凭证按钮
 const isPlan = ref(false);
 const loading = ref(false);
@@ -287,13 +281,13 @@ const diffInDays = (date, type = "minus") => {
 const paramsPage = ref({});
 const agriculturalRole = ref(null);
 const userId = ref(null);
+const userType = ref(localStorage.getItem("USER_TYPE"));
 onActivated(() => {
     const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
     agriculturalRole.value = userInfo.agriculturalRole;
     userId.value = userInfo.id;
 
     window.scrollTo(0, 0);
-    curRole.value = localStorage.getItem("SET_USER_CUR_ROLE");
     paramsPage.value = route.query.miniJson ? JSON.parse(route.query.miniJson) : {};
     if(paramsPage.value.paramsPage) {
         const data = JSON.parse(paramsPage.value.paramsPage);
@@ -307,7 +301,7 @@ onActivated(() => {
 });
 
 const getButtonText = () => {
-    return (agriculturalRole.value === 1 || (agriculturalRole.value === 2 && workItem.value.executorUserId != userId.value)) && !workItem.value?.reviewImage?.length && workItem.value?.needReview && curRole.value == '2';
+    return (agriculturalRole.value === 1 || (agriculturalRole.value === 2 && workItem.value.executorUserId != userId.value)) && !workItem.value?.reviewImage?.length && workItem.value?.needReview && userType.value != '2';
 };
 
 const getDetail = () => {
@@ -500,7 +494,6 @@ const clearData = () => {
     imageArr.value = [];
     paramsPage.value = {};
     isPlan.value = false;
-    curRole.value = "";
     loading.value = false;
 };