工作端小程序
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.
 
 
 
 
 

40 lines
722 B

// store/user.js
const state = {
userInfo: null,
token:uni.getStorageSync('token') || null,
};
const mutations = {
SET_USER_INFO(state, info) {
state.userInfo = info;
},
SET_TOKEN(state, token) {
state.token = token;
},
LOGOUT(state) {
state.userInfo = null;
state.token = null;
},
};
const actions = {
setUserInfo({ commit }, info) {
commit("SET_USER_INFO", info);
},
setToken({ commit }, token) {
commit("SET_TOKEN", token);
uni.setStorageSync('token', token);
},
logout({ commit }) {
commit("LOGOUT");
uni.removeStorageSync('token');
uni.removeStorageSync('userInfo');
},
};
export default {
namespaced: true,
state,
mutations,
actions,
};