apiConfig.js 547 B

1234567891011121314151617181920212223
  1. let v = wx.getAccountInfoSync()
  2. let apiUrl = `${v.miniProgram.envVersion == 'release'?'https://interface.huihenduo.com.cn/hhd-pat-cargo-app-dev/':'https://interface.huihenduo.com.cn/hhd-pat-cargo-app-dev/'}`
  3. function api(url, data, method) {
  4. return new Promise((resolve, reject) => {
  5. wx.request({
  6. url: `${apiUrl}/${url}`,
  7. method,
  8. data,
  9. dataType: 'json',
  10. header: {
  11. 'content-type': 'application/json'
  12. },
  13. success: resolve,
  14. fail: reject
  15. })
  16. })
  17. }
  18. module.exports = {
  19. apiUrl,
  20. api
  21. }