Commit 50365685 by yancanhua

fix: 企业微信登录自测问题调整

1 parent 5d0cc991
...@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => { ...@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => {
console.log(recode) console.log(recode)
setTimeout(() => { setTimeout(() => {
store.dispatch('login') store.dispatch('login')
}, 660) }, 666)
}) })
if (to.matched.some(recode => recode.meta.noAuth)) { if (to.matched.some(recode => recode.meta.noAuth)) {
console.log('noAuth') console.log('noAuth')
......
...@@ -40,20 +40,28 @@ const actions = { ...@@ -40,20 +40,28 @@ const actions = {
// window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } }) // window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}, },
login({ dispatch, state }) { login({ dispatch, state }) {
//获取当前路由路径 //获取当前路由路径
const currentPath = window.location.href; const currentPath = window.location.href;
const pathKeywords = ['/department', '/personage', '/company']; const pathKeywords = ['/department', '/personage', '/company'];
const isTargetPath = pathKeywords.some(keyword => currentPath.includes(keyword)); const isTargetPath = pathKeywords.some(keyword => currentPath.includes(keyword));
if (isTargetPath) { const pushId = getParams('pushId');
if (isTargetPath && (pushId && (pushId * 1) > 744)) {
state.showWindow = false state.showWindow = false
try { try {
let { corpId, agentId } = getParams(); let { corpId, agentId } = getParams();
const wwCode = getParams('code'); const wwCode = getParams('code');
let { loginUrl } = window.$fetchConfig; let { loginUrl } = window.$fetchConfig;
let userInfo = window.sessionStorage.getItem('ww_userInfo') || ''; let userInfo = util.getLocalStorage('ww_userInfo') || '';
if(userInfo) return state.showWindow = true; if (userInfo && userInfo.timestamp) {
//判断用户时间戳是否过期12小时
if (userInfo.timestamp && (Date.now() - userInfo.timestamp) > (1000 * 60 * 720)) {
console.log('用户登录过期');
} else {
console.log('用户登录未过期');
return state.showWindow = true;
}
}
if (wwCode) { if (wwCode) {
ssoApi.login({ code: wwCode, corpId, getUserInfoFlag: false }).then(res => { ssoApi.login({ code: wwCode, corpId, getUserInfoFlag: false }).then(res => {
const { code, data, message } = res; const { code, data, message } = res;
...@@ -64,8 +72,10 @@ const actions = { ...@@ -64,8 +72,10 @@ const actions = {
if (item.loginList && item.loginList.length) { if (item.loginList && item.loginList.length) {
let [userInfo] = item.loginList, let [userInfo] = item.loginList,
{ phone } = userInfo { phone } = userInfo
if (phone) window.sessionStorage.setItem('ww_params_phone', JSON.stringify(phone)) if (phone) util.setLocalStorage('ww_params_phone', phone)
window.sessionStorage.setItem('ww_userInfo', JSON.stringify(userInfo)) //获取当前时间戳
userInfo.timestamp = Date.now();
util.setLocalStorage('ww_userInfo', userInfo);
} else throw '' } else throw ''
} else throw '' } else throw ''
} else throw message } else throw message
...@@ -77,14 +87,14 @@ const actions = { ...@@ -77,14 +87,14 @@ const actions = {
if (!error) error = '登录失败或无权限' if (!error) error = '登录失败或无权限'
if (error) Notify(typeof error === 'string' ? error : error.toString()) if (error) Notify(typeof error === 'string' ? error : error.toString())
} }
} else {
state.showWindow = true
const { corpId, agentId } = util.getLocalStorage('ww_storage_info'),
{ loginUrl } = window.$fetchConfig;
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}`
} }
// else {
// state.showWindow = true
// const { corpId, agentId } = util.getLocalStorage('ww_storage_info'),
// { loginUrl } = window.$fetchConfig;
// window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}`
// }
}, },
navigation({ dispatch }, to) { navigation({ dispatch }, to) {
let { corpId, agentId, phone, name,id } = getParams(), let { corpId, agentId, phone, name,id } = getParams(),
userInfo = util.getLocalStorage('ww_userInfo') userInfo = util.getLocalStorage('ww_userInfo')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!