import { getArticleList,addArticle,delArticle,getArticleInfo,updateArticle,upArticleStatus} from '@/api/news'

const state = {

}

const mutations = {

}

const actions = {
  //1.资讯中心 start ---------------------------------------->
  //获取资讯列表
  getArticleList({commit},data) {
    return new Promise((resolve, reject) => {
      getArticleList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //添加资讯
  addArticle({commit},data) {
    return new Promise((resolve, reject) => {
      addArticle(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //删除资讯
  delArticle({commit},data) {
    return new Promise((resolve, reject) => {
      delArticle(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取资讯详情
  getArticleInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getArticleInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改资讯内容
  updateArticle({commit},data) {
    return new Promise((resolve, reject) => {
      updateArticle(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改资讯显示或隐藏
  upArticleStatus({commit},data) {
    return new Promise((resolve, reject) => {
      upArticleStatus(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //资讯中心 end ---------------------------------------->
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
