|
@@ -1,14 +1,14 @@
|
|
|
<template>
|
|
|
<view class="tm-tabbar">
|
|
|
<template v-for="item in rolToTabBars">
|
|
|
- <view
|
|
|
- :class="{'tab-item': true, active: item.pagePath === currentPagePath}"
|
|
|
- :key="item.text"
|
|
|
- @click="navigateTo(item.pagePath)" >
|
|
|
- <image
|
|
|
- class="icon"
|
|
|
- :src="item.pagePath === currentPagePath
|
|
|
- ? item.selectedIconPath
|
|
|
+ <view
|
|
|
+ :class="{'tab-item': true, active: item.pagePath === currentPagePath}"
|
|
|
+ :key="item.text"
|
|
|
+ @click="navigateTo(item.pagePath)" >
|
|
|
+ <image
|
|
|
+ class="icon"
|
|
|
+ :src="item.pagePath === currentPagePath
|
|
|
+ ? item.selectedIconPath
|
|
|
: item.iconPath"
|
|
|
></image>
|
|
|
<text>{{ item.text }}</text>
|
|
@@ -22,22 +22,12 @@
|
|
|
* 底部tabBar
|
|
|
* 芦荟
|
|
|
* 2021.2.1
|
|
|
- * props: {
|
|
|
- * permission:对应的角色(权限)(1、管理员 2、查核组长 3、查核组员 4、单位负责人 5、改善者)
|
|
|
- * }
|
|
|
*/
|
|
|
export default {
|
|
|
- props: {
|
|
|
- // 对应的角色(权限)(1、管理员 2、查核组长 3、查核组员 4、单位负责人 5、改善者)
|
|
|
- permission: {
|
|
|
- type: Number,
|
|
|
- default: () => 0
|
|
|
- }
|
|
|
- },
|
|
|
data() {
|
|
|
return {
|
|
|
// 当前路由地址
|
|
|
- currentPagePath: '',
|
|
|
+ currentPagePath: '',
|
|
|
// tabbar列表(这是最全的)
|
|
|
tabBarList: [
|
|
|
{
|
|
@@ -46,24 +36,24 @@
|
|
|
selectedIconPath: '/static/tabbar/creatingSituations-select.png', // 选中时的图片路径
|
|
|
pagePath: 'pages/creatingSituations/creatingSituations' // 页面路径
|
|
|
},{
|
|
|
- text: '任务',
|
|
|
- iconPath: '/static/tabbar/mission-unselect.png',
|
|
|
- selectedIconPath: '/static/tabbar/mission-select.png',
|
|
|
+ text: '任务',
|
|
|
+ iconPath: '/static/tabbar/mission-unselect.png',
|
|
|
+ selectedIconPath: '/static/tabbar/mission-select.png',
|
|
|
pagePath: 'pages/mission/mission'
|
|
|
},{
|
|
|
- text: '配置',
|
|
|
- iconPath: '/static/tabbar/setting-unselect.png',
|
|
|
- selectedIconPath: '/static/tabbar/setting-select.png',
|
|
|
+ text: '配置',
|
|
|
+ iconPath: '/static/tabbar/setting-unselect.png',
|
|
|
+ selectedIconPath: '/static/tabbar/setting-select.png',
|
|
|
pagePath: 'pages/configure/configure'
|
|
|
},{
|
|
|
- text: '我的',
|
|
|
- iconPath: '/static/tabbar/my-unselect.png',
|
|
|
- selectedIconPath: '/static/tabbar/my-select.png',
|
|
|
+ text: '我的',
|
|
|
+ iconPath: '/static/tabbar/my-unselect.png',
|
|
|
+ selectedIconPath: '/static/tabbar/my-select.png',
|
|
|
pagePath: 'pages/home/home'
|
|
|
},{
|
|
|
- text: '日历',
|
|
|
- iconPath: '/static/tabbar/calendar-unselect.png',
|
|
|
- selectedIconPath: '/static/tabbar/calendar-select.png',
|
|
|
+ text: '日历',
|
|
|
+ iconPath: '/static/tabbar/calendar-unselect.png',
|
|
|
+ selectedIconPath: '/static/tabbar/calendar-select.png',
|
|
|
pagePath: 'pages/index/index'
|
|
|
}
|
|
|
],
|
|
@@ -74,31 +64,12 @@
|
|
|
{permission: 3, name: '查核组员', tabBarIndexs: [0, 4, 3]},
|
|
|
{permission: 4, name: '单位负责人', tabBarIndexs: [0, 1, 3]},
|
|
|
{permission: 5, name: '改善者', tabBarIndexs: [1, 3]}
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- computed:{
|
|
|
- rolToTabBars() {
|
|
|
- if(this.permission == 0) {
|
|
|
- return []
|
|
|
- }else {
|
|
|
- let current = this.rolList.find(item => item.permission == this.permission) || {};
|
|
|
- if(current){
|
|
|
- let tabBars = [];
|
|
|
- current.tabBarIndexs.map(index => {
|
|
|
- tabBars.push(this.tabBarList[index]);
|
|
|
- });
|
|
|
- return tabBars;
|
|
|
- }else {
|
|
|
- return [];
|
|
|
- }
|
|
|
- return []
|
|
|
- }
|
|
|
+ ],
|
|
|
+ rolToTabBars: [],
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
|
- let routes = getCurrentPages()
|
|
|
- this.currentPagePath = routes[routes.length - 1].route;
|
|
|
+ this.getRolToTabBars();
|
|
|
},
|
|
|
methods: {
|
|
|
// 路由跳转
|
|
@@ -107,6 +78,26 @@
|
|
|
uni.navigateTo({
|
|
|
url: `/${pagePath}`
|
|
|
});
|
|
|
+ },
|
|
|
+ // 获取权限对应的地步导航
|
|
|
+ getRolToTabBars() {
|
|
|
+ const permission = uni.getStorageSync('nowPermission');
|
|
|
+ if(!permission) {
|
|
|
+ this.rolToTabBars = [];
|
|
|
+ }else {
|
|
|
+ let current = this.rolList.find(item => item.permission == permission) || {};
|
|
|
+ if(current){
|
|
|
+ let tabBars = [];
|
|
|
+ current.tabBarIndexs.map(index => {
|
|
|
+ tabBars.push(this.tabBarList[index]);
|
|
|
+ });
|
|
|
+ this.rolToTabBars = tabBars;
|
|
|
+ }else {
|
|
|
+ this.rolToTabBars = [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let routes = getCurrentPages();
|
|
|
+ this.currentPagePath = routes[routes.length - 1].route;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -118,30 +109,30 @@
|
|
|
left: 0;
|
|
|
bottom: 0;
|
|
|
display: flex;
|
|
|
- width: 100%;
|
|
|
+ width: 100%;
|
|
|
height: 87.5rpx;
|
|
|
border-top: 0.62rpx solid #DADEE6;
|
|
|
background-color: #fff;
|
|
|
-
|
|
|
+
|
|
|
.tab-item {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
flex: 1;
|
|
|
-
|
|
|
+
|
|
|
.icon {
|
|
|
margin-bottom: 10rpx;
|
|
|
width: 27.5rpx;
|
|
|
height: 28.75rpx;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
>text {
|
|
|
font-size: 15rpx;
|
|
|
color: #3D424D;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.active.tab-item {
|
|
|
>text {
|
|
|
color: #3377FF;
|