authen.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div>123</div>
  3. </template>
  4. <script>
  5. import Vue from "vue";
  6. import { getAuthen } from "../assets/util";
  7. export default Vue.extend({
  8. head() {
  9. return {
  10. title: "认证",
  11. };
  12. },
  13. data() {
  14. return {
  15. redirect: "",
  16. };
  17. },
  18. mounted() {
  19. this.redirect = this.$route.query.state;
  20. if (!this.$route.query.code) {
  21. getAuthen();
  22. } else {
  23. this.$axios
  24. .$get("/getGzhAuthorizeInfo", {
  25. params: {
  26. code: this.$route.query.code,
  27. stationId: this.stationId,
  28. },
  29. })
  30. .then((res) => {
  31. if (res.retCode === 0) {
  32. this.$store.dispatch("authen/setBaseData", {
  33. openId: res.data.openid,
  34. accessToken: res.data.access_token,
  35. unionId: res.data.unionid,
  36. });
  37. this.handleGoto();
  38. }
  39. })
  40. .catch((res) => {
  41. alert("catch");
  42. getAuthen();
  43. });
  44. }
  45. },
  46. methods: {
  47. handleGoto() {
  48. console.log(this.redirect);
  49. this.$router.replace({
  50. path: this.redirect,
  51. });
  52. },
  53. },
  54. });
  55. </script>
  56. <style lang="less">
  57. </style>