单点登录增加
This commit is contained in:
parent
1e35b38dca
commit
8ce3f7689d
|
|
@ -11,9 +11,9 @@
|
|||
<el-form-item style="width: 100%">
|
||||
<el-button type="primary" style="width: 100%; border: none" @click="login">登录</el-button>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item style="width: 100%">
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button type="primary" style="width: 100%; border: none" @click="loginCate">卡特账号登录</el-button>
|
||||
</el-form-item> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</body>
|
||||
</template>
|
||||
|
|
@ -26,6 +26,7 @@ import { reactive, onMounted } from 'vue';
|
|||
import store from '@/store'
|
||||
import router from '@/router'
|
||||
import crypto from 'crypto'
|
||||
import loading from "@/utils/loading";
|
||||
// Dependency: Node.js crypto module
|
||||
// https://nodejs.org/api/crypto.html#crypto_crypto
|
||||
function base64URLEncode(str) {
|
||||
|
|
@ -96,12 +97,8 @@ const loginCate = () => {
|
|||
// window.open(cateLoginUrl)// 不打开新窗口
|
||||
}
|
||||
onMounted(() => {
|
||||
if (router.currentRoute.value.query.code != null | undefined) {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)',
|
||||
})
|
||||
if (router.currentRoute.value.query.code !== undefined) {
|
||||
loading.open('请求登录中...')
|
||||
const tokenParam = {
|
||||
code_verifier: store.getters.getVerify,
|
||||
client_id: '609f8296-74ab-441e-904f-3a8508030511',
|
||||
|
|
@ -114,15 +111,13 @@ onMounted(() => {
|
|||
// response_mode: 'form_post'
|
||||
}
|
||||
postToGetToken(tokenParam).then(res => {
|
||||
loading.close()
|
||||
store.commit('mutationClearVerify', verifier)// 删除认证信息
|
||||
if (res.data.id_token != null | undefined) {
|
||||
if (res.data.id_token !== undefined) {
|
||||
const codeInfo = {
|
||||
id_token: res.data.id_token
|
||||
}
|
||||
getUser(codeInfo).then(res => {
|
||||
loading.close()
|
||||
if (res.data.code == 0) {
|
||||
if (res.data.code === 0) {
|
||||
store.commit('mutationUser', res.data.returnData.user)// 用户信息
|
||||
store.commit('mutationMenu', res.data.returnData.menuList)// 菜单信息
|
||||
store.commit('mutationStandId', res.data.returnData.standId)
|
||||
|
|
@ -132,14 +127,14 @@ onMounted(() => {
|
|||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
loading.close()
|
||||
ElMessage.error('登录失败!')
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
loading.close()
|
||||
ElMessage.error('登录错误')
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user