const axios = require('axios')

// axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
// axios.defaults.withCredentials = true

const ax = axios.create({
  withCredentials: false
})

// login
export function queryInformation(param) {
  return axios({
    method: 'GET',
    // url: host.main + path.queryInformation,
    url: '/api/zws/v1/enrollment/submissions',
    params: {
      project_id: 1000,
      name: 'hhahah'
    }
  })
    .then(function(response) {
      console.log(response)
    })
    .catch(function(error) {
      console.log(error)
    })
}

export function introduction(params) {
  // 获取所有介绍内容
  return ax({
    method: 'GET',
    url: '/api/zws/v1/cms/projects/1000/contents/' + params.tag
  })
    .then(function(response) {
      params.cb(response.data[0].content)
    })
    .catch(function(error) {
      console.log(error)
    })
}

export function getNews(params) {
  // 获取所有新闻消息
  return ax({
    method: 'GET',
    // url: host.main + path.news,
    url: '/api/zws/v1/cms/news',
    params: {
      project_id: 1000
    }
  })
    .then(function(response) {
      params.cb(response.data)
    })
    .catch(function(error) {
      console.log(error)
    })
}
