aWxRequest.js 1 KB
Newer Older
Z's avatar
Z committed
1
import axios from 'axios'
xulili's avatar
xulili committed
2
import envConfig from '@/config/env-config'
Z's avatar
Z committed
3 4 5 6 7 8 9 10
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',
xulili's avatar
xulili committed
11 12
    // url: 'http://139.155.48.151:8085' + inUrl,
    url: envConfig.appBaseUrlA + inUrl,
Z's avatar
Z committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
  }

  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)
      })
    })
  }

xulili's avatar
xulili committed
45
}