46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
export default {
|
|
namespaced: true,
|
|
state: {
|
|
showLoginModal: false,
|
|
openId: "",
|
|
token: "",
|
|
userInfo: null,
|
|
},
|
|
getters: {
|
|
showLoginModal(state) {
|
|
return state.showLoginModal;
|
|
},
|
|
userInfo(state) {
|
|
return state.userInfo;
|
|
},
|
|
},
|
|
mutations: {
|
|
showLoginModal(state, data) {
|
|
state.showLoginModal = data;
|
|
},
|
|
openId(state, data) {
|
|
state.openId = data;
|
|
},
|
|
token(state, data) {
|
|
state.token = data;
|
|
},
|
|
userInfo(state, data) {
|
|
state.userInfo = data;
|
|
}
|
|
},
|
|
actions: {
|
|
logout(context) {
|
|
context.commit('userInfo', null);
|
|
},
|
|
token(context, token) {
|
|
let cacheToken = uni.getStorageSync('user_access_token');
|
|
if (typeof token !== "undefined") {
|
|
uni.setStorageSync('user_access_token', token);
|
|
context.commit('token', token);
|
|
} else if (typeof token === "undefined" && cacheToken) {
|
|
context.commit('token', cacheToken);
|
|
}
|
|
}
|
|
}
|
|
}
|