apiConfig.js 736 B

1234567891011121314151617181920212223242526272829303132333435
  1. let v = wx.getAccountInfoSync()
  2. let appVersion = wx.getStorageSync('appVersion')
  3. let {
  4. envVersion
  5. } = v.miniProgram
  6. if (appVersion != envVersion) {
  7. wx.clearStorage({
  8. success: (res) => {
  9. wx.setStorageSync('appVersion', envVersion)
  10. },
  11. })
  12. }
  13. let apiUrl = `${envVersion == 'release'?'https://interface.huihenduo.com.cn/hhd-pat/':'https://interface.huihenduo.com.cn/hhd-pat-dev/'}`
  14. function api(url, data, method) {
  15. return new Promise((resolve, reject) => {
  16. wx.request({
  17. url: `${apiUrl}/${url}`,
  18. method,
  19. data,
  20. dataType: 'json',
  21. header: {
  22. 'content-type': 'application/json'
  23. },
  24. success: resolve,
  25. fail: reject
  26. })
  27. })
  28. }
  29. module.exports = {
  30. apiUrl,
  31. api
  32. }