import axios from 'axios'
const api = {
  query: '/api/banner/query',
  details: '/api/banner/details/'
}
const state = {
  bannerList: [],
  banneritem: {}
}
const mutations = {
  banner (state, payload) {
    state.bannerList = payload
  },
  details (state, payload) {
    state.banneritem = payload.data
  }
}
const actions = {
  async getbanner ({ commit }, payload) {
    const res = await axios.get(api.query)
    if (res.data.errcode === 0) commit('banner', res.data.data)
    return res
  },
  async getdetails ({ commit }, { id } = {}) {
    const res = await axios.get(`${api.details}${id}`)
    if (res.data.errcode === 0) commit('details', res.data)
    return res
  }
}
export default { state, mutations, actions, namespaced: true }
