<template>
  <div>123</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.$axios
        .$get("/getGzhAuthorizeInfo", {
          params: {
            code: this.$route.query.code,
            stationId: this.stationId,
          },
        })
        .then((res) => {
          if (res.retCode === 0) {
            this.$store.dispatch("authen/setBaseData", {
              openId: res.data.openid,
              accessToken: res.data.access_token,
              unionId: res.data.unionid,
            });
            this.handleGoto();
          }
        })
        .catch((res) => {
          alert("catch");
          getAuthen();
        });
    }
  },
  methods: {
    handleGoto() {
      console.log(this.redirect);
      this.$router.replace({
        path: this.redirect,
      });
    },
  },
});
</script>

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