index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="informantion_mask">
  3. <view class="informantion_content" @tap.stop.prevent>
  4. <view class="informantion-title">
  5. <view>
  6. <view @click="showCloseempty" style="height: 10%;">
  7. <p class="informantion-title-p">公告</p>
  8. </view>
  9. <view v-if="showClose >2" class="close-btn uni-column">
  10. <uni-icons class="icon-gear" type="closeempty" size="30" style="z-index: 5;"
  11. @click="close"></uni-icons>
  12. </view>
  13. </view>
  14. <div v-html="message" class="informantion-title-span"></div>
  15. <!-- {{message}} -->
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import {
  22. onMounted,
  23. ref,
  24. getCurrentInstance
  25. } from 'vue'
  26. import {
  27. onLoad,
  28. onReady,
  29. onUnload,
  30. onShow,
  31. onReachBottom,
  32. } from '@dcloudio/uni-app'
  33. import {
  34. store
  35. } from '@/store/index.js'
  36. const message = ref('')
  37. const showClose = ref(0)
  38. onMounted(() => {
  39. uni.hideLoading();
  40. const instance = getCurrentInstance().proxy
  41. const eventChannel = instance.getOpenerEventChannel();
  42. eventChannel.on('notification', function(data) {
  43. console.log('notification', data)
  44. if (data && data.data) {
  45. message.value = data.data.content;
  46. }
  47. })
  48. })
  49. function showCloseempty() {
  50. showClose.value += 1
  51. }
  52. function close() {
  53. store.isNotification = true
  54. let pages = getCurrentPages();
  55. let index = 0
  56. for (let i = pages.length - 1; i >= 0; i--) {
  57. if (pages[i].$page.fullPath != "/pages/notification/index") {
  58. index = pages.length - i - 1;
  59. break
  60. }
  61. }
  62. uni.navigateBack({
  63. delta: index
  64. });
  65. console.log(pages)
  66. }
  67. </script>
  68. <style lang="scss">
  69. page {
  70. width: 100%;
  71. height: 100%;
  72. background: rgba(0, 0, 0, 0.4);
  73. }
  74. .informantion_mask {
  75. width: 100%;
  76. height: 100%;
  77. display: flex;
  78. flex-direction: row;
  79. justify-content: center;
  80. align-items: center;
  81. }
  82. .informantion_content {
  83. width: 600rpx;
  84. height: 820rpx;
  85. // height: 70%;
  86. overflow: hidden;
  87. border-radius: 10rpx;
  88. background-color: white;
  89. display: flex;
  90. flex-direction: column;
  91. justify-content: space-between;
  92. padding-bottom: 20rpx;
  93. }
  94. .informantion-title-span {
  95. height: 82%;
  96. overflow: auto;
  97. margin-bottom: -20px;
  98. }
  99. .mask-header {
  100. height: 400rpx;
  101. position: relative;
  102. background-image: url('../../static/images/bj.png');
  103. background-repeat: no-repeat;
  104. background-size: cover;
  105. image {
  106. width: 40rpx;
  107. height: 40rpx;
  108. position: absolute;
  109. top: 20rpx;
  110. right: 20rpx;
  111. }
  112. }
  113. .close-btn {
  114. position: absolute;
  115. right: 24rpx;
  116. top: 24rpx;
  117. width: 40rpx;
  118. height: 40rpx;
  119. z-index: 1003;
  120. .close-btn-icon {
  121. width: 40rpx;
  122. }
  123. }
  124. .informantion-title {
  125. overflow: auto;
  126. text-align: center;
  127. padding: 0 40rpx;
  128. p {
  129. font-size: 35rpx;
  130. font-weight: bold;
  131. line-height: 80rpx;
  132. }
  133. span {
  134. color: #6C6C6C;
  135. }
  136. }
  137. .informantion-btn {
  138. height: 93rpx;
  139. width: 80%;
  140. margin: 0 auto;
  141. }
  142. </style>