authen.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div>认证中,请稍等</div>
  3. </template>
  4. <script>
  5. import Vue from "vue";
  6. import { getAuthen } from "../assets/util";
  7. import querystring from "querystring";
  8. export default Vue.extend({
  9. head() {
  10. return {
  11. title: "认证",
  12. };
  13. },
  14. data() {
  15. return {
  16. redirect: "",
  17. };
  18. },
  19. created() {
  20. console.log(this.$route);
  21. const [url, str] = this.$route.query.state.split("abc")
  22. this.redirect = url;
  23. if(str!==undefined){
  24. const search = querystring.parse(str.replace(/def/g,"&").replace(/ghi/g,"="));
  25. console.log(search)
  26. }
  27. if (!this.$route.query.code) {
  28. getAuthen();
  29. } else {
  30. console.log("-----");
  31. console.log(this.$route);
  32. this.$store.dispatch("authen/login",this.$route.query.code).then((res)=>{
  33. console.log(this.$route.query);
  34. this.handleGoto();
  35. }).catch((res)=>{
  36. alert(res);
  37. getAuthen();
  38. });
  39. }
  40. },
  41. methods: {
  42. handleGoto() {
  43. console.log("goto")
  44. console.log(this.redirect);
  45. this.$router.replace({
  46. path: this.redirect,
  47. });
  48. },
  49. },
  50. });
  51. </script>
  52. <style lang="less">
  53. </style>