You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
canteen/store/user.js

35 lines
706 B

export default {
//开启命名空间
namespaced: true ,
//数据
state: () => ({
token : '',
//用户的信息对象
userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}')
}),
//方法
mutations : {
updateUserInfo(state,userinfo){
state.userinfo = userinfo
this.commit('m_user/saveUserInfoToStorage')
},
saveUserInfoToStorage(state)
{
uni.setStorageSync('userinfo',JSON.stringify(state.userinfo))
},
updatetoken(state, token)
{
state.token = token
this.commit('m_user/savetokentostorage')
},
savetokentostorage(state){
uni.setStorageSync('token',state.token)
}
},
getters: {},
}