apiConfig.js 540 B

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