前言:
因为若依为了保护用户的隐私所以没有把user_id存入token中所以需要添加一些配置拿取用户user_id,但是若依为大家存储用户名,头像,角色等信息
默认的存储的信息:
拿取这些是不用配置什么的只需要在js中编写拿取代码:
因为拿取的数据是个集合所以在data中定义tokenList集合对象存储所有信息
# 拿取所有的用户信息存储到tokenList集合对象中
this.tokenList = uni.getStorageSync("storage_data") || {};
# 通过点出他的名字拿取vuex_xxx 比如id就是vuex_id
this.username = this.tokenList.vuex_name
1. 开始配置拿取用户user_id操作
1.1 修改user.js页面
state: {
token: getToken(),
name: storage.get(constant.name),
id: storage.get(constant.id), # 添加id
avatar: storage.get(constant.avatar),
roles: storage.get(constant.roles),
permissions: storag