App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. if (!token) {
  51. this.regist();
  52. } else {
  53. this.globalData.token = token;
  54. }
  55. document.body.style.setProperty("background-color",this.globalData.color4)
  56. },
  57. onHide: function() {
  58. },
  59. methods: {
  60. getThemeInfo() {
  61. },
  62. async regist() {
  63. let ret = await this.$myRequest({
  64. url: "/regist",
  65. data: {
  66. "code": "o08gpwOfRgwnhh1WCBYGLbaszur8",
  67. "shareToken": ""
  68. }
  69. });
  70. if (ret.data.success) {
  71. let userId = ret.data.single.userId;
  72. this.$cache.set("_user_id",userId,0);
  73. this.globalData.userId = userId;
  74. if (ret.data.single.authed == 1) {
  75. let token = ret.data.single.token;
  76. this.$cache.set('_token_owner_union', token);
  77. this.globalData.token = token
  78. }
  79. uni.$emit('request')
  80. }else{
  81. uni.$emit('request')
  82. }
  83. },
  84. },
  85. globalData: {
  86. token: "",
  87. userId:"",
  88. color1: "#F07423",
  89. color2: "#FD8F3C",
  90. color3: "#FFC444",
  91. color4: "#F5F5F7",
  92. color5: "#F7A98E",
  93. color6: "#FFF4EB",
  94. color7:"#F8BA91",
  95. color8:"#FFF4EB",
  96. color9:"#8B654D",
  97. color10:"#FCF6F1",
  98. BASE_URL:"https://dm-api.elab-plus.cn",//默认环境
  99. }
  100. }
  101. </script>
  102. <style>
  103. </style>