You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.6 KiB

11 months ago
<template>
<view>
<u-tabbar activeColor="#2294E6" :value="name" :fixed="true" :placeholder="false" :safeAreaInsetBottom="false">
<u-tabbar-item :text="item.text" :name='item.text' @click="to(item)" v-for="(item,index) in list">
<image class="u-page__item__slot-icon" slot="active-icon" :src="item.selectedIconPath"></image>
<image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.iconPath"></image>
</u-tabbar-item>
</u-tabbar>
</view>
</template>
<script>
export default {
props: {
name: {
default: '首页',
// type:'String'
}
},
watch: {
// path: {
// handler(newVal, oldVal) {
// // this.initVal()
// },
// // immediate 设为true,进入页面会立即执行handler函数。
// immediate: true
// }
},
data() {
return {
$: this.$,
home: {
// 最少2个、最多5个 tab
"pagePath": "/pages/index/index",
// 页面路径,必须在 pages 中先定义
"iconPath": "/static/nav/index.png",
// 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px
"selectedIconPath": "/static/nav/index_active.png",
// 选中时的图片路径
"text": "首页"
// tab 上按钮文字
},
approve: {
"pagePath": "/pages/approve/index",
"iconPath": "/static/nav/jobfind.png",
"selectedIconPath": "/static/nav/jobfind_active.png",
"text": "审批"
},
investigation: {
"pagePath": "/pages/investigation/index",
"iconPath": "/static/nav/job.png",
"selectedIconPath": "/static/nav/job_active.png",
"text": "排查"
},
governance: {
"pagePath": "/pages/governance/index",
"iconPath": "/static/nav/lean.png",
"selectedIconPath": "/static/nav/lean_active.png",
"text": "治理"
},
mine: {
"pagePath": "/pages/mine/index",
"iconPath": "/static/nav/mine.png",
"selectedIconPath": "/static/nav/mine_active.png",
"text": "我的"
},
"list": [
],
value: 0
}
},
created() {
this.initTab()
},
methods: {
to(item, index) {
this.value = index
uni.switchTab({
url: item.pagePath
})
},
initVal() {
for (let i in this.list) {
if ('/pages/' + this.path + '/index' == this.list[i].pagePath) {
this.value = i
}
}
},
initTab() {
let role = this.$.getData('userInfo').role || []
if (role.includes('领导')) {
this.list.push(this.home)
this.list.push(this.approve)
this.list.push(this.investigation)
this.list.push(this.governance)
this.list.push(this.mine)
}
if (role.includes('排查人员') && !role.includes('领导')) {
this.list.push(this.home)
// this.list.push(this.approve)
this.list.push(this.investigation)
this.list.push(this.governance)
this.list.push(this.mine)
}
if (!role.includes('排查人员') && !role.includes('领导')) {
this.list.push(this.home)
// this.list.push(this.approve)
// this.list.push(this.investigation)
this.list.push(this.governance)
this.list.push(this.mine)
}
for (let i in this.list) {
if ('/pages/' + this.path + '/index' == this.list[i].pagePath) {
// console.log('/pages/' + this.path + '/index' == this.list[i].pagePath,this.list.length,i)
// this.value = Number(i)
}
}
// console.log('/pages/'+this.path+'/index')
// console.log('/pages/' + this.path + '/index')
}
}
}
</script>
<style lang="scss" scoped>
.u-page__item__slot-icon {
width: 46rpx;
height: 46rpx;
}
</style>