1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- Vue.use(Vuex)
- const state = {
- logined: false,
- loginedUser: {
- username: '',
- agency: false
- }
- }
- const mutations = {
- LOGIN (state) {
- state.logined = true
- let user = JSON.parse(localStorage.getItem('userInfo'))
- state.loginedUser.username = user.username
- // state.loginedUser.agency = user.agency
- },
- LOGOUT(state){
- state.logined = false
- state.loginedUser.username = ''
- // state.loginedUser.agency = false
- }
- }
- const actions = {
- login(context){
- context.commit('LOGIN')
- },
- logout(context){
- context.commit('LOGOUT')
- }
- }
- const getters = {
- }
- export default new Vuex.Store({
- state,
- mutations,
- actions,
- getters
- })
|