userLogin.vue 966 B

1234567891011121314151617181920212223242526272829303132
  1. <script>
  2. export default {
  3. created() {
  4. const code = this.getUrlKey("code")
  5. const hostname = document.location.hostname;
  6. if(code){
  7. let params = {}
  8. params.code = code
  9. params.hostname = hostname
  10. this.$store.dispatch("WxLogin", params).then((res) => {
  11. this.$router.push({ path: "/" });
  12. // this.$router.push({ path: "/register" });
  13. }).catch((res) => {
  14. // console.log(code)
  15. // this.$router.push({ path: "/login" });
  16. this.$router.push({ path: "/register" });
  17. });
  18. }else{
  19. // this.$router.push({ path: "/login" });
  20. this.$router.push({ path: "/register" });
  21. }
  22. },
  23. render: function(h) {
  24. return h() // avoid warning message
  25. },
  26. methods: {
  27. getUrlKey(name) {
  28. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
  29. },
  30. }
  31. }
  32. </script>