<template>
  <div>
    <span>正在登录中。。。。</span>
  </div>
</template>

<script>
import * as types from "../../store/mutation-types";
export default {
  data() {
    return {
      data: "",
    };
  },

  methods: {
    getUrlKey(name) {
      return (
        decodeURIComponent(
          (new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
            location.href
          ) || [, ""])[1].replace(/\+/g, "%20")
        ) || null
      );
    },
  },
  mounted() {},

  created() {
    this.data = this.getUrlKey("obj");
    console.log(this.data+"谁先来"); //21
    var jsObject = JSON.parse(this.data);
    console.log(jsObject.id);
/**
 * {"code":20000,"message":"success","data":{"id":1,"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhZG1pbl9pZCI6MSwiZXhwIjoxNjA1MTc4NDkxfQ.4v6qo3VaFt3tWgYeVI8q-kHhcjtDhjgzyjYnDaVtiKE"}}
 */
    this.$store.commit(types.RECEIVE_ADMIN_ID, jsObject.id+"");
//http://127.0.0.1:8080/#/pcIntent?obj={"id":1,"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhZG1pbl9pZCI6MSwiZXhwIjoxNjA1MTc4NDkxfQ.4v6qo3VaFt3tWgYeVI8q-kHhcjtDhjgzyjYnDaVtiKE"}
    this.$store.commit(types.RECEIVE_ADMIN_TOKEN, jsObject.token);
    this.$router.push({ path: "/main"});
  },
};
</script>