import { carouselList, addCarousel, deleteCarouselBatch } from '@/api/carousel'

const carousel = {
  namespaced: true,

  actions: {
    getCarouselList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        carouselList(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    createCarlosel({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        addCarousel(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    deleteCarousel({ commit, state }, data) { // 删除轮播图
      return new Promise((resolve, reject) => {
        deleteCarouselBatch(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default carousel
