config.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // 配置信息
  2. var config = {}
  3. const accountInfo = uni.getAccountInfoSync();
  4. const envVersion = accountInfo.miniProgram.envVersion;
  5. console.log(accountInfo, envVersion, 'envVersionenvVersionenvVersion')
  6. uni.getSystemInfo({
  7. success: function(res) {
  8. console.log(res, 'getSystemInfogetSystemInfogetSystemInfogetSystemInfo')
  9. if (res.uniPlatform === 'mp-weixin') {
  10. console.log(accountInfo, envVersion, '当前在微信开中运行当前在微信开中运行当前在微信开中运行当前在微信开中运行')
  11. // 在微信小程序中运行的逻辑
  12. if (envVersion === 'develop') {
  13. // 开发版本
  14. config = {
  15. // https://api.duanju.dududus.com 测试环境
  16. // https://api.zhiyupa.com 正式环境
  17. apiUrl: "https://api.duanju.dududus.com",
  18. staticUrl: 'https://xjc.demo.hongcd.com/img/', //静态图片地址https://xjc.demo.hongcd.com
  19. zystaticUrl: "",
  20. TabbarIndex: 2
  21. }
  22. } else if (envVersion === 'trial') {
  23. //体验版
  24. config = {
  25. apiUrl: "https://api.zhiyupa.com",
  26. staticUrl: 'https://xjc.demo.hongcd.com/img/', //静态图片地址https://xjc.demo.hongcd.com
  27. zystaticUrl: "",
  28. TabbarIndex: 2
  29. }
  30. } else if (envVersion === 'release') {
  31. //正式版
  32. config = {
  33. apiUrl: "https://api.zhiyupa.com",
  34. staticUrl: 'https://xjc.demo.hongcd.com/img/', //静态图片地址https://xjc.demo.hongcd.com
  35. zystaticUrl: "",
  36. TabbarIndex: 2
  37. }
  38. }
  39. } else if (res.uniPlatform === 'web') {
  40. // 在H5环境中运行的逻辑
  41. console.log('当前在H5环境中运行');
  42. }
  43. }
  44. });
  45. export default config