App.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. let BASE_URL = "";
  5. var env ='';
  6. let res = uni.getStorageSync('env') || '1'
  7. switch(res){
  8. case '1': //dev
  9. BASE_URL = 'http://192.168.4.212:8866' // 开发环境
  10. env = 'dev'
  11. break;
  12. case '2': //test
  13. BASE_URL = 'https://opentest1.elab.ink'
  14. env = 'test'
  15. break;
  16. case '3'://test2
  17. BASE_URL = 'https://opentest2.elab.ink'
  18. env = 'test2'
  19. break;
  20. case '4'://test3
  21. BASE_URL = 'https://gatewaytest3.skyforestcity.com'
  22. env = 'test3'
  23. break;
  24. case '5'://test4
  25. BASE_URL = 'https://gatewaytest4.skyforestcity.com'
  26. env = 'test4'
  27. break;
  28. case '6'://uat3
  29. BASE_URL = "https://api-uat3.elaber.cn"
  30. env = 'uat3'
  31. break;
  32. case '7': //uat
  33. BASE_URL = "https://api-uat.elaber.cn"
  34. env = 'uat'
  35. break;
  36. case '8': // 线上 product
  37. default:
  38. BASE_URL = "https://dm-api.elab-plus.cn"
  39. env = 'production'
  40. break;
  41. }
  42. this.globalData.BASE_URL = BASE_URL;
  43. this.globalData.env = env;
  44. let plat = uni.getSystemInfoSync().platform;
  45. this.globalData.platform = plat
  46. let userInfo = uni.getStorageSync('userInfo');//获得保存在本地的用户信息
  47. },
  48. onShow: function() {
  49. let token = this.$cache.get('_token_owner_union');
  50. let userId = this.$cache.get('_user_id')
  51. if (!token) {
  52. this.regist();
  53. } else {
  54. this.globalData.token = token;
  55. this.globalData.userId = userId;
  56. }
  57. document.body.style.setProperty("background-color",this.globalData.color4)
  58. },
  59. onHide: function() {
  60. },
  61. methods: {
  62. getThemeInfo() {
  63. },
  64. async regist() {
  65. let ret = await this.$myRequest({
  66. url: "/regist",
  67. data: {
  68. "code": "o08gpwOfRgwnhh1WCBYGLbaszur8",
  69. "shareToken": ""
  70. }
  71. });
  72. if (ret.data.success) {
  73. let userId = ret.data.single.userId;
  74. this.$cache.set("_user_id",userId,0);
  75. this.globalData.userId = userId;
  76. if (ret.data.single.authed == 1) {
  77. let token = ret.data.single.token;
  78. this.$cache.set('_token_owner_union', token);
  79. this.globalData.token = token
  80. }
  81. uni.$emit('request')
  82. }else{
  83. uni.$emit('request')
  84. }
  85. },
  86. },
  87. globalData: {
  88. token: "",
  89. userId:"",
  90. color1: "#F07423",
  91. color2: "#FD8F3C",
  92. color3: "#FFC444",
  93. color4: "#F5F5F7",
  94. color5: "#F7A98E",
  95. color6: "#FFF4EB",
  96. color7:"#F8BA91",
  97. color8:"#FFF4EB",
  98. color9:"#8B654D",
  99. color10:"#FCF6F1",
  100. BASE_URL:"https://dm-api.elab-plus.cn",//默认环境
  101. }
  102. }
  103. </script>
  104. <style>
  105. </style>