App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script>
  2. const config = require('./static/config.js');
  3. export default {
  4. onLaunch: function() {
  5. let href = location.href;
  6. let code = this.getQueryString('code');
  7. if(!code){
  8. let url = href.split('#')[0];
  9. url = encodeURIComponent(url);
  10. url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+config.appid+"&redirect_uri="+url+"&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect"
  11. window.location.href = url;
  12. }
  13. let BASE_URL = "";
  14. var env ='';
  15. let res = "3"
  16. switch(res){
  17. case '1': //dev
  18. BASE_URL = 'http://192.168.4.212:8866' // 开发环境
  19. env = 'dev'
  20. break;
  21. case '2': //test
  22. BASE_URL = 'https://opentest1.elab.ink'
  23. env = 'test'
  24. break;
  25. case '3'://test2
  26. BASE_URL = 'https://opentest2.elab.ink'
  27. env = 'test2'
  28. break;
  29. case '4'://test3
  30. BASE_URL = 'https://gatewaytest3.skyforestcity.com'
  31. env = 'test3'
  32. break;
  33. case '5'://test4
  34. BASE_URL = 'https://gatewaytest4.skyforestcity.com'
  35. env = 'test4'
  36. break;
  37. case '6'://uat3
  38. BASE_URL = "https://api-uat3.elaber.cn"
  39. env = 'uat3'
  40. break;
  41. case '7': //uat
  42. BASE_URL = "https://api-uat.elaber.cn"
  43. env = 'uat'
  44. break;
  45. case '8': // 线上 product
  46. default:
  47. BASE_URL = "https://dm-api.elab-plus.cn"
  48. env = 'production'
  49. break;
  50. }
  51. this.globalData.BASE_URL = BASE_URL;
  52. this.globalData.env = env;
  53. },
  54. onShow: function() {
  55. let shareToken = this.getQueryString('shareToken');
  56. let projectId = this.getQueryString('projectId');
  57. this.globalData.projectId = projectId||'';
  58. this.globalData.shareToken = shareToken||'';
  59. this.regist();
  60. document.body.style.setProperty("background-color",this.globalData.color4);
  61. },
  62. onHide: function() {
  63. },
  64. methods: {
  65. getThemeInfo() {
  66. },
  67. getQueryString(name){
  68. var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
  69. return reg.test(location.href) ? unescape(RegExp.$2.replace(/\+/g, " ")) : ""
  70. },
  71. async regist() {
  72. let code = this.getQueryString('code');
  73. let ret = await this.$myRequest({
  74. url: "/regist",
  75. data: {
  76. "code": code,
  77. "shareToken":this.globalData.shareToken||"",
  78. "projectId":this.globalData.projectId||"",
  79. }
  80. });
  81. if (ret.data.success) {
  82. let userId = ret.data.single.userId;
  83. this.globalData.userId = userId;
  84. if (ret.data.single.authed == 1) {
  85. let token = ret.data.single.token;
  86. this.globalData.token = token
  87. }
  88. uni.$emit('request')
  89. }
  90. },
  91. },
  92. globalData: {
  93. token: "",
  94. userId:"",
  95. projectId:"",
  96. shareToken:"",
  97. color1: "#F07423",
  98. color2: "#FD8F3C",
  99. color3: "#FFC444",
  100. color4: "#F5F5F7",
  101. color5: "#F7A98E",
  102. color6: "#FFF4EB",
  103. color7:"#F8BA91",
  104. color8:"#FFF4EB",
  105. color9:"#8B654D",
  106. color10:"#FCF6F1",
  107. BASE_URL:"https://dm-api.elab-plus.cn",//默认环境
  108. }
  109. }
  110. </script>
  111. <style>
  112. </style>