Commit 4bd49306 by yancanhua

fix: 企业微信授权优化

1 parent a5841700
......@@ -98,6 +98,16 @@ const pages = {
showAction: true
}
},
{
name: 'authorize',
meta: {
keepAlive: true,
title: '登录授权',
noAuth: true,
backgroundColor: '#f7f8fa',
showAction: true
}
},
]
}
let routes = [
......
......@@ -81,7 +81,11 @@ const actions = {
} else throw message
})
} else {
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}&backLoginCode=BACKCODE`
util.setLocalStorage('authorizeUrl', window.location.href);
let locationHref = window.location.href;
//把字符串 department, personage, company 替换为 authorize
locationHref = locationHref.replace(/(department|personage|company)/g, 'authorize');
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(locationHref)}&corpId=${corpId}&agentId=${agentId}&backLoginCode=BACKCODE`
}
} catch (error) {
if (!error) error = '登录失败或无权限'
......
<!-- 公司月度总结 -->
<template>
<div>
<div class="pageBox">{{ pageTitle }}</div>
</div>
</template>
<script>
import { util } from 'utils'
export default {
data() {
return {
pageTitle: '正在登录授权中...',
}
},
mounted() {
const code = this.getParams('code');
if (code) {
this.pageTitle = '授权成功';
const authorizeUrl = util.getLocalStorage('authorizeUrl');
window.location.href = authorizeUrl + '&code=' + code;
} else {
this.pageTitle = '正在登录授权中...'
}
},
methods: {
getParams(name) {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
}
}
</script>
<style lang="scss" scoped>
.pageBox {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!