提交 1537f12d 编写于 作者: huangwensu's avatar huangwensu

获取菜单和用户信息

上级 c2e095e4
<template>
<div>
<v-header></v-header>
<v-slidebar></v-slidebar>
<v-header :userName="userName" :portrait="portrait"></v-header>
<v-slidebar :authList="authList" :tokenValue="token"></v-slidebar>
<el-container>
<div class="content" id="body-content">
<transition name="router-fade" mode="out-in">
......@@ -22,6 +22,8 @@
import VHeader from './views/layout/header.vue'
import VSlidebar from './views/layout/slidebar.vue'
import VFooter from './views/layout/footer.vue'
import { base64decode } from "./utils/utils.js"
import { mapActions } from 'vuex'
let vm = null
export default {
components:{
......@@ -31,11 +33,15 @@ export default {
},
data() {
return {
token: '',
userName: '',
portrait: '',
authList: {}
}
},
created() {
vm = this
vm.getToken()
},
mounted() {
setInterval(function(){
......@@ -43,6 +49,18 @@ export default {
},60000)
},
methods: {
// 解密token
getToken() {
let href = window.location.href
let offset = href.indexOf("?")
if(offset !== -1) {
let paramStr = href.substring(offset + 1, href.length)
let pars = base64decode(paramStr).split("&")[0].split("=")[1]
vm.token = pars
}
vm.changeToken(vm.token)
vm.getUserAuth(vm.token)
},
// 实时消息推送
pushMessage() {
vm.$notify({
......@@ -50,6 +68,22 @@ export default {
message: '这是一条警告的提示消息',
type: 'warning'
});
},
// 修改token
...mapActions([
'changeToken',
'changeIdType'
]),
// 获取用户权限
getUserAuth(token) {
vm.GET('common/v1/role',{token: token}).then((res) => {
if(res.code == '000000') {
vm.changeIdType(res.data.idType)
vm.userName = res.data.name
vm.portrait = res.data.imageUrl
vm.authList = res.data.auth
}
})
}
}
}
......
......@@ -11,8 +11,11 @@ const service = axios.create({
// request拦截器
service.interceptors.request.use(config => {
if(config.data && config.data.token) {
localStorage.setItem('storageToken',config.data.token)
}
config.headers['sysCode'] = 12
config.headers['token'] = 'AB14D7D7675E4D09B4B1566170076122'
config.headers['token'] = localStorage.getItem('storageToken')
config.headers['deviceInfo'] = JSON.stringify({ "app_channel": "", "app_mac": "", "app_uuid": "", "app_version": "", "device_brand": "", "device_ip": "", "device_model": "", "device_net": "", "device_ops": "", "resolution_wh": "", "system_level": "", "device_type": '10' })
// if (config.data && config.data.setEntry) {
// config.headers['sysCode'] = config.data.sysCode || 10
......
......@@ -287,6 +287,7 @@ import BreadCrumb from '../../components/breadcrumb.vue'
import { doUpload, getFilePath } from "../../utils/qiniuUtil"
import { validateWord150 } from "../../utils/validate.js"
import { mapGetters } from 'vuex'
import { openLoading, closeLoading } from '../../utils/utils';
let vm = null
// 判断组件是否重名
let validateRepeatWord = function(rule, value, callback, message) {
......@@ -462,7 +463,9 @@ export default {
// 根据ID查询组件基本信息
componentBasicInfo() {
if(vm.componentId) {
openLoading(vm)
vm.GET('portalComponent/queryPortalComponentById',{id: vm.componentId}).then((res) => {
closeLoading(vm)
if( res.code == '000000') {
vm.portalComponent = res.data.portalComponent
vm.itemName = vm.portalComponent.name
......@@ -567,7 +570,9 @@ export default {
if(_this.width != 750 || _this.height != 420) {
vm.$message.info('图片不符合规范,请根据规范上传图片')
}else {
openLoading(vm)
doUpload(vm,file, getFilePath(file,null), 'preview4', 'progress1', 1).then(function (path) {
closeLoading(vm)
vm.portalComponent.imageUrl = path.fullPath
});
}
......
......@@ -73,6 +73,7 @@ import BreadCrumb from '../../components/breadcrumb.vue'
import { doUpload, getFilePath } from "../../utils/qiniuUtil"
import { validateWord } from "../../utils/validate.js"
import { mapGetters } from 'vuex'
import { openLoading, closeLoading } from '../../utils/utils';
let vm = null
export default {
components: {
......@@ -133,7 +134,9 @@ export default {
methods: {
// 列表查询
search() {
vm.GET('/portalComponent/queryPortalComponent',vm.searchParam).then((res) => {
openLoading(vm)
vm.GET('portalComponent/queryPortalComponent',vm.searchParam).then((res) => {
closeLoading(vm)
if( res.code == '000000' ) {
vm.tableData = res.data.queryList
vm.totalRows = res.data.total
......
......@@ -7,34 +7,27 @@
<div class="user-info">
<el-dropdown trigger="click" @command="handleCommand">
<div class="el-dropdown-link">
<img class="user-logo" src="../../assets/image/img.jpg">
<span id="headName">{{name}}</span><i class="el-icon-caret-bottom"></i>
<img class="user-logo" :src="portrait">
<span id="headName">{{userName}}</span><i class="el-icon-caret-bottom"></i>
</div>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item command="logout">退出</el-dropdown-item> -->
<el-dropdown-item command="logout">注销</el-dropdown-item>
<el-dropdown-item @click="forward">返回云鹊医首页</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<!--导航-->
<!-- <div class="user-info" style="padding-right:10px;">
<el-dropdown trigger="click" @command="handleCommand">
<div>
<span class="el-dropdown-link">返回云鹊医首页</span>
<span class="line">|</span>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="logout">注销</el-dropdown-item>
<el-dropdown-item @click="forward">返回云鹊医首页</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div> -->
</div>
</template>
<script>
export default {
props: {
portrait: {
type: String
},
userName: {
type: String
}
},
data() {
return {
name: 'hws',
......
......@@ -21,47 +21,23 @@
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { mapGetters } from 'vuex'
import { setTimeout } from 'timers';
let vm = null
export default {
props: {
tokenValue: {
type: String
},
authList: {
type: Object,
default: () => {}
}
},
data() {
return {
token: '',
authList: {},
items: [
{
title: '数据总览',
icon: 'el-icon-menu',
index: 'home'
},{
title: '教培项目',
icon: 'el-icon-message',
index: 'item',
subs: [
{
title: '项目组件',
icon: 'el-icon-setting',
index: 'item-component'
},
{
title: '项目管理',
icon: 'el-icon-setting',
index: 'item-manager'
}
]
},{
title: '系统管理',
icon: 'el-icon-menu',
index: 'system',
subs: [
{
title: '角色管理',
icon: 'el-icon-setting',
index: 'role'
}
]
}
]
// authList: {},
items: []
}
},
computed: {
......@@ -71,36 +47,39 @@ export default {
},
created() {
vm = this
vm.token = vm.$route.query.token || 'C1C5360EEC754092B9EC244147B35BB7'
vm.changeToken(vm.token)
vm.getUserAuth(vm.token)
},
mounted() {
vm.authSelect()
},
methods: {
// 修改token
...mapActions([
'changeToken',
'changeIdType'
]),
// 获取用户权限
getUserAuth(token) {
vm.GET('common/v1/role',{token: token}).then((res) => {
if(res.code == '000000') {
vm.changeIdType(res.data.idType)
vm.authList = res.data.auth
if(!vm.authList.P001) { // 项目管理
vm.items[1].subs[1].index = 'blank'
}
if(!vm.authList.P002) { // 组件管理
vm.items[1].subs[0].index = 'blank'
}
if(!vm.authList.P001) { // 角色管理
vm.items[2].subs[0].index = 'blank'
}
}
})
// 获取菜单数据
authSelect() {
let req = {
"token": vm.tokenValue,
"system_type": "25"
}
vm.POST('portalComponent/menu/list',req).then((res) => {
if( res.code == '000000') {
vm.items = res.data.picapMenuModels
vm.$nextTick(() => {
vm.getUserAuth()
})
}
})
},
// 获取用户权限
getUserAuth() {
if(vm.authList && vm.authList.length > 0) {
if(!vm.authList.P001) { // 项目管理
vm.items[1].subs[1].index = 'blank'
}
if(!vm.authList.P002) { // 组件管理
vm.items[1].subs[0].index = 'blank'
}
if(!vm.authList.P001) { // 角色管理
vm.items[2].subs[0].index = 'blank'
}
}
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册