DrawCarouselGame.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="gameBox">
  6. <iframe id="iframe" frameborder="0" :src="src" style="width: 100%;height: 100%;"></iframe>
  7. </div>
  8. </div>
  9. <SiderInfo></SiderInfo>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import SiderInfo from '@/components/SiderInfo.vue'
  15. import { getToken } from '@/utils/auth'
  16. export default{
  17. components: {
  18. SiderInfo
  19. },
  20. data() {
  21. return {
  22. src: this.$route.query.actId == 37 ? './dailyDrawCarousel.html' : this.$route.query.actId == 8 || this.$route.query.actId == 49 ? './monthlyDrawCarousel.html' : this.$route.query.actId == 47 ? './newYearDrawCarousel.html' : '', //需要加载的子页面url
  23. actId:this.$route.query.actId
  24. };
  25. },
  26. created(){},
  27. async mounted(){
  28. var that = this
  29. this.iframe = document.getElementById('iframe');
  30. this.iframe.onload = function(){
  31. // iframe加载完成后要进行的操作
  32. that.postMsg()
  33. };
  34. window.getUserInfo = this.getUserInfo;// 这里需要暴露给全局,这样的话,子页面才能调用相对应的方法
  35. },
  36. methods: {
  37. async postMsg() {
  38. //将token传递给子页面
  39. let token = getToken();
  40. let actId = this.actId;
  41. let param = {
  42. token,
  43. actId
  44. }
  45. this.iframe.contentWindow.postMessage(param,'*')
  46. },
  47. getUserInfo(){
  48. this.$store.dispatch('GetUserInfo');
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped>
  54. .timeline-container{
  55. margin: 0 auto;
  56. }
  57. .timeline-entry-list{
  58. margin-right: 17.5rem;
  59. border-radius: 2px;
  60. position: relative;
  61. display: flex;
  62. justify-content: center;
  63. align-items: center;
  64. }
  65. .timeline-entry-list .gameBox{
  66. width: 720px;
  67. height: 720px;
  68. background-color: #fff;
  69. }
  70. </style>