55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import user from "@/core/models/user";
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
showLoginModal: false,
|
|
openId: "",
|
|
token: "",
|
|
finishInfo: false,
|
|
info: {
|
|
id: 0,
|
|
avatar: "",
|
|
nickname: "",
|
|
openid: "",
|
|
mobile: "",
|
|
createTime: 0,
|
|
worker: {},
|
|
},
|
|
},
|
|
getters: {
|
|
isLogin(state) {
|
|
return state.token.length > 0;
|
|
},
|
|
},
|
|
mutations: {
|
|
showLoginModal(state, data) {
|
|
state.showLoginModal = data;
|
|
},
|
|
openId(state, data) {
|
|
state.openId = data;
|
|
},
|
|
token(state, data) {
|
|
state.token = data;
|
|
},
|
|
info(state, data) {
|
|
state.info = data;
|
|
},
|
|
finishInfo(state, data) {
|
|
state.finishInfo = data;
|
|
}
|
|
},
|
|
actions: {
|
|
async info(context, refresh) {
|
|
await user.info(refresh).then(info => {
|
|
if (info.worker != null) {
|
|
context.commit('finishInfo', true);
|
|
}
|
|
context.commit('info', info);
|
|
});
|
|
},
|
|
logout(context) {
|
|
context.commit('info', null);
|
|
},
|
|
}
|
|
}
|