let v = wx.getAccountInfoSync()
let apiUrl = `${v.miniProgram.envVersion!='develop'?'https://interface.huihenduo.com.cn/hhd-pat/':'https://interface.huihenduo.com.cn/hhd-pat-dev/'}`

function api(url, data, method) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: `${apiUrl}/${url}`,
      method,
      data,
      dataType: 'json',
      header: {
        'content-type': 'application/json'
      },
      success: resolve,
      fail: reject
    })
  })
}

module.exports = {
  apiUrl,
  api
}