const getDefaultState = () => {
  return {
    provinceid: '',
    cityid: '',
    countyid: ''
  }
}

const state = getDefaultState()

const mutations = {
  RESET_STATE: (state) => {
    Object.assign(state, getDefaultState())
  },
  SET_PROVINCEID: (state, provinceid) => {
    alert(provinceid)
    state.provinceid = provinceid
  },
  SET_CITYID: (state, cityid) => {
    state.cityid = cityid
  },
  SET_COUNTYID: (state, countyid) => {
    state.countyid = countyid
  }
}

const actions = {
  // 获取省市县code
  getCode({ commit }, params) {
    commit('SET_PROVINCEID', params.provinceID)
    commit('SET_CITYID', params.cityID)
    commit('SET_COUNTYID', params.countyID)
  }
}

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

