index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="loginBox">
  3. <iframe src="//edu.cocorobo.cn/course/login?type=2" frameborder="0"></iframe>
  4. <!-- <button @click="handleLogin">登录</button> -->
  5. </div>
  6. </template>
  7. <script>
  8. import { mapActions } from 'vuex'
  9. export default {
  10. data() {
  11. return {
  12. redirect: undefined,
  13. timer: null
  14. }
  15. },
  16. watch: {
  17. $route: {
  18. handler: function(route) {
  19. this.redirect = route.query && route.query.redirect
  20. },
  21. immediate: true
  22. }
  23. },
  24. methods: {
  25. ...mapActions({
  26. login: 'user/login'
  27. }),
  28. handleLogin() {
  29. this.$router.push({ path: this.redirect || '/' })
  30. },
  31. async getLogin() {
  32. const userid = await this.login()
  33. console.log(userid)
  34. if (userid) {
  35. this.$router.push({ path: this.redirect || '/' })
  36. }
  37. // eduGet().then(res => {})
  38. }
  39. },
  40. beforeDestroy() {
  41. clearInterval(this.timer)
  42. this.timer = null
  43. },
  44. mounted() {
  45. this.timer = setInterval(() => {
  46. this.getLogin()
  47. }, 2000)
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .loginBox {
  53. position: relative;
  54. width: 100vw;
  55. height: 100vh;
  56. overflow: hidden;
  57. > iframe {
  58. width: 100%;
  59. height: 100%;
  60. border: 0;
  61. }
  62. }
  63. </style>