<template>
  <div>认证中,请稍等</div>
</template>

<script>
import Vue from "vue";
import { getAuthen } from "../assets/util";
export default Vue.extend({
  head() {
    return {
      title: "认证",
    };
  },
  data() {
    return {
      redirect: "",
    };
  },
  mounted() {
    this.redirect = this.$route.query.state;
    if (!this.$route.query.code) {
      getAuthen();
    } else {
      this.$store.dispatch("authen/login",this.$route.query.code).then((res)=>{
        this.handleGoto();
      }).catch((res)=>{
        alert(res);
        getAuthen();
      });
    }
  },
  methods: {
    handleGoto() {
      this.$router.replace({
        path: this.redirect,
      });
    },
  },
});
</script>

<style lang="less">
</style>
