import axios from 'axios'
const api = {
  query: '/api/page/details',
  pagequery: '/api/page/query'
}
const state = {
  pageitem: {},
  pageList: null
}
const mutations = {
  details (state, payload) {
    state.pageitem = payload
  },
  page (state, payload) {
    state.pageList = payload.data
  }
}
const actions = {
  async getdetails ({ commit }, payload) {
    const res = await axios.get(`${api.query}/${payload.code}`)
    if (res.data.errcode === 0) commit('details', res.data.data)
    return res
  },
  async pagequery ({ commit }) {
    const res = await axios.get(api.pagequery)
    if (res.errcode === 0) commit('page', res)
    return res
  }
}
export default { state, mutations, actions, namespaced: true }
