index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="loginBox">
  3. <iframe src="//edu.cocorobo.hk/LoginIframe?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. if (userid) {
  34. this.$router.push({ path: this.redirect || '/' })
  35. }
  36. // eduGet().then(res => {})
  37. }
  38. },
  39. beforeDestroy() {
  40. clearInterval(this.timer)
  41. this.timer = null
  42. },
  43. mounted() {
  44. this.getLogin()
  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>