提交 80049ce5 编写于 作者: 小刘28's avatar 小刘28 💬

Merge branch 'lxl'

{
"pages": [
{
"path": "pages/template/template-2-web",
"style": {
"navigationBarTitleText": "template-2-web"
}
},
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/tabbar-a/tabbar-a",
......@@ -138,23 +132,33 @@
"list": [
{
"pagePath": "pages/tabbar-a/tabbar-a",
"text": "页面A"
"text": "页面A",
"iconPath": "static/normal.png",
"selectedIconPath": "static/selected.png"
},
{
"pagePath": "pages/tabbar-b/tabbar-b",
"text": "页面B"
"text": "页面B",
"iconPath": "static/normal.png",
"selectedIconPath": "static/selected.png"
},
{
"pagePath": "pages/tabbar-c/tabbar-c",
"text": "页面C"
"text": "页面C",
"iconPath": "static/normal.png",
"selectedIconPath": "static/selected.png"
},
{
"pagePath": "pages/tabbar-d/tabbar-d",
"text": "页面D"
"text": "页面D",
"iconPath": "static/normal.png",
"selectedIconPath": "static/selected.png"
},
{
"pagePath": "pages/tabbar-e/tabbar-e",
"text": "页面E"
"text": "页面E",
"iconPath": "static/normal.png",
"selectedIconPath": "static/selected.png"
}
]
},
......
<template>
<view>
<view class="">
<button @click="clickGetUserRoles()">获取当前用户拥有的角色</button>
</view>
<view class="">
<button @click="clickAddRolesToUser()">给当前用户添加角色</button>
</view>
<view class="">
<button @click="clickSearchUserIncludeRole()">查询用户是否拥有user角色</button>
</view>
</view>
</template>
......@@ -12,7 +20,18 @@
}
},
methods: {
clickGetUserRoles(){
let roles = this.$store.getters.getRoles;
console.log(roles);
},
clickAddRolesToUser(){
let roles = ['admin','user','user1'];
this.$store.commit('M_updateRoles',roles);
},
clickSearchUserIncludeRole(){
let flag = this.$store.getters.getSearchRole('user1');
console.log(flag);
},
}
}
</script>
......
......@@ -6,11 +6,16 @@ Vue.use(Vuex);
//Vuex.Store 构造器选项
const store = new Vuex.Store({
state: { //存放状态
state: {
// 用户信息
user: uni.getStorageSync('user') || {},
// token信息
token: uni.getStorageSync('token') || '',
// 是否登录
isLogin: uni.getStorageSync('isLogin') || false,
roles:uni.getStorageSync('roles') || {},
// 用户拥有的角色
roles:uni.getStorageSync('roles') || [],
// 用户拥有的权限
premiss:uni.getStorageSync('premiss') || [],
},
mutations: {
......@@ -69,9 +74,15 @@ const store = new Vuex.Store({
getRoles(state) {
return state.roles;
},
getSearchRole:(state) => (role) => {
return state.roles.includes(role);
},
getPremiss(state) {
return state.premiss;
}
},
getSearchPremiss:(state) => (premiss) => {
return state.premiss.includes(premiss);
},
},
modules: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册