import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
Vue.use(Vuex);
const api = {
  wxchattestInfo: `/api/auth/wxchattest`,
};
const state = () => ({});
const mutations = {
  setUser(state, payload) {
    if (payload) {
      state.user = payload;
      sessionStorage.setItem('user', JSON.stringify(payload));
    } else {
      let user = sessionStorage.getItem('user');
      if (user) state.user = JSON.parse(user);
      else return false;
    }
  },
};

const actions = {
  async login({ commit }, payload) {
    const res = await this.$axios.$get(`${api.wxchattestInfo}`, payload);
    return res;
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
