App.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <script>
  2. var ekanfang = uni.requireNativePlugin("Ekanfang")
  3. export default {
  4. onLaunch: function() {
  5. let BASE_URL = "";
  6. var env ='';
  7. let res = uni.getStorageSync('env')
  8. switch(res){
  9. case '1': //dev
  10. BASE_URL = 'http://101.231.166.56:16666' // 开发环境
  11. env = 'dev'
  12. break;
  13. case '2': //test
  14. BASE_URL = 'https://gatewaytest.elab-plus.vip'
  15. env = 'test'
  16. break;
  17. case '3'://test2
  18. BASE_URL = 'http://gatewaytest1.elab-plus.com'
  19. env = 'test2'
  20. break;
  21. case '4'://test3
  22. BASE_URL = 'https://gatewaytest3.skyforestcity.com'
  23. env = 'test3'
  24. break;
  25. case '5'://test4
  26. BASE_URL = 'https://gatewaytest4.skyforestcity.com'
  27. env = 'test4'
  28. break;
  29. case '6'://uat3
  30. BASE_URL = "https://api-uat3.elaber.cn"
  31. env = 'uat3'
  32. break;
  33. case '7': //uat
  34. BASE_URL = "https://api-uat.elaber.cn"
  35. env = 'uat'
  36. break;
  37. case '8': // 线上 product
  38. default:
  39. BASE_URL = "https://dm-api.elab-plus.cn"
  40. env = 'production'
  41. break;
  42. }
  43. this.globalData.BASE_URL = BASE_URL;
  44. this.globalData.env = env;
  45. let plat = uni.getSystemInfoSync().platform;
  46. this.globalData.platform = plat
  47. // // console.log('App Launch')
  48. // #ifdef APP-VUE
  49. var self = this
  50. let userInfo = uni.getStorageSync('userInfo');//获得保存在本地的用户信息
  51. if(userInfo){//有数据,已登录
  52. let roleMenulList = userInfo.roleMenuList
  53. this.reloadMeunStatus(roleMenulList);
  54. }else{
  55. //不存在则跳转登录页
  56. uni.reLaunch({
  57. url: "/pages/loginPage/index",
  58. success: () => {
  59. //跳转完页面后再关闭启动页
  60. plus.navigator.closeSplashscreen();
  61. }
  62. })
  63. }
  64. // #endif
  65. },
  66. onShow: function() {
  67. // console.log("App onshow")
  68. document.body.style.setProperty("background-color",this.globalData.backgorundThemeColor)
  69. },
  70. onHide: function() {
  71. // console.log('App Hide')
  72. },
  73. methods: {
  74. reloadMeunStatus(roleMenulList) {
  75. var self = this
  76. if(roleMenulList.length>0){
  77. let menuCode = roleMenulList[0].menuCode
  78. if (menuCode == 100){
  79. plus.navigator.closeSplashscreen();
  80. }else if (menuCode == 200) {
  81. plus.navigator.closeSplashscreen();
  82. uni.reLaunch({
  83. url:'./pages/loginsuccess/loginSuccess',
  84. })
  85. } else if (menuCode == 300) {
  86. plus.navigator.closeSplashscreen();
  87. uni.reLaunch({
  88. url:'./pages/mine/mine',
  89. })
  90. }
  91. }
  92. },
  93. getThemeInfo() {
  94. // console.log("调用了")
  95. let self = this;
  96. uni.getStorage({ //获得保存在本地的用户信息
  97. key: 'userInfo',
  98. success: (res) => {
  99. if (res.data) {
  100. //存在则关闭启动页进入首页
  101. if (res.data.hasOwnProperty('theme') && null != res.data.theme) {
  102. let theme = JSON.parse(res.data.theme);
  103. self.globalData.themeColor = theme.themeColor;
  104. self.globalData.fuzhuColor = theme.fuzhuColor;
  105. self.globalData.fuzhuColor15 = theme.fuzhuColor15;
  106. self.globalData.themeColor50 = theme.themeColor50;
  107. self.globalData.themeColor25 = theme.themeColor25;
  108. self.globalData.fuzhuColor50 = theme.fuzhuColor50;
  109. self.globalData.backgorundThemeColor = theme.backgorundThemeColor
  110. }
  111. self.globalData.token = res.data.token;
  112. }
  113. },
  114. });
  115. }
  116. },
  117. globalData: {
  118. token: "",
  119. themeColor: "#3CD9D9",
  120. fuzhuColor: "#FEC350",
  121. fuzhuColor15: "#FFF6E5",
  122. themeColor50: "#9DECEC",
  123. themeColor25: "#CEF6F6",
  124. fuzhuColor50: "#FEE1A7",
  125. backgorundThemeColor:"#F1F5F9",
  126. unReadNumTotal:0,
  127. BASE_URL:"https://dm-api.elab-plus.cn",//默认环境
  128. }
  129. }
  130. </script>
  131. <style>
  132. /*每个页面公共css */
  133. /* #ifndef APP-NVUE */
  134. @import url("./static/font/iconfont.css");
  135. page {
  136. background-color: #F4F7F7;
  137. }
  138. /* #endif */
  139. </style>