common.js 843 Bytes
Newer Older
张罗鹏's avatar
张罗鹏 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
import { getStore, setStore } from '@/util/store';
/*eslint-disable*/
const common = {
  state: {
    access_token:
      getStore({
        name: 'access_token'
      }) || '',
    refresh_token:
      getStore({
        name: 'refresh_token'
      }) || '',
    userInfo: getStore({
      name: 'userInfo'
    }) || {}
  },
  actions: {
    LoginByQrcode ({ commit }, userInfo) {

    }
  },
  mutations: {
    SET_ACCESS_TOKEN: (state, access_token) => {
      state.access_token = access_token;
      setStore({
        name: 'access_token',
        content: state.access_token,
        type: 'session'
      });
    },
    SET_USERINFO: (state, userInfo) => {
      state.userInfo = userInfo;
      setStore({
        name: 'userInfo',
        content: state.userInfo,
        type: 'session'
      });
    },
  }
}
export default common