import Ajax from '../../util/ajax'
import api from '../../util/api'

export default {
  namespaced: true,
  state: {
    result: [],
    user: {},
    mainInfo: {}
  },
  mutations: {
    updateState (state, payload) {
      state.result = payload.Message
      state.user = payload.UserInfo
      state.mainInfo = payload.Info[0]
    }
  },
  actions: {
    getBodyCheck (context) {
      return new Promise((resolve, reject) => {
        Ajax({
          ...api.bodyCheck.bodyCheck
        }).then(res => {
          context.commit('updateState', res)
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    }
  }
}