import { getStore, setStore } from '@/util/store' const user = { state: { access_token: getStore({ name: 'access_token' }) || '', user_id: getStore({ name: 'user_id' }) || '', code: getStore({ name: 'code' }) || '', authId: getStore({ name: 'auth_id' }) || '', accountId: getStore({ name: 'account_id' }) || '', signInfo: getStore({ name: 'signInfo' }), userInfo: {} }, actions: { setToken ({ commit }, param) { commit('SET_TOKEN', param) }, setUserId ({ commit }, param) { commit('SET_USERID', param) }, setCode ({ commit }, param) { commit('SET_CODE', param) }, setAuthId ({ commit }, param) { commit('SET_AUTHID', param) }, setAccountId ({ commit }, param) { commit('SET_ACCOUNTID', param) }, setSignInfo ({ commit }, param) { commit('SET_SIGNINFO', param) } }, mutations: { SET_TOKEN: (state, token) => { state.access_token = token console.log(state.access_token) setStore({ name: 'access_token', content: state.access_token, type: 'session' }) }, SET_USERID: (state, userid) => { state.user_id = userid setStore({ name: 'user_id', content: state.user_id, type: 'session' }) }, SET_CODE: (state, code) => { state.code = code setStore({ name: 'code', content: state.code, type: 'session' }) }, SET_AUTHID: (state, authId) => { state.authId = authId setStore({ name: 'auth_id', content: state.authId, type: 'session' }) }, SET_ACCOUNTID: (state, accountId) => { state.accountId = accountId setStore({ name: 'account_id', content: state.accountId, type: 'session' }) }, SET_USERIFNO: (state, userInfo) => { state.userInfo = userInfo }, SET_SIGNINFO: (state, info) => { state.signInfo = info setStore({ name: 'signInfo', content: state.signInfo, type: 'session' }) } } } export default user