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

export default {
  namespaced: true,
  state: {
    news: {}
  },
  mutations: {
    updateList (state, payload) {
      state.news = payload
    }
  },
  actions: {
    getNewsList ({ commit }, payload) {
      return new Promise((resolve, reject) => {
        Ajax(api.news.url, {
          method: api.news.method,
          queryData: { ...payload }
        }).then(res => {
          commit('updateList', res)
          resolve(res)
        }).catch((res) => {
          reject(res)
        })
      })
    }
  }
}
