index.vue 2.9 KB

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