|
@@ -2,6 +2,7 @@ import modules from './modules'
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
import Router from '@/plugin/uni-simple-router/index.js'
|
|
import Router from '@/plugin/uni-simple-router/index.js'
|
|
import { ACCESS_TOKEN } from '@/common/util/constants.js'
|
|
import { ACCESS_TOKEN } from '@/common/util/constants.js'
|
|
|
|
+import configService from '@/common/service/config.service.js'
|
|
import api from "@/api/api";
|
|
import api from "@/api/api";
|
|
import { SKIP_SSO_URL_QUERY, locationUrl, openSso, getUrlParam } from './sso.js'
|
|
import { SKIP_SSO_URL_QUERY, locationUrl, openSso, getUrlParam } from './sso.js'
|
|
|
|
|
|
@@ -16,26 +17,29 @@ const whiteList = ['/pages/login/login']
|
|
//全局路由前置守卫
|
|
//全局路由前置守卫
|
|
router.beforeEach((to, from, next) => {
|
|
router.beforeEach((to, from, next) => {
|
|
let token = uni.getStorageSync(ACCESS_TOKEN);
|
|
let token = uni.getStorageSync(ACCESS_TOKEN);
|
|
|
|
+
|
|
|
|
+ console.log("-----to---------------------"+JSON.stringify(token))
|
|
if (token) {
|
|
if (token) {
|
|
next()
|
|
next()
|
|
} else {
|
|
} else {
|
|
// query如果没有明确要求跳过sso则执行sso登录
|
|
// query如果没有明确要求跳过sso则执行sso登录
|
|
- if (to.query[SKIP_SSO_URL_QUERY.key] !== SKIP_SSO_URL_QUERY.val) {
|
|
|
|
|
|
+ // const token = uni.getStorageSync(ACCESS_TOKEN);
|
|
|
|
+ const ticket = getUrlParam('ticket');
|
|
|
|
+ console.log("-----ticket---------------------"+ticket)
|
|
|
|
+ if (ticket != null && ticket != '') {
|
|
/**
|
|
/**
|
|
* 单点登录,返回是否需要跳转到单点登录页
|
|
* 单点登录,返回是否需要跳转到单点登录页
|
|
*/
|
|
*/
|
|
let redirect = false;
|
|
let redirect = false;
|
|
- if (openSso == 'true') {
|
|
|
|
- const token = uni.getStorageSync(ACCESS_TOKEN);
|
|
|
|
- const ticket = getUrlParam('ticket');
|
|
|
|
|
|
+ // if (openSso == 'true') {
|
|
if (!token) {
|
|
if (!token) {
|
|
if (ticket) {
|
|
if (ticket) {
|
|
try {
|
|
try {
|
|
new Promise((resolve, reject) => {
|
|
new Promise((resolve, reject) => {
|
|
api
|
|
api
|
|
.validateCasLogin({
|
|
.validateCasLogin({
|
|
- ticket: ticket,
|
|
|
|
- service: locationUrl,
|
|
|
|
|
|
+ ticket: ""+ticket,
|
|
|
|
+ service: "http://localhost:8080/",
|
|
})
|
|
})
|
|
.then((response) => {
|
|
.then((response) => {
|
|
if (response.data.code == 200) {
|
|
if (response.data.code == 200) {
|
|
@@ -53,15 +57,12 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
redirect = true;
|
|
redirect = true;
|
|
- uni.navigateTo({
|
|
|
|
- url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl)
|
|
|
|
- });
|
|
|
|
// if (process.env.VUE_APP_PLATFORM != 'h5') {
|
|
// if (process.env.VUE_APP_PLATFORM != 'h5') {
|
|
// uni.navigateTo({
|
|
// uni.navigateTo({
|
|
- // url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl)
|
|
|
|
|
|
+ // url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl())
|
|
// });
|
|
// });
|
|
// } else {
|
|
// } else {
|
|
- // window.location.href = 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl);
|
|
|
|
|
|
+ // window.location.href = 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl());
|
|
// }
|
|
// }
|
|
|
|
|
|
}
|
|
}
|
|
@@ -70,19 +71,19 @@ router.beforeEach((to, from, next) => {
|
|
} else {
|
|
} else {
|
|
redirect = true;
|
|
redirect = true;
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
- url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl)
|
|
|
|
|
|
+ url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl())
|
|
});
|
|
});
|
|
// if (process.env.VUE_APP_PLATFORM != 'h5') {
|
|
// if (process.env.VUE_APP_PLATFORM != 'h5') {
|
|
// uni.navigateTo({
|
|
// uni.navigateTo({
|
|
- // url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl)
|
|
|
|
|
|
+ // url: 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl())
|
|
// });
|
|
// });
|
|
// } else {
|
|
// } else {
|
|
- // window.location.href = 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl);
|
|
|
|
|
|
+ // window.location.href = 'https://id.shendong.com.cn/default' + '/login?service=' + encodeURIComponent(locationUrl());
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ // }
|
|
let redirectSso = redirect;
|
|
let redirectSso = redirect;
|
|
|
|
|
|
// 如果需要重定向到sso页面则取消路由导航
|
|
// 如果需要重定向到sso页面则取消路由导航
|