dt_jump.vue
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
<div>阿里钉钉-授权认证中</div>
</template>
<script>
import req from '@/utils/request'
import utils from '@/utils/jump'
import * as dd from "dingtalk-jsapi";
import {getTenantInfo} from '@/api/uc.js'
import store from '@/store'
export default {
components: {},
props: ['tenant'],
data() {
return {
layout: {},
gridList: []
};
},
created() {
const loading = this.$loading({
lock: true,
text: "授权中",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
});
let Base64 = require("js-base64").Base64;
var params = utils.getParameters("params")
params = decodeURIComponent(params);
if(params){
try {
params = Base64.decode(params);
} catch (error) {
loading.close();
this.$message.error("传入的参数params解码错误了:"+error)
return;
}
}
const me_ = this;
var corpid = utils.getParameters("corpid");
var redirect_uri = decodeURIComponent(utils.getParameters("redirect_uri"));
dd.ready(function() {
dd.runtime.permission.requestAuthCode({
corpId: corpid,
onSuccess: function(info) {
//获取租户信息
let tenantCode = me_.tenant ? me_.tenant : 'platform'
const this_ = me_
getTenantInfo(tenantCode).then((res) => {
if (res && res.state) {
let tenantId = res.value.id
this_.proxyLogin(info.code, redirect_uri, loading,params, tenantId);
}
})
},
onFail: function(err) {
alert(JSON.stringify(err));
}
})
})
},
methods: {
proxyLogin(code, redirect_uri, loading,params, tenantId) {
let url = window.context.auth + "/sso/dingTalk?code=" + code + "&tenantId=" + tenantId;
req.get(url).then((response) =>{
loading.close();
if (response) {
store
.dispatch('user/authentication', response)
.then(() => {
this.toRedirectUri(redirect_uri)
})
.catch(() => {
this.$router.push({path:'/home'})
})
} else {
this.toRedirectUri(redirect_uri)
}
});
},
toRedirectUri(redirect_uri){
if(redirect_uri){
location.href = redirect_uri;
}else{
if(!params){
this.$router.push({path:'/home'})
}else{
this.parseParams(params);
}
}
},
parseParams(params){
let paramsJson = JSON.parse(params||"{}");
//审批的消息
if(paramsJson.templateType ==='bpmnapproval'|| paramsJson.templateType ==='bpmnback' || paramsJson.templateType ==='promoter'
|| paramsJson.templateType ==='bpmntasktrans' || paramsJson.templateType ==='bpmnagent' || paramsJson.templateType ==='bpmtasksetexecutors'
|| paramsJson.templateType ==='bpmhandto'){
let url = `/task/${paramsJson.taskId}/0`;
this.$router.push({path:url});
} else if(paramsJson.templateType ==='copyto'){
let url = `/noticeTask/${paramsJson.readId}/COPYTO/0/0/transmittedMatters`;
this.$router.push({path:url});
} else if(paramsJson.templateType ==='bpmendprocess' || paramsJson.templateType ==='bpmrenewprocess'){
let url = `/inst/${paramsJson.instId}/request`;
this.$router.push({path:url});
} else{
this.$router.push({path:'/home'})
}
}
}
};
</script>