index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="detail_container">
  4. <uni-card>
  5. <template v-slot:title>
  6. <view class="message_title">
  7. {{ msgInfo.title }}
  8. </view>
  9. </template>
  10. <view class="message_container">
  11. <uni-card :border="false" :is-shadow="false" spacing="0px" margin="0px">
  12. <view class="message_contant">
  13. <u-parse :content="msgInfo.content" :selectable="true" @navigate="parseNavigate">
  14. </u-parse>
  15. </view>
  16. <view class="message_info">
  17. <uni-row :gutter="20">
  18. <uni-col :xs="{ span: 24 }" :sm="{ span: 16, offset: 1 }">
  19. <view class="user">
  20. <text class="user_pre">发布者:</text>
  21. {{ msgInfo.name }}
  22. </view>
  23. </uni-col>
  24. <uni-col :xs="{ span: 24 }" :sm="6">
  25. <view class="time">
  26. 发布时间:{{ msgInfo.sendTime }}
  27. </view>
  28. </uni-col>
  29. </uni-row>
  30. </view>
  31. </uni-card>
  32. </view>
  33. </uni-card>
  34. <uni-card v-if="attachments.length > 0">
  35. <view class="file_list">
  36. <uni-section title="附件" type="line" titleFontSize="1rem"></uni-section>
  37. <view>
  38. <attachment-list :attachments="attachments"></attachment-list>
  39. </view>
  40. </view>
  41. </uni-card>
  42. </view>
  43. <view style="height: 5px; margin-top: 20px;"></view>
  44. </template>
  45. <script setup lang="ts">
  46. import { onLoad ,onShareAppMessage ,onReady} from '@dcloudio/uni-app';
  47. import { onMounted, ref } from 'vue';
  48. import { getNoticeInfo, getMessageInfo } from '@/api/message';
  49. import $tab from '@/plugins/tab';
  50. import $modal from '@/plugins/modal.js'
  51. import uParse from '@/components/gaoyia-parse/parse.vue'
  52. import attachmentList from '@/components/ygoa/attachmentList.vue'
  53. import { useUserStore } from '@/store/user';
  54. const userStore = useUserStore();
  55. const type = ref(-1);
  56. const noticeId = ref('');
  57. const universalId = ref('');
  58. const messageId = ref('');
  59. onLoad((options) => {
  60. if (options.noticeId) {
  61. type.value = 0
  62. noticeId.value = options.noticeId;
  63. } else {
  64. type.value = 1
  65. universalId.value = options.universalId;
  66. messageId.value = options.messageId;
  67. }
  68. })
  69. onReady(()=> {
  70. // 根据 noticeId 来决定是否显示分享按钮
  71. if (noticeId.value) {
  72. uni.showShareMenu()
  73. } else {
  74. uni.hideShareMenu()
  75. }
  76. })
  77. onShareAppMessage((res) => {
  78. if (noticeId.value) {
  79. return {
  80. title: msgInfo.value.title,
  81. path: '/pages/message/index?noticeId='+noticeId.value,
  82. };
  83. } else {
  84. return { title: '', path: '' }; // 不允许分享时,返回空的标题和路径
  85. }
  86. })
  87. const msgInfo = ref({
  88. title:'',
  89. sendTime:'',
  90. name:'',
  91. content:''})
  92. const attachments = ref([]);//附件
  93. //公告详情
  94. function showNoticeInfo(id) {
  95. const params = {
  96. userId: userStore.user.useId, //当前用户id
  97. noticeId: id
  98. }
  99. getNoticeInfo(params).then(({ returnParams }) => {
  100. // console.log('returnParams', returnParams);
  101. msgInfo.value = {
  102. title: returnParams.title,
  103. sendTime: returnParams.sendTime,
  104. name: returnParams.name,
  105. content: returnParams.noticeContent
  106. }
  107. attachments.value = returnParams.affixUrl;
  108. })
  109. }
  110. //消息详情
  111. function showMessageInfo({ universalId, messageId }) {
  112. const params = {
  113. universalId: universalId,
  114. messageId: messageId
  115. }
  116. getMessageInfo(params).then(({ returnParams }) => {
  117. msgInfo.value = {
  118. title: returnParams.title,
  119. sendTime: returnParams.sendtime,
  120. name: returnParams.name,
  121. content: returnParams.content,
  122. }
  123. attachments.value = returnParams.fileList;
  124. })
  125. }
  126. onMounted(() => {
  127. switch (type.value) {
  128. case 0:
  129. showNoticeInfo(noticeId.value);
  130. break;
  131. case 1:
  132. showMessageInfo({ universalId: universalId.value, messageId: messageId.value });
  133. break;
  134. }
  135. })
  136. // 超链接 跳转
  137. function parseNavigate(href, e) {
  138. $tab.navigateTo('./URLView?url=' + encodeURIComponent(href));
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .detail_container {
  143. .message_title {
  144. text-align: center;
  145. font-size: calc(1.5rem + 0px);
  146. font-weight: bold;
  147. margin-top: 5px;
  148. }
  149. .message_container {
  150. .message_contant {
  151. ::v-deep .wxParse {
  152. font-size: calc(0.875rem + 0px);
  153. }
  154. }
  155. .message_info {
  156. margin: 20px 0;
  157. text-align: right;
  158. .user {
  159. font-size: calc(0.875rem + 0px);
  160. .user_pre {
  161. font-weight: bold;
  162. }
  163. }
  164. .time {
  165. margin-top:calc(0.625px * (1rem - 16px));
  166. font-size: calc(0.875rem + 0px);
  167. }
  168. }
  169. }
  170. ::v-deep .file_list {
  171. .uni-section .uni-section-header {
  172. margin-left: -10px;
  173. }
  174. .message_attachment {
  175. .attachment {
  176. color: #2196f3;
  177. margin-left: 5px;
  178. font-size: calc(14px + .5*(1rem - 16px)) !important;
  179. }
  180. }
  181. }
  182. }
  183. </style>