对接政务端

des
吕天方 7 months ago
parent 89f3453e30
commit 5333e65219

@ -5,8 +5,8 @@ VUE_APP_TITLE = 金鸡湖现代服务业品牌管理系统
ENV = 'development'
# 金鸡湖现代服务业品牌管理系统/开发环境
# VUE_APP_BASE_API = 'http://192.168.0.104:9040'
VUE_APP_BASE_API = 'http://39.101.188.84:9040'
VUE_APP_BASE_API = 'http://192.168.0.105:9040'
# VUE_APP_BASE_API = 'http://39.101.188.84:9040'
# VUE_APP_BASE_API = 'https://idp.sipac.gov.cn/api'
# 路由懒加载

@ -6,6 +6,7 @@ ENV = 'production'
# 金鸡湖现代服务业品牌管理系统/生产环境
# VUE_APP_BASE_API = '/prod-api'
# VUE_APP_BASE_API = 'http://39.101.188.84:9040'
VUE_APP_BASE_API = 'http://39.101.188.84:9040'
# VUE_APP_BASE_API = 'http://192.114.0.197/api'
VUE_APP_BASE_API = 'https://idp.sipac.gov.cn/api'
# VUE_APP_BASE_API = 'https://idp.sipac.gov.cn/api'

@ -1,6 +1,6 @@
{
"name": "ruoyi",
"version": "1.0.202406181508",
"version": "1.0.202406201411",
"description": "金鸡湖现代服务业品牌管理系统",
"author": "若依",
"license": "MIT",

@ -16,4 +16,22 @@ export function enterpriseLogout(params) {
method: "get",
params
})
}
}
// 政务端跳转过来查看个人信息
export function governmentGetInfo(params) {
return request({
url: "/system/chief",
method: "get",
params
})
}
// // 政务端退出登录
// export function enterpriseLogout(params) {
// return request({
// url: "/system/singlelogin/enterpriseLogout",
// method: "get",
// params
// })
// }

