vue 管理后台,等级权限问题

1.用户登录 url +用户id 或 其他的唯一标识 发送请求
2 后台返回一个 这个id 对应的字段 存储

		userLogin() {
			if (this.userInfo.username !== "" && this.userInfo.password !== "") {
				this.$post(this.$url + "mgr/login", this.userInfo)
				.then(data => {
					if (data.code == 1) {
						this.$store.commit("setTokenKey", data.data.sessionId);
						this.$store.commit("userinfo", data.data);
						// 保存用户的权限路由
						localStorage.setItem("roles", data.data.roles);  //这个localstorage需要考虑
						this.$store.commit("updateMenulist");
						this.$router.push({ name: "person" });
					} else {
						this.$message.error(data.info);
					}
				})
				.catch(err => {});
			}
		}

3.解析对应字段

let roles = localStorage.getItem('roles') ? localStorage.getItem('roles') : "";
        console.log(roles);
        roles = roles.split(",");
        this.agent = roles.indexOf('agent') != -1?true:false;
        if(this.agent){
            this.isChildUpdate1 = true;
            this.isChildUpdate2 = false;
        }else{
            this.isChildUpdate1 = false;
            this.isChildUpdate2 = true;
            this.activeName = "second";
        }
        this.operator = roles.indexOf('operator') != -1?true:false;

之后 使用v-if 控制 显示到前端

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值