notice.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div>
  3. <div v-if="langMsg" @click="noticeShow = true" class="game-notice">
  4. {{langMsg['title']}}:{{langMsg['msg']}}
  5. </div>
  6. <transition name="msgbox-fade">
  7. <div class="popup-wrap" v-if="noticeShow && langMsg">
  8. <div class="popup-modal"></div>
  9. <div class="popup-box">
  10. <div class="popup-hd">
  11. <div class="popup-hd-title"><em>{{langMsg['title']}}</em></div>
  12. <span class="popup-close" @click="noticeShow = false"></span>
  13. </div>
  14. <div class="popup-bd">
  15. <div class="rules-text" v-html="langMsg['msg']"></div>
  16. </div>
  17. </div>
  18. </div>
  19. </transition>
  20. </div>
  21. </template>
  22. <script>
  23. import API from '@/api'
  24. export default {
  25. name: 'notice',
  26. data () {
  27. return {
  28. noticeMap: {},
  29. langMsg: null,
  30. noticeShow: false
  31. }
  32. },
  33. watch: {
  34. '$i18n.locale' (to, form) {
  35. if (this.langMsg) {
  36. let lang = this.$i18n.locale
  37. this.langMsg = this.noticeMap[lang]
  38. }
  39. }
  40. },
  41. methods: {
  42. getNitice () {
  43. API.game.getNewMsg().then(({ data }) => {
  44. if (data.data) {
  45. this.noticeMap['zh'] = {
  46. 'title': data.data.zh_title,
  47. 'msg': data.data.zh_msg
  48. }
  49. this.noticeMap['en'] = {
  50. 'title': data.data.en_title,
  51. 'msg': data.data.en_msg
  52. }
  53. this.noticeMap['kr'] = {
  54. 'title': data.data.kr_title,
  55. 'msg': data.data.kr_msg
  56. }
  57. let lang = this.$i18n.locale
  58. this.langMsg = this.noticeMap[lang]
  59. // 是否展示弹窗
  60. let noticeId = data.data.id
  61. if (!localStorage.getItem('dice_game_notice_id')) {
  62. this.noticeShow = true
  63. localStorage.setItem('dice_game_notice_id', noticeId)
  64. return
  65. }
  66. let localId = localStorage.getItem('dice_game_notice_id')
  67. if (noticeId !== Number(localId)) {
  68. this.noticeShow = true
  69. localStorage.setItem('dice_game_notice_id', noticeId)
  70. }
  71. }
  72. })
  73. }
  74. },
  75. mounted () {
  76. this.getNitice()
  77. }
  78. }
  79. </script>
  80. <style lang="scss">
  81. .game-notice{
  82. width: px2rem(1300);
  83. margin: px2rem(12) auto;
  84. height: px2rem(32);
  85. line-height: px2rem(32);
  86. background-color: rgba($color: #000000, $alpha: .6);
  87. font-size: px2rem(12);
  88. padding: 0 px2rem(20);
  89. border-radius: px2rem(16);
  90. color: #ffffff;
  91. cursor: pointer;
  92. overflow: hidden;
  93. text-overflow: ellipsis;
  94. white-space: nowrap;
  95. box-sizing: border-box;
  96. @media #{$phone} {
  97. position: static;
  98. top: auto;
  99. left: auto;
  100. margin: px2rem(10) auto;
  101. width: 100%;
  102. font-size: px2rem(24);
  103. height: px2rem(38);
  104. line-height: px2rem(38);
  105. }
  106. }
  107. .rules-text{
  108. padding: px2rem(20);
  109. background-color: rgba(0, 0, 0, 0.2);
  110. text-align: left;
  111. font-size: px2rem(16);
  112. line-height: px2rem(28);
  113. @include wrap;
  114. @media #{$phone} {
  115. font-size: px2rem(24);
  116. line-height: px2rem(44);
  117. }
  118. }
  119. </style>