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

export default {
  namespaced: true,
  state: {
    channelList: [],
  },
  mutations: {
    updateList (state, payload) {
      state.channelList = payload || []
    },
  },
  actions: {
    GetChannelListList ({ commit }, payload) {
      return new Promise((resolve, reject) => {
        ajax(api.channelManager.getChannelList.url, {
          method: api.channelManager.getChannelList.method,
          queryData: {
            ...payload,
          }
        }).then(res => {
          commit('updateList', res.list)
          resolve(res)
        }).catch(reject)
      })
    },
  }
}
