8 changed files with 96 additions and 4 deletions
@ -0,0 +1,73 @@ |
|||
<template> |
|||
<div class="g-app"> |
|||
<div class="m-hint">登录中...</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { requestGet, requestPost } from "@/js/dai/request"; |
|||
import getQueryPara from "dai-js/modules/getQueryPara"; |
|||
|
|||
export default { |
|||
data() { |
|||
return {}; |
|||
}, |
|||
|
|||
components: {}, |
|||
computed: {}, |
|||
|
|||
created() { |
|||
let ticket = getQueryPara("ticket"); |
|||
if (ticket) { |
|||
this.loginByTicket(ticket); |
|||
} else { |
|||
this.getAuthUrl(); |
|||
} |
|||
}, |
|||
mounted() {}, |
|||
|
|||
methods: { |
|||
async getAuthUrl() { |
|||
const url = "/auth/sso/ssoAuthUrl"; |
|||
|
|||
const { data, code, msg } = await requestGet(url, { |
|||
clientLoginUrl: location.href, |
|||
}); |
|||
|
|||
if (code === 0) { |
|||
location.href = data.authUrl + "&mode=ticket"; |
|||
} else { |
|||
this.$message.error(msg); |
|||
} |
|||
}, |
|||
|
|||
async loginByTicket(ticket) { |
|||
const url = "/auth/sso/login?ticket=" + ticket; |
|||
|
|||
const { data, code, msg } = await requestPost(url, { |
|||
ticket, |
|||
}); |
|||
|
|||
if (code === 0) { |
|||
localStorage.setItem("token", data.token); |
|||
this.$router.replace({ name: "index" }); |
|||
} |
|||
}, |
|||
}, |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.g-app { |
|||
width: 100vw; |
|||
height: 100vh; |
|||
background-color: #f7f7f7; |
|||
.m-hint { |
|||
text-align: center; |
|||
font-size: 36px; |
|||
line-height: 100vh; |
|||
color: #999999; |
|||
font-weight: bold; |
|||
} |
|||
} |
|||
</style> |
Loading…
Reference in new issue