| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <div class="login">
- <div>
- <div class="avatar-box">
- <van-loading text-color="#0094ff" v-if="loading">正在跳转</van-loading>
- <span style="color: red" v-if="type == 'error'">{{ message }}</span>
- <span style="color: #E6A23C" v-if="type == 'warn'">{{ message }}</span>
- </div>
- </div>
- </div>
- </template>
- <script>
- // 请求接口
- import { tokenLogin } from '@/api/public.js'
- import { mapGetters } from 'vuex'
- export default {
- data() {
- return {
- loading: false,
- type: '',
- message: ''
- }
- },
- computed: {
- ...mapGetters(['userName'])
- },
- inject:["initWebSocket"],
- mounted() {
- this.loading = true
- let { query } = this.$route;
- if (!query) {
- this.loading = false
- this.type = 'error'
- this.message = '缺少sso_token'
- } else {
- let { sso_token } = query
- if (!sso_token) {
- this.type = 'warn'
- this.loading = false
- this.message = '缺少sso_token'
- } else {
- tokenLogin(sso_token)
- .then(res => {
- console.log(res, 'res')
- sessionStorage.setItem('access_token',res.data.access_token);
- this.$router.replace('/home');
- //初始化websocket
- // this.initWebSocket();
- })
- .catch(e => {
- this.type = 'error'
- this.message = '请求错误'
- this.loading = false
- })
- }
- }
- },
- methods: {}
- }
- </script>
- <style lang="scss">
- //.van-cell__title{
- // align-items: center;
- //}
- //.custom-title{
- // align-self: center;
- //}
- </style>
- <style scoped lang="scss">
- .login {
- height: 100vh;
- background: url('../assets/img/login-background.png') top left no-repeat #edfcff;
- background-size: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- > div {
- width: 450px;
- padding: 30px 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- background-color: #fff;
- border-radius: 10px;
- .avatar-box {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 150px;
- }
- }
- h2 {
- letter-spacing: 10px;
- text-align: center;
- }
- .custom-title {
- align-self: center;
- vertical-align: middle;
- }
- }
- </style>
|