Files
app-govern/pages/index/index.vue
2023-02-20 14:19:28 +08:00

143 lines
4.2 KiB
Vue

<template>
<Cn-page :loading="loading" noPadding>
<view slot="body">
<view class="index">
<!-- 运维 -->
<YunWei v-if="userInfo.role == 1" />
<!-- 专职 -->
<ZhuanZhi v-if="userInfo.role == 2" />
<!-- 工程 -->
<GongCheng v-if="userInfo.role == 3" />
<!-- 主用户 -->
<ZhuYongHu v-if="userInfo.role == 4" />
<!-- 子用户 -->
<ZiYongHu v-if="userInfo.role == 5" />
<uni-fab ref="fab" direction="vertical" horizontal="right" vertical="bottom" :content="content"
@trigger="trigger" />
</view>
</view>
</Cn-page>
</template>
<script>
import YunWei from "./comp/indexYunWei.vue";
import GongCheng from "./comp/indexGongCheng.vue";
import ZhuYongHu from "./comp/indexZhuYongHu.vue";
import ZiYongHu from "./comp/indexZiYongHu.vue";
import ZhuanZhi from "./comp/indexZhuanZhi.vue";
export default {
components: {
YunWei,
GongCheng,
ZhuYongHu,
ZiYongHu,
ZhuanZhi
},
data () {
return {
loading: false,
userInfo: {
role: 4
}
}
},
computed: {
content () {
let arr = [1, 3, 4]
let content = [{
iconPath: '/static/mine3.png',
text: '运维管理',
}, {
iconPath: '/static/mine3.png',
text: '专职管理',
}, {
iconPath: '/static/mine3.png',
text: '工程',
}, {
iconPath: '/static/mine3.png',
text: '主用户',
}, {
iconPath: '/static/mine3.png',
text: '子用户',
}
]
// if (arr.indexOf(this.userInfo.role) > -1) {
// content.push({
// iconPath: '/static/device.png',
// text: '添加设备',
// }, {
// iconPath: '/static/gateway.png',
// text: '添加网关',
// })
// }
return content
}
},
methods: {
send () {
uni.createPushMessage({
title: '灿能',
content: '灿能推送',
success: function (res) {
console.log('推送成功')
},
fail: function (res) {
console.log('推送失败')
}
})
},
trigger (e) {
if (e.index === 5) {
uni.navigateTo({
url: '/pages/device/new'
})
} else if (e.index === 6) {
uni.navigateTo({
url: '/pages/gateway/new'
})
} else {
this.userInfo.role = e.index + 1
uni.setStorageSync('userInfo', {
role: e.index + 1
})
let roleName = ''
switch (e.index + 1) {
case 1:
roleName = '运维管理'
break
case 2:
roleName = '专职管理'
break
case 3:
roleName = '工程'
break
case 4:
roleName = '主用户'
break
case 5:
roleName = '子用户'
break
}
this.$util.toast(roleName + '角色切换成功')
}
this.$refs.fab.close()
}
},
onLoad (options) {
this.loading = false
},
onShow () {
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo) || { role: 4 }
}
}
</script>
<style lang="scss">
.index {
padding: 34rpx 0 0;
}
/deep/ .uni-card {
background: $uni-theme-white;
}
</style>