Files
app-govern/pages/index/index.vue

174 lines
5.2 KiB
Vue
Raw Normal View History

2023-01-11 16:33:13 +08:00
<template>
2023-02-20 14:19:28 +08:00
<Cn-page :loading="loading" noPadding>
2023-01-13 16:32:56 +08:00
<view slot="body">
<view class="index">
2023-02-09 08:50:01 +08:00
<!-- 运维 -->
<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" />
2023-02-28 16:39:58 +08:00
<YouKe v-if="userInfo.role == 6"> </YouKe>
2023-02-07 17:59:54 +08:00
<uni-fab ref="fab" direction="vertical" horizontal="right" vertical="bottom" :content="content"
@trigger="trigger" />
2023-01-13 16:32:56 +08:00
</view>
2023-01-13 13:23:25 +08:00
</view>
2023-02-23 08:44:46 +08:00
</Cn-page>
2023-01-11 16:33:13 +08:00
</template>
<script>
2023-02-09 08:50:01 +08:00
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";
2023-02-28 16:39:58 +08:00
import YouKe from "./comp/indexYouKe.vue";
2023-01-13 13:23:25 +08:00
export default {
2023-02-09 08:50:01 +08:00
components: {
YunWei,
GongCheng,
ZhuYongHu,
ZiYongHu,
2023-02-28 16:39:58 +08:00
ZhuanZhi,
YouKe
2023-02-09 08:50:01 +08:00
},
2023-01-13 13:23:25 +08:00
data () {
return {
2023-02-06 13:34:15 +08:00
loading: false,
2023-02-09 08:50:01 +08:00
userInfo: {
2023-02-20 14:19:28 +08:00
role: 4
2023-02-09 08:50:01 +08:00
}
}
},
computed: {
content () {
let arr = [1, 3, 4]
let content = [{
iconPath: '/static/mine3.png',
text: '运维管理',
}, {
iconPath: '/static/mine3.png',
text: '专职管理',
}, {
iconPath: '/static/mine3.png',
text: '工程',
2023-02-06 13:34:15 +08:00
}, {
2023-02-09 08:50:01 +08:00
iconPath: '/static/mine3.png',
text: '主用户',
}, {
iconPath: '/static/mine3.png',
text: '子用户',
2023-02-28 16:39:58 +08:00
}, {
iconPath: '/static/mine3.png',
text: '游客',
2023-02-09 08:50:01 +08:00
}
2023-02-06 13:34:15 +08:00
]
2023-02-09 08:50:01 +08:00
return content
2023-01-13 13:23:25 +08:00
}
},
methods: {
2023-02-01 16:59:32 +08:00
send () {
uni.createPushMessage({
title: '灿能',
content: '灿能推送',
success: function (res) {
console.log('推送成功')
},
fail: function (res) {
console.log('推送失败')
}
})
},
2023-02-09 08:50:01 +08:00
2023-02-06 13:34:15 +08:00
trigger (e) {
2023-02-28 16:39:58 +08:00
if (e.index === 500) {
2023-02-06 13:34:15 +08:00
uni.navigateTo({
url: '/pages/device/new'
})
2023-02-09 08:50:01 +08:00
} else {
this.userInfo.role = e.index + 1
uni.setStorageSync('userInfo', {
role: e.index + 1
})
let roleName = ''
switch (e.index + 1) {
case 1:
roleName = '运维管理'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
index: 1
})
2023-02-09 08:50:01 +08:00
break
case 2:
roleName = '专职管理'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
index: 1
})
2023-02-09 08:50:01 +08:00
break
case 3:
roleName = '工程'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
index: 1
})
2023-02-09 08:50:01 +08:00
break
case 4:
roleName = '主用户'
2023-02-23 08:44:46 +08:00
uni.setTabBarBadge({
index: 1,
text: '6'
})
2023-02-09 08:50:01 +08:00
break
case 5:
roleName = '子用户'
2023-02-23 08:44:46 +08:00
uni.setTabBarBadge({
index: 1,
text: '6'
})
2023-02-09 08:50:01 +08:00
break
2023-02-28 16:39:58 +08:00
case 6:
roleName = '游客'
uni.setTabBarBadge({
index: 1,
text: '6'
})
break
2023-02-09 08:50:01 +08:00
}
this.$util.toast(roleName + '角色切换成功')
2023-02-06 13:34:15 +08:00
}
2023-02-09 08:50:01 +08:00
this.$refs.fab.close()
2023-02-06 13:34:15 +08:00
}
2023-01-13 16:32:56 +08:00
},
2023-02-09 08:50:01 +08:00
onLoad (options) {
this.loading = false
},
2023-01-13 16:32:56 +08:00
onShow () {
2023-02-23 08:44:46 +08:00
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
if (!this.userInfo) {
this.userInfo = {
role: 4
}
uni.setStorageSync('userInfo', {
role: 4
})
}
2023-02-28 16:39:58 +08:00
if (this.userInfo.role == 4 || this.userInfo.role == 5 || this.userInfo.role == 6) {
2023-02-23 08:44:46 +08:00
uni.setTabBarBadge({
index: 1,
text: '6'
})
}
2023-01-13 13:23:25 +08:00
}
}
2023-01-11 16:33:13 +08:00
</script>
2023-01-13 16:32:56 +08:00
<style lang="scss">
.index {
2023-02-20 14:19:28 +08:00
padding: 34rpx 0 0;
2023-01-13 13:23:25 +08:00
}
2023-02-07 17:59:54 +08:00
/deep/ .uni-card {
background: $uni-theme-white;
}
2023-01-11 16:33:13 +08:00
</style>