
export default {
  namespaced: true,
  state: {
    location: []
  },
  mutations: {
    init (state, data) { // 这里的state对应着上面这个state
      state.location = data
    }
  },
  actions: {
    updateLocationInfo (context, payload) { // 这里的context和我们使用的$store拥有相同的对象和方法
      return new Promise((resolve) => {
        this.$ajax(this.$api.cms.location.url, {
          method: this.$api.cms.location.method,
          data: {
            issys: payload && payload.issys ? payload.issys : 0
          }
        }).then(res => {
          context.commit('init', res)
          resolve()
        })
      })
    }
  }
}
