import { getToken, setToken } from '@/utils/auth' import Cache from '@/utils/cache' const getDefaultState = () => { return { token: getToken(), info: Cache.get('userInfo'), allset: '', person:Cache.get('personInfo'), //核销员 staff:'', } } const state = getDefaultState() const mutations = { SET_TOKEN: (state, token) => { setToken(token) state.token = token }, SET_INFO: (state, info) => { Cache.set('userInfo', info) state.info = info }, SET_ALL_SET: (state, allset) => { Cache.set('allset', allset) state.allset = allset }, SET_PERSON: (state, person) => { Cache.set('personInfo', person) state.person = person }, SET_STAFF: (state, staff) => { Cache.set('staff', staff) state.staff = staff }, } const actions = { token({ commit }, token) { commit('SET_TOKEN', token) }, info({ commit }, info) { commit('SET_INFO', info) }, allset({ commit }, allset) { commit('SET_ALL_SET', allset) }, person({ commit }, person) { commit('SET_PERSON', person) }, staff({ commit }, staff) { commit('SET_STAFF', staff) }, } export default { namespaced: true, state, mutations, actions }