|
@@ -198,50 +198,60 @@
|
|
} else if (ua.indexOf("micromessenger") > 0) {
|
|
} else if (ua.indexOf("micromessenger") > 0) {
|
|
this.isWX = true;
|
|
this.isWX = true;
|
|
}
|
|
}
|
|
- if (localStorage.userInfo != null) {
|
|
|
|
- this.$router.push("/index").catch(err => { console.log(err, '错误5')});
|
|
|
|
|
|
+ let href = window.location.href;
|
|
|
|
+ //优先处理企业微信工作台点击进入,后台已经处理过,有userId传过来了
|
|
|
|
+ if (this.isCorpWX && href.indexOf("userId") > 0) {
|
|
|
|
+ //判断企业微信,是否存在授权
|
|
|
|
+ var loginUserId = href.substring(href.indexOf("userId=")+"userId=".length);
|
|
|
|
+ if (loginUserId.includes('#/')) {
|
|
|
|
+ loginUserId = loginUserId.substring(0, loginUserId.indexOf('#/'));
|
|
|
|
+ }
|
|
|
|
+ this.loginByUserId(loginUserId);
|
|
} else {
|
|
} else {
|
|
- if (this.isCorpWX || this.isWX) {
|
|
|
|
- let href = window.location.href;
|
|
|
|
- //判断企业微信,是否存在授权
|
|
|
|
- if (href.includes("com/?code")) {
|
|
|
|
- this.bindIfNessary();
|
|
|
|
- } else {
|
|
|
|
- if (href.indexOf('hasTriedAutoLogin') == -1) {
|
|
|
|
- this.tryAutoLogin();
|
|
|
|
- } else if (href.indexOf("userId") > 0) {
|
|
|
|
- //后台经过验证后,重定向过来带上了userId
|
|
|
|
- var loginUserId = href.substring(href.indexOf("userId=")+"userId=".length);
|
|
|
|
- if (loginUserId.includes('#/')) {
|
|
|
|
- loginUserId = loginUserId.substring(0, loginUserId.indexOf('#/'));
|
|
|
|
|
|
+ if (localStorage.userInfo != null && !this.isCorpWX) {
|
|
|
|
+ this.$router.push("/index").catch(err => { console.log(err, '错误5')});
|
|
|
|
+ } else {
|
|
|
|
+ if (this.isCorpWX || this.isWX) {
|
|
|
|
+ //判断企业微信,是否存在授权
|
|
|
|
+ if (href.includes("com/?code")) {
|
|
|
|
+ this.bindIfNessary();
|
|
|
|
+ } else {
|
|
|
|
+ if (href.indexOf('hasTriedAutoLogin') == -1) {
|
|
|
|
+ this.tryAutoLogin();
|
|
|
|
+ } else if (href.indexOf("userId") > 0) {
|
|
|
|
+ //后台经过验证后,重定向过来带上了userId
|
|
|
|
+ var loginUserId = href.substring(href.indexOf("userId=")+"userId=".length);
|
|
|
|
+ if (loginUserId.includes('#/')) {
|
|
|
|
+ loginUserId = loginUserId.substring(0, loginUserId.indexOf('#/'));
|
|
|
|
+ }
|
|
|
|
+ this.loginByUserId(loginUserId);
|
|
}
|
|
}
|
|
- this.loginByUserId(loginUserId);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //检查环境,如果是钉钉有$CORPID$
|
|
|
|
+ var key = '?corpid=';
|
|
|
|
+ var jumpkey = '&jumpto=';
|
|
|
|
+ var url = location.href;
|
|
|
|
+ var that = this;
|
|
|
|
+ if (url.indexOf(key) > 0) {
|
|
|
|
+ var corpId = ''
|
|
|
|
+ if(url.indexOf(jumpkey) > 0){
|
|
|
|
+ corpId = url.substring(url.indexOf(key)+key.length,url.indexOf(jumpkey));
|
|
|
|
+ }else{
|
|
|
|
+ corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
|
|
|
|
+ }
|
|
|
|
+ this.isDingding = true
|
|
|
|
+ dd.ready(function() {
|
|
|
|
+ dd.runtime.permission.requestAuthCode({
|
|
|
|
+ corpId: corpId, // 企业id
|
|
|
|
+ onSuccess: function (info) {
|
|
|
|
+ var code = info.code // 通过该免登授权码可以获取用户身份
|
|
|
|
+ that.loginByCode(code, corpId);
|
|
|
|
+ }});
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- } else {
|
|
|
|
- //检查环境,如果是钉钉有$CORPID$
|
|
|
|
- var key = '?corpid=';
|
|
|
|
- var jumpkey = '&jumpto=';
|
|
|
|
- var url = location.href;
|
|
|
|
- var that = this;
|
|
|
|
- if (url.indexOf(key) > 0) {
|
|
|
|
- var corpId = ''
|
|
|
|
- if(url.indexOf(jumpkey) > 0){
|
|
|
|
- corpId = url.substring(url.indexOf(key)+key.length,url.indexOf(jumpkey));
|
|
|
|
- }else{
|
|
|
|
- corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
|
|
|
|
- }
|
|
|
|
- this.isDingding = true
|
|
|
|
- dd.ready(function() {
|
|
|
|
- dd.runtime.permission.requestAuthCode({
|
|
|
|
- corpId: corpId, // 企业id
|
|
|
|
- onSuccess: function (info) {
|
|
|
|
- var code = info.code // 通过该免登授权码可以获取用户身份
|
|
|
|
- that.loginByCode(code, corpId);
|
|
|
|
- }});
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|