<template>
  <div>单点登录中...</div>
</template>

<script>
import { decrypt } from '@/utils/rsaEncrypt'
export default {
  name: 'Sso',
  data() {
    const username = this.$route.query.username
    const password = this.$route.query.password
    const redirect = this.$route.query.redirect
    console.log(this.$route.query)
    return {
      user: {
        username: decrypt(username),
        password: password
      },
      redirect: redirect
    }
  },
  created() {
    console.log(this.user)
    this.loginSSO()
  },
  methods: {
    loginSSO() {
      this.$store.dispatch('LoginSSO', this.user).then(() => {
        // this.loading = false
        this.$router.push({ path: this.redirect || '/' })
      }).catch((err) => {
        // this.loading = false
        // this.getCode()
        this.$message({
          type: 'error',
          message: err.message
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
