import axios from 'axios'
import envConfig from '@/config/env-config'
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',
    corpId: 'ww4df265003b43fa0d',
    agentId: '1000033',
    // url: 'http://139.155.48.151:8085' + inUrl,
    url: envConfig.appBaseUrlA + 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)
      })
    })
  }

}
