import {
  statAuditNum
} from "@/api/login.js";
import store from '../../store'
const getDefaultState = () => {
  return {
    scoketNum: "",
    userId: sessionStorage.getItem("userid")
  }
}
const state = getDefaultState()
const mutations = {
  GET_NUMJK(state, data) {
    state.scoketNum = data.num
  },
  GET_NUM(state, data) {
    let NewData = JSON.parse(data)
    if (NewData.userId === state.userId) {
      state.scoketNum = NewData.num
    } 
  }
}
const actions = {
  async statAuditNum({
    commit,
    dispatch
  }, data) {
    await statAuditNum(data).then(res => {
      try {
        commit('GET_NUMJK', res.body)
      } catch (err) {
        throw new Error(err)
      }
    })
  },

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