|
@@ -217,6 +217,23 @@
|
|
|
this.$toast.fail(res.msg);
|
|
|
}
|
|
|
}).catch(err=> {this.$toast.clear();});
|
|
|
+ },
|
|
|
+ // 飞书登录
|
|
|
+ flyingBook(appid, code) {
|
|
|
+ this.$axios.post('/feishu-info/loginByFeishu', {appId: appid,code: code})
|
|
|
+ .then(res => {
|
|
|
+ if(res.code == "ok") {
|
|
|
+ let user = res.data;
|
|
|
+ this.$store.commit("updateLogin", true);
|
|
|
+ localStorage.userInfo = JSON.stringify(user);
|
|
|
+
|
|
|
+ this.$router.push("/index").catch(err => { console.log(err, '错误3')});
|
|
|
+ //强制刷新,避免index页面中的mounted不执行
|
|
|
+ // window.location.reload();
|
|
|
+ } else {
|
|
|
+ this.$toast.fail(res.msg);
|
|
|
+ }
|
|
|
+ }).catch(err=> {this.$toast.clear();});
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -274,33 +291,56 @@
|
|
|
|
|
|
} 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('#'));
|
|
|
+ if(href.indexOf("corpid") > 0) {
|
|
|
+ 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('#'));
|
|
|
+ }
|
|
|
+ alert('钉钉登录==='+corpId);
|
|
|
+ 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 {
|
|
|
+ // 飞书登陆
|
|
|
+ if(href.indexOf("appId") > 0) {
|
|
|
+ console.log('执行到这里---飞书')
|
|
|
+ let arr = href.split('appId=')[1]
|
|
|
+ let str = arr.split('#')[0]
|
|
|
+ console.log(str, window)
|
|
|
+ window.h5sdk.ready(() => { // ready方法不需要每次都调用
|
|
|
+ tt.requestAuthCode({
|
|
|
+ appId: str,
|
|
|
+ success: (info) => {
|
|
|
+ console.info(info.code, '飞书 code')
|
|
|
+ this.flyingBook(str, info.code)
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.error(error)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
- alert('钉钉登录==='+corpId);
|
|
|
- this.isDingding = true
|
|
|
- dd.ready(function() {
|
|
|
- dd.runtime.permission.requestAuthCode({
|
|
|
- corpId: corpId, // 企业id
|
|
|
- onSuccess: function (info) {
|
|
|
- var code = info.code // 通过该免登授权码可以获取用户身份
|
|
|
- that.loginByCode(code, corpId);
|
|
|
- }});
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|