index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="detail_container">
  3. <uni-card>
  4. <template v-slot:title>
  5. <view class="message_title">
  6. {{ msgInfo.title}}
  7. </view>
  8. </template>
  9. <view class="message_container">
  10. <uni-card :border="false" :is-shadow="false" spacing="0px" margin="0px">
  11. <view class="message_contant">
  12. <u-parse :content="msgInfo.content" :selectable="true" @navigate="parseNavigate">
  13. </u-parse>
  14. </view>
  15. <view>
  16. <attachment-list :attachments="attachments"></attachment-list>
  17. </view>
  18. <view class="message_info">
  19. <uni-row :gutter="20">
  20. <uni-col :xs="{span: 24}" :sm="{span: 16, offset: 1}">
  21. <view class="user">
  22. <text class="user_pre">发布者:</text>
  23. {{msgInfo.name}}
  24. </view>
  25. </uni-col>
  26. <uni-col :xs="{span: 24}" :sm="6">
  27. <view class="time">
  28. 发布时间:{{msgInfo.sendTime}}
  29. </view>
  30. </uni-col>
  31. </uni-row>
  32. </view>
  33. </uni-card>
  34. </view>
  35. </uni-card>
  36. </view>
  37. </template>
  38. <script setup lang="ts">
  39. import { onLoad } from '@dcloudio/uni-app';
  40. import { onMounted, ref } from 'vue';
  41. import { getNoticeInfo, getMessageInfo } from '@/api/message';
  42. import $tab from '@/plugins/tab';
  43. import uParse from '@/components/gaoyia-parse/parse.vue'
  44. import attachmentList from '@/components/ygoa/attachmentList.vue'
  45. import { useUserStore } from '@/store/user';
  46. const userStore = useUserStore();
  47. const type = ref(-1);
  48. const noticeId = ref('');
  49. const universalId = ref('');
  50. const messageId = ref('');
  51. onLoad((options) => {
  52. if(options.noticeId) {
  53. type.value = 0
  54. noticeId.value = options.noticeId;
  55. } else {
  56. type.value = 1
  57. universalId.value = options.universalId;
  58. messageId.value = options.messageId;
  59. }
  60. })
  61. const msgInfo = ref({})
  62. const attachments = ref([]);//附件
  63. //公告详情
  64. function showNoticeInfo(id) {
  65. const params = {
  66. userId: userStore.user.useId, //当前用户id
  67. noticeId: id
  68. }
  69. getNoticeInfo(params).then(({ returnParams }) => {
  70. // console.log('returnParams', returnParams);
  71. msgInfo.value = {
  72. title: returnParams.title,
  73. sendTime: returnParams.sendTime,
  74. name: returnParams.name,
  75. content: returnParams.noticeContent,
  76. }
  77. if (returnParams.affixUrl) {
  78. attachments.value = returnParams.affixUrl;
  79. console.log(attachments.value);
  80. }
  81. })
  82. }
  83. //消息详情
  84. function showMessageInfo({ universalId, messageId }) {
  85. const params = {
  86. universalId: universalId,
  87. messageId: messageId
  88. }
  89. getMessageInfo(params).then(({ returnParams }) => {
  90. msgInfo.value = {
  91. title: returnParams.title,
  92. sendTime: returnParams.sendtime,
  93. name: returnParams.name,
  94. content: returnParams.content,
  95. }
  96. })
  97. }
  98. onMounted(() => {
  99. switch (type.value) {
  100. case 0:
  101. showNoticeInfo(noticeId.value);
  102. break;
  103. case 1:
  104. showMessageInfo({ universalId: universalId.value, messageId: messageId.value });
  105. break;
  106. }
  107. })
  108. // 超链接 跳转
  109. function parseNavigate(href, e) {
  110. $tab.navigateTo('./URLView?url=' + encodeURIComponent(href));
  111. }
  112. </script>
  113. <style lang="scss">
  114. .detail_container {
  115. .message_title {
  116. text-align: center;
  117. font-size: 1.5rem;
  118. font-weight: bold;
  119. margin-top: 5px;
  120. }
  121. .message_container {
  122. .message_info {
  123. margin: 20px 0;
  124. text-align: right;
  125. .user {
  126. // font-size: 1rem;
  127. .user_pre {
  128. font-weight: bold;
  129. }
  130. }
  131. .time {
  132. // font-size: 1rem;
  133. }
  134. }
  135. .message_attachment {
  136. .attachment {
  137. color: blue;
  138. margin-left: 5px;
  139. }
  140. }
  141. }
  142. }
  143. </style>