123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <script>
- const config = require('./static/config.js');
- export default {
- onLaunch: function() {
- let href = location.href;
- let code = this.getQueryString('code');
- if(!code){
- href = encodeURIComponent(href.split('#')[0].substring(0,href.split('#')[0].length-1));
- let url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+config.appid+"&redirect_uri="+href+"&response_type=code&scope=snsapi_base&state=123&connect_redirect=1#wechat_redirect"
- window.location.href = url;
- }
- let BASE_URL = "";
- var env ='';
- let res = "3"
- switch(res){
- case '1': //dev
- BASE_URL = 'http://192.168.4.212:8866' // 开发环境
- env = 'dev'
- break;
- case '2': //test
- BASE_URL = 'https://opentest1.elab.ink'
- env = 'test'
- break;
- case '3'://test2
- BASE_URL = 'https://opentest2.elab.ink'
- env = 'test2'
- break;
- case '4'://test3
- BASE_URL = 'https://gatewaytest3.skyforestcity.com'
- env = 'test3'
- break;
- case '5'://test4
- BASE_URL = 'https://gatewaytest4.skyforestcity.com'
- env = 'test4'
- break;
- case '6'://uat3
- BASE_URL = "https://api-uat3.elaber.cn"
- env = 'uat3'
- break;
- case '7': //uat
- BASE_URL = "https://api-uat.elaber.cn"
- env = 'uat'
- break;
- case '8': // 线上 product
- default:
- BASE_URL = "https://dm-api.elab-plus.cn"
- env = 'production'
- break;
- }
- this.globalData.BASE_URL = BASE_URL;
- this.globalData.env = env;
- },
- onShow: function() {
- let token = this.$cache.get('_token_owner_union');
- let userId = this.$cache.get('_user_id');
- if (!token||!userId) {
- this.globalData.userId = userId;
- this.regist();
- } else {
- this.globalData.token = token;
- this.globalData.userId = userId;
- }
- document.body.style.setProperty("background-color",this.globalData.color4)
- },
- onHide: function() {
- },
- methods: {
- getThemeInfo() {
-
- },
- getQueryString(name){
- var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
- return reg.test(location.href) ? unescape(RegExp.$2.replace(/\+/g, " ")) : ""
- },
- async regist() {
- let code = this.getQueryString('code');
- let ret = await this.$myRequest({
- url: "/regist",
- data: {
- "code": code,
- "shareToken": ""
- }
- });
- if (ret.data.success) {
- let userId = ret.data.single.userId;
- this.$cache.set("_user_id",userId,0);
- this.globalData.userId = userId;
- if (ret.data.single.authed == 1) {
- let token = ret.data.single.token;
- this.$cache.set('_token_owner_union', token);
- this.globalData.token = token
- }
- }
- },
- },
- globalData: {
- token: "",
- userId:"",
- color1: "#F07423",
- color2: "#FD8F3C",
- color3: "#FFC444",
- color4: "#F5F5F7",
- color5: "#F7A98E",
- color6: "#FFF4EB",
- color7:"#F8BA91",
- color8:"#FFF4EB",
- color9:"#8B654D",
- color10:"#FCF6F1",
- BASE_URL:"https://dm-api.elab-plus.cn",//默认环境
- }
- }
- </script>
- <style>
-
- </style>
|