@ -18,7 +18,7 @@
>
<div class="avatar-wrapper">
<img :src="avatar" class="user-avatar" />
<div class="user-name">{{ name }}</div>
<div class="user-name">{{ nickName }}</div>
<i class="el-icon-caret-bottom" />
</div>
<el-dropdown-menu slot="dropdown">
@ -70,7 +70,7 @@ export default {
}
},
computed: {
...mapGetters(["avatar", "name", "sidebarRouters"]),
...mapGetters(["avatar", "name", "sidebarRouters", "nickName"]),
variables() {
return variables;
},

@ -59,6 +59,58 @@ router.beforeEach((to, from, next) => {
} else {
next();
}
} else if (window.location.href.includes("userToken=") && window.location.href.includes("signature=") && window.location.href.includes("timespan=")) {
var regOne = new RegExp(/[?&]timespan=([^&#]+)/);
var regTwo = new RegExp(/[?&]signature=([^&#]+)/);
var regThree = new RegExp(/[?&]userToken=([^&#]+)/);
const queryOne = window.location.href.match(regOne);
const queryTwo = window.location.href.match(regTwo);
const queryThree = window.location.href.match(regThree);
const timespan = queryOne && queryOne[1]; // 时间戳
const signature = queryTwo && queryTwo[1]; // 签名
const userToken = queryThree && queryThree[1]; // 用户令牌
let info = {
userToken,
signature,
timespan
}
if (store.getters.roles.length === 0) {
isRelogin.show = true;
store.dispatch("governmentLogin",info).then(res => {
isRelogin.show = false;
if (store.getters.roles.length === 0) {
// isRelogin.show = true;
let url = window.location.href;
var modifiedUrl = url.replace(/[\?&](timespan|signature|userToken)=.*?(#\/|$)/g, '');
// console.log(modifiedUrl,'modifiedUrl');
window.location.href = modifiedUrl;
// 判断当前用户是否已拉取完user_info信息
store
.dispatch("GetInfo")
.then(() => {
// isRelogin.show = false;
store.dispatch("GenerateRoutes").then((accessRoutes) => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes); // 动态添加可访问路由表
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
});
})
.catch((err) => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
});
}
}).catch((err) => {
console.log(err);
// store.dispatch("LogOut").then(() => {
// Message.error(err);
// location.href = "https://qyt.sipac.gov.cn/sipsg-enterprise-mobile-manage/#/login"
// });
});
}
}
// else if(window.location.href.includes("clienttoken=")){
@ -97,13 +149,17 @@ router.beforeEach((to, from, next) => {
}
} else {
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next();
} else {
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); // 否则全部重定向到登录页
NProgress.done();
}
// if (whiteList.indexOf(to.path) !== -1) {
// // 在免登录白名单,直接进入
// next();
// } else {
// next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); // 否则全部重定向到登录页
// NProgress.done();
// }
store.dispatch("LogOut").then(() => {
Message.error(err);
location.href = process.env.VUE_APP_BASE_API + "/system/singlelogin/login"
});
}
});

@ -8,6 +8,7 @@ const getters = {
token: (state) => state.user.token,
avatar: (state) => state.user.avatar,
name: (state) => state.user.name,
nickName: (state) => state.user.nickName,
introduction: (state) => state.user.introduction,
roles: (state) => state.user.roles,
permissions: (state) => state.user.permissions,

@ -1,11 +1,12 @@
import { login, logout, getInfo, refreshToken } from '@/api/login'
import { getToken, setToken, removeToken, setExpiresIn, getClientToken, setClientToken, removeClientToken } from '@/utils/auth'
import { singleSigngetInfo, enterpriseLogout } from "@/api/jin_ji_hu/login"
import { getToken, setToken, removeToken, setExpiresIn, getClientToken, setClientToken, removeClientToken, getUSerToken, setUserToken, removeUSerToken } from '@/utils/auth'
import { singleSigngetInfo, enterpriseLogout, governmentGetInfo } from "@/api/jin_ji_hu/login"
const user = {
state: {
token: getToken(),
clientToken: getClientToken(),
userToken: getUSerToken(),
id: '',
name: '',
avatar: '',
@ -25,6 +26,9 @@ const user = {
SET_CLIENTTOKEN: (state, token) => {
state.clientToken = token
},
SET_USERTOKEN: (state, token) =>{
state.userToken = token
},
SET_EXPIRES_IN: (state, time) => {
state.expires_in = time
},
@ -82,6 +86,7 @@ const user = {
})
},
// 企业端登录
SingleSignOnGetInfo({ commit, state },info) {
return new Promise((resolve, reject) => {
singleSigngetInfo({clientToken: info.clientToken}).then(res => {
@ -106,10 +111,28 @@ const user = {
})
},
// 政务端登录
governmentLogin({ commit, state },info) {
return new Promise((resolve, reject) => {
governmentGetInfo(info).then(res => {
// console.log(res);
setUserToken(info.userToken)
commit('SET_USERTOKEN', res.data.token)
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
resolve()
}).catch(error => {
console.log(error);
// reject(error)
})
})
},
// 获取用户信息
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
// console.log(res);
const user = res.user
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组

@ -2,7 +2,9 @@ import Cookies from 'js-cookie'
const TokenKey = 'Admin-Token'
const ClientToken = 'ClientToken'
const UserToken = 'UserToken'
const ExpiresInKey = 'Admin-Expires-In'
export function getToken() {
return Cookies.get(TokenKey)
}
@ -39,4 +41,17 @@ export function setClientToken(token) {
export function removeClientToken() {
return Cookies.remove(ClientToken)
}
// 政务端登录的userToken
export function getUSerToken() {
return Cookies.get(UserToken)
}
export function setUserToken(token) {
return Cookies.set(UserToken, token)
}
export function removeUSerToken() {
return Cookies.remove(UserToken)
}
Loading…
Cancel
Save