aWxRequest.js 1.06 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
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 = {
9 10 11
    // corpId: 'wwd1cdbca7b8b2b6c4',
    // agentId: '1000015',
    corpId: 'ww4df265003b43fa0d',
xd's avatar
xd committed
12
    agentId: '100003',
xulili's avatar
xulili committed
13 14
    // url: 'http://139.155.48.151:8085' + inUrl,
    url: envConfig.appBaseUrlA + inUrl,
Z's avatar
Z committed
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 45 46
  }

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