index.vue 3.6 KB

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