index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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_attachment">
  19. <uni-section class="mb-10" title="附件" type="line">
  20. </uni-section>
  21. <uni-row :gutter="0">
  22. <uni-col v-for="(attachment, index) in attachments" :key="index" :xs="{span: 24}" :sm="6">
  23. <view class="attachment">
  24. <text
  25. @click="seeAttachment(attachment.path)">{{ attachment.fileName || '空' }}</text>
  26. </view>
  27. </uni-col>
  28. </uni-row>
  29. </view> -->
  30. <view class="message_info">
  31. <uni-row :gutter="20">
  32. <uni-col :xs="{span: 24}" :sm="{span: 16, offset: 1}">
  33. <view class="user">
  34. <text class="user_pre">发布者:</text>
  35. {{msgInfo.name}}
  36. </view>
  37. </uni-col>
  38. <uni-col :xs="{span: 24}" :sm="6">
  39. <view class="time">
  40. 发布时间:{{msgInfo.sendTime}}
  41. </view>
  42. </uni-col>
  43. </uni-row>
  44. </view>
  45. </uni-card>
  46. </view>
  47. </uni-card>
  48. </view>
  49. </template>
  50. <script setup lang="ts">
  51. import { onLoad } from '@dcloudio/uni-app';
  52. import { onMounted, reactive, ref } from 'vue';
  53. import $tab from '@/plugins/tab';
  54. import uParse from '@/components/gaoyia-parse/parse.vue'
  55. import { GetNoticeInfo, GetMessageInfo } from '@/api/message';
  56. import { useUserStore } from '@/store/user';
  57. import attachmentList from '@/components/ygoa/attachmentList.vue'
  58. const userStore = useUserStore();
  59. const type = ref(-1);
  60. const noticeId = ref('');
  61. const universalId = ref('');
  62. const messageId = ref('');
  63. onLoad((options) => {
  64. switch (options.type) {
  65. case '0':
  66. type.value = 0
  67. noticeId.value = options.noticeId;
  68. break;
  69. case '1':
  70. type.value = 1
  71. universalId.value = options.universalId;
  72. messageId.value = options.messageId;
  73. break;
  74. }
  75. })
  76. const msgInfo = ref({
  77. title: '标题',
  78. sendTime: '2024-1-1',
  79. name: '管理员',
  80. content: '',
  81. // attachment:'附件',
  82. })
  83. const attachments = ref([]);//附件
  84. const message = ref('');
  85. //公告详情
  86. function showNoticeInfo(id) {
  87. const params = {
  88. userId: userStore.user.useId, //当前用户id
  89. noticeId: id
  90. }
  91. GetNoticeInfo(params).then(({ returnParams }) => {
  92. // console.log('returnParams', returnParams);
  93. msgInfo.value = {
  94. title: returnParams.title,
  95. sendTime: returnParams.sendTime,
  96. name: returnParams.name,
  97. content: returnParams.noticeContent,
  98. }
  99. if (returnParams.affixUrl) {
  100. attachments.value = returnParams.affixUrl;
  101. console.log(attachments.value);
  102. }
  103. })
  104. }
  105. //消息详情
  106. function showMessageInfo({ universalId, messageId }) {
  107. const params = {
  108. universalId: universalId,
  109. messageId: messageId
  110. }
  111. GetMessageInfo(params).then(({ returnParams }) => {
  112. msgInfo.value = {
  113. title: returnParams.title,
  114. sendTime: returnParams.sendtime,
  115. name: returnParams.name,
  116. content: returnParams.content,
  117. }
  118. })
  119. }
  120. //预览文件
  121. // function seeAttachment(path) {
  122. // // console.log('path',path);
  123. // $tab.navigateTo('./URLView?type=doc&url=' + encodeURIComponent(path));
  124. // }
  125. onMounted(() => {
  126. switch (type.value) {
  127. case 0:
  128. showNoticeInfo(noticeId.value);
  129. break;
  130. case 1:
  131. showMessageInfo({ universalId: universalId.value, messageId: messageId.value });
  132. break;
  133. }
  134. // message.value = "<p>正文<br><br></p><h1>H1内容</h1><h2>H2内容</h2><h3>H3内容</h3><h4>H4内容</h4><h5>H5内容</h5><a href=\"https://www.douyin.com/user/MS4wLjABAAAAoT36HajHfEPMCVKeiukoxGkYU0k0s0NA5khixKqH5Pk\" target=\"_blank\">链接地址</a><p style=\"text-align: left;\">链接图片<img src=\"https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png\" alt=\"链接图片\" data-href=\"\" style=\"\"></p><blockquote>引用</blockquote><p><strong>加粗</strong></p><p><u>下划线</u></p><p><em>倾斜</em></p><p><u><strong>加粗+下划线</strong></u></p><p><em><strong>加粗+倾斜</strong></em></p><p><u><em>下划线+倾斜</em></u></p><p><s>删除线</s></p><p><code>行内代码</code></p><p><sup>上标</sup></p><p><sub>下标</sub></p><p><s><code>行内代码+删除线</code></s></p><p><s><u><em><code><strong>加粗+下划线+倾斜+删除线+行内代码</strong></code></em></u></s></p><p><span style=\"color: rgb(225, 60, 57);\">红色文字</span></p><p><span style=\"color: rgb(255, 236, 61);\">黄色文字</span></p><p><span style=\"color: rgb(66, 144, 247);\"><s><u><em><code><strong>蓝色文字+加粗+下划线+倾斜+删除线+行内代码</strong></code></em></u></s></span></p><p><span style=\"color: rgb(0, 0, 0); background-color: rgb(255,255,0);\">黄色背景</span></p><p><span style=\"color: rgb(9, 109, 217); background-color: rgb(255,0,0);\"><s><u><em><code><strong>红色背景+蓝色文字+加粗+下划线+倾斜+删除线+行内代码</strong></code></em></u></s></span></p><p><span style=\"font-size: 12px;\">12px字号</span><span style=\"font-size: 32px;\">32px字号</span></p><p><span style=\"font-size: 14px;\">14px字号</span><span style=\"font-size: 48px;\">48px字号</span></p><p><span style=\"font-family: 仿宋;\">仿宋 </span><span style=\"font-family: 宋体;\">宋体</span></p><p style=\"line-height: 3;\"><span style=\"font-family: 宋体;\">3行高 </span></p><p style=\"line-height: 2;\"><span style=\"font-family: 宋体;\">2行高</span></p><ul><li><span style=\"font-family: 宋体;\">无序列表</span></li><li><span style=\"font-family: 宋体;\">无序列表</span></li></ul><ol><li><span style=\"font-family: 宋体;\">有序列表</span></li><li><span style=\"font-family: 宋体;\">有序列表</span></li></ol><div data-w-e-type=\"todo\"><input type=\"checkbox\" disabled ><span style=\"font-family: 宋体;\">待办</span></div><div data-w-e-type=\"todo\"><input type=\"checkbox\" disabled ><span style=\"font-family: 宋体;\">待办</span></div><p style=\"text-align: left;\"><span style=\"font-family: 宋体;\">左对齐</span></p><p style=\"text-align: right;\"><span style=\"font-family: 宋体;\">右对齐</span></p><p style=\"text-align: center;\"><span style=\"font-family: 宋体;\">居中</span></p><p style=\"text-align: justify;\"><span style=\"font-family: 宋体;\">两侧对齐</span></p><p style=\"text-indent: 2em; text-align: left;\"><span style=\"font-family: 宋体;\">增加缩进</span></p><p style=\"text-align: left;\"><span style=\"font-family: 宋体;\">\uD83D\uDE00表情</span></p><p style=\"text-align: left;\"><span style=\"font-family: 宋体;\"> </span> </p><p style=\"text-align: left;\">100图片<img src=\"https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png\" alt=\"图片描述\" data-href=\"\" style=\"\"></p><p style=\"text-align: left;\">50图片<img src=\"https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png\" alt=\"\" data-href=\"\" style=\"width: 50%;\"></p><p style=\"text-align: left;\">30图片<img src=\"https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png\" alt=\"\" data-href=\"\" style=\"width: 30%;\"></p><table style=\"width: auto;\"><tbody><tr><th colSpan=\"1\" rowSpan=\"1\" width=\"auto\">表格</th><th colSpan=\"1\" rowSpan=\"1\" width=\"auto\">表格</th></tr><tr><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">表格</td><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">表格</td></tr><tr><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">表格</td><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\"><img src=\"https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png\" alt=\"\" data-href=\"\" style=\"width: 30%;\"/>表格30图片</td></tr></tbody></table><pre><code class=\"language-css\">代码块 css语言\n代码块</code></pre><p>分割线</p><hr/><p>分割线</p>"
  135. })
  136. // 超链接 跳转
  137. function parseNavigate(href, e) {
  138. $tab.navigateTo('./URLView?url=' + encodeURIComponent(href));
  139. }
  140. </script>
  141. <style lang="scss">
  142. .detail_container {
  143. .message_title {
  144. text-align: center;
  145. font-size: 1.5rem;
  146. font-weight: bold;
  147. margin-top: 5px;
  148. }
  149. .message_container {
  150. .message_info {
  151. margin: 20px 0;
  152. text-align: right;
  153. .user {
  154. // font-size: 1rem;
  155. .user_pre {
  156. font-weight: bold;
  157. }
  158. }
  159. .time {
  160. // font-size: 1rem;
  161. }
  162. }
  163. .message_attachment {
  164. .attachment {
  165. color: blue;
  166. margin-left: 5px;
  167. }
  168. }
  169. }
  170. }
  171. </style>