<!--
 * @Author: jixiang
 * @Date: 2021-09-10 11:23:38
 * @Description: 
 * @FilePath: /suqian_pc_new/src/views/login/casLogin.vue
 * One World One Drefeel(56580223@qq.com)
-->
<!--  -->
<template>
  <div class=""></div>
</template>

<script setup lang="ts">
import { mapGetters } from 'vuex';
import { onMounted, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex';
import { getToken, setToken } from '@/utils/cookie';
const route = useRoute();
const router = useRouter();
const store = useStore();
import Axios from '@/api/axios';
console.log(route.query, router, 'ticket');
const cas = () => {
  Axios.post(
    '/fighter-integrate-uaap/integrate/uaap/cas/exchange-token',
    {},
    {
      params: {
        token: route.query.ticket,
      },
    }
  )
    .then((response) => {
      // 用户信息存储 以及 验证业务token 待实现
      // store.dispatch('Login', { loginInfo: response.data });
      const { data, code, headers } = response.data;
      if (code === 200) {
        store.dispatch('user/getUserInfo', { userinfo: data.subject });
        // setToken(data.subject.id);
        // debugger;
        console.log(headers, 'headers');
        let toUrl: any = route.query.toUrl;
        if (toUrl) {
          router.push(toUrl);
        } else {
          // router.push('/bookList');
        }
        console.log(response, 'resp');
      }
    })
    .catch((error) => {
      // this.$message.error(error.msg)
    });
  console.log(route.query.ticket, 'ticket');
};

// 生命周期 - 挂载完成（可以访问DOM元素）
onMounted(() => {
  console.log('cas');
  cas();
});
</script>
<!-- <style lang="scss" scoped>
  //@import url(); 引入公共css类
</style> -->
