|
|
@@ -351,6 +351,9 @@ export default {
|
|
|
// 2. Set redirect_uri cookie if 'from' exists
|
|
|
if (from) {
|
|
|
document.cookie = `redirect_uri=${encodeURIComponent(from)}; path=/; max-age=300`;
|
|
|
+ console.log('设置redirect_uri cookie:', from);
|
|
|
+ } else {
|
|
|
+ console.log('URL中没有from参数');
|
|
|
}
|
|
|
const params = {
|
|
|
phone: this.cardForm.phone,
|
|
|
@@ -358,10 +361,15 @@ export default {
|
|
|
};
|
|
|
this.$apis.loginAPI(params)
|
|
|
.then((res) => {
|
|
|
+ console.log('登录响应:', res.data.data);
|
|
|
if (res.data.code === 0) {
|
|
|
- if(res.data.data.redirectUri !== null){
|
|
|
+ // 清理redirect_uri cookie
|
|
|
+ setCookie({redirect_uri: ""}, -1);
|
|
|
+
|
|
|
+ // 检查是否需要重定向
|
|
|
+ if (res.data.data.redirectUri && res.data.data.redirectUri.trim() !== '') {
|
|
|
+ console.log('准备重定向到:', res.data.data.redirectUri);
|
|
|
// 跳转到外部系统的home页面,并携带token
|
|
|
- console.log(res.data.data);
|
|
|
if(res.data.data.redirectUri === REQUEST_BASE_URL_EAI) {
|
|
|
window.location.href = `${res.data.data.redirectUri}/home?token=${encodeURIComponent(res.data.data.token)}`;
|
|
|
} else {
|
|
|
@@ -390,25 +398,16 @@ export default {
|
|
|
type: "success",
|
|
|
duration: 1000,
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
setTimeout(() => {
|
|
|
- if (!res.data.data.redirectUri) {
|
|
|
- if (this.$route.params.login_to) {
|
|
|
- this.$router.push(String(this.$route.params.login_to));
|
|
|
- } else {
|
|
|
- if(res.data.data.user.role === "ADMIN"){
|
|
|
- this.$router.push("/root");
|
|
|
- }else{
|
|
|
- this.$router.push("/portal");
|
|
|
- }
|
|
|
- }
|
|
|
+ if (this.$route.params.login_to) {
|
|
|
+ this.$router.push(String(this.$route.params.login_to));
|
|
|
} else {
|
|
|
- let p = new Promise(function (resolve, reject) {
|
|
|
- setCookie({redirect_uri: ""}, -1);
|
|
|
- resolve();
|
|
|
- }).then(r => {
|
|
|
- window.location.href = res.data.data.redirectUri + "?id_token=" + res.data.data.token;
|
|
|
- });
|
|
|
+ if(res.data.data.user.role === "ADMIN"){
|
|
|
+ this.$router.push("/root");
|
|
|
+ }else{
|
|
|
+ this.$router.push("/portal");
|
|
|
+ }
|
|
|
}
|
|
|
}, 500);
|
|
|
} else {
|