import axios from 'axios'

export function wxRequest(inUrl, data = {}, header = {}, method = 'post') {
  // let URL = `http://172.16.0.111:8081${url}`
  // let URL = `http://139.155.48.151:8081${url}`

  // Z-BasicInfo
  let INFO = {
    corpId: 'wwd1cdbca7b8b2b6c4',
    agentId: '1000015',
    url: 'http://139.155.48.151:8085' + inUrl,
  }

  if (method == 'post') {
    return new Promise(function (resolve, reject) {
      axios({
        url: INFO.url,
        method: method,
        headers: header,
        data: data
      }).then(res => {
        resolve(res.data)
      }).catch(res => {
        reject(res)
      })
    })
  }

  if (method == 'get') {
    return new Promise(function (resolve, reject) {
      axios({
        url: INFO.url,
        method: method,
        headers: header,
        params: data
      }).then(res => {
        resolve(res.data)
      }).catch(res => {
        reject(res)
      })
    })
  }

}