提交 3973989c 编写于 作者: KK's avatar KK

认证失败自动退出钉钉应用

上级 b34e883f
...@@ -97,10 +97,13 @@ export default class Login extends Vue { ...@@ -97,10 +97,13 @@ export default class Login extends Vue {
let loginStatus :any = await this.thirdPartyService.login(); let loginStatus :any = await this.thirdPartyService.login();
if(!loginStatus.issuccess){ if(!loginStatus.issuccess){
this.$notice.error(loginStatus.message?loginStatus.message:"钉钉认证失败,请联系管理员"); this.$notice.error(loginStatus.message?loginStatus.message:"钉钉认证失败,请联系管理员");
}else{ setTimeout(()=>{
this.thirdPartyService.close();
},1500);
}else if(loginStatus.issuccess){
const url: any = this.$route.query.redirect? this.$route.query.redirect: "*"; const url: any = this.$route.query.redirect? this.$route.query.redirect: "*";
this.$router.replace({ path: url }); this.$router.replace({ path: url });
this.$router.go(-1) this.$router.go(-1);
} }
} }
......
...@@ -82,8 +82,6 @@ export class DingTalkService { ...@@ -82,8 +82,6 @@ export class DingTalkService {
* @memberof DingTalkService * @memberof DingTalkService
*/ */
public async login(): Promise<any> { public async login(): Promise<any> {
const data = await this.getUserInfo();
if (!data || !data.value || Object.is(data.value, '')) {
const access_token :any= await this.get(`/uaa/open/dingtalk/access_token`); const access_token :any= await this.get(`/uaa/open/dingtalk/access_token`);
if(access_token.status == 200 && access_token.data && access_token.data.regionid){ if(access_token.status == 200 && access_token.data && access_token.data.regionid){
const res: any= await dd.runtime.permission.requestAuthCode({ corpId: access_token.data.regionid }); const res: any= await dd.runtime.permission.requestAuthCode({ corpId: access_token.data.regionid });
...@@ -92,7 +90,6 @@ export class DingTalkService { ...@@ -92,7 +90,6 @@ export class DingTalkService {
if(userInfo.status == 200 && userInfo.data.token && userInfo.data.user){ if(userInfo.status == 200 && userInfo.data.token && userInfo.data.user){
localStorage.setItem("token", userInfo.data.token); localStorage.setItem("token", userInfo.data.token);
localStorage.setItem("user", JSON.stringify(userInfo.data.user)); localStorage.setItem("user", JSON.stringify(userInfo.data.user));
dd.util.domainStorage.setItem({ name: this.infoName, value: userInfo.data });
return {issuccess:true,message:""}; return {issuccess:true,message:""};
}else if(userInfo.status == 400){ }else if(userInfo.status == 400){
return {issuccess:false,message:userInfo.data.message}; return {issuccess:false,message:userInfo.data.message};
...@@ -106,7 +103,6 @@ export class DingTalkService { ...@@ -106,7 +103,6 @@ export class DingTalkService {
return {issuccess:false,message:"获取企业id失败"}; return {issuccess:false,message:"获取企业id失败"};
} }
} }
}
/** /**
* 清楚登录用户信息 * 清楚登录用户信息
...@@ -157,4 +153,14 @@ export class DingTalkService { ...@@ -157,4 +153,14 @@ export class DingTalkService {
return DingTalkService.instance; return DingTalkService.instance;
} }
/**
* 关闭钉钉应用
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
public close(){
this.dd.biz.navigation.close({});
}
} }
...@@ -137,4 +137,19 @@ export class ThirdPartyService { ...@@ -137,4 +137,19 @@ export class ThirdPartyService {
return ThirdPartyService.instance; return ThirdPartyService.instance;
} }
/**
* 关闭
*
* @static
* @returns {ThirdPartyService}
* @memberof ThirdPartyService
*/
public close(){
if (this.isDingTalk()) {
this.dd.close();
} else if (this.isWeChat()) {
this.weChat.close();
}
}
} }
\ No newline at end of file
...@@ -190,4 +190,14 @@ export class WeChatService { ...@@ -190,4 +190,14 @@ export class WeChatService {
return WeChatService.instance; return WeChatService.instance;
} }
/**
* 关闭微信应用
*
* @static
* @returns {WeChatService}
* @memberof WeChatService
*/
public close(){
// 关闭
}
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册