|
|
@@ -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) {
|