config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * 应用全局配置
  3. *
  4. * 环境自动检测(基于微信小程序官方 API):
  5. * uni.getAccountInfoSync().miniProgram.envVersion
  6. * 'develop' → 开发版(工具内预览)
  7. * 'trial' → 体验版(上传到体验版)
  8. * 'release' → 正式版(线上发布)
  9. *
  10. * 无需手动修改任何变量,发布到对应环境自动生效。
  11. */
  12. let API_BASE_URL = 'http://cfc.iwintrue.com'
  13. try {
  14. const accountInfo = uni.getAccountInfoSync()
  15. const env = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion
  16. if (env) {
  17. switch (env) {
  18. case 'develop':
  19. //API_BASE_URL = 'http://cfc.iwintrue.com'
  20. API_BASE_URL = 'http://192.168.1.57:9082'
  21. //API_BASE_URL = 'https://cfc.etotem.com.cn'
  22. break
  23. case 'trial':
  24. API_BASE_URL = 'https://cfc.etotem.com.cn'
  25. break
  26. case 'release':
  27. API_BASE_URL = 'https://cfc.etotem.com.cn'
  28. break
  29. }
  30. }
  31. } catch (e) {
  32. // 非小程序环境(H5/dev),使用默认地址
  33. }
  34. export default {
  35. API_BASE_URL,
  36. api(path) {
  37. return API_BASE_URL + path
  38. }
  39. }