detail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="page_detail">
  3. <common-header title="消息通知" @back="goBack"></common-header>
  4. <view class="detail_content">
  5. <view class="detail_header">
  6. <text class="detail_title">{{ noticeDetail.noticeName }}</text>
  7. <view class="detail_meta">
  8. <view class="meta_left">
  9. <text class="meta_text">{{ noticeDetail.typeName }}</text>
  10. <text class="meta_text">{{ noticeDetail.createTeacherName }}</text>
  11. <text class="meta_text">{{ noticeDetail.releaseTime }}</text>
  12. </view>
  13. <view class="attachment_tag" v-if="noticeDetail.noticeFiles.length > 0" @click="showAttachmentModal = true">
  14. <text>附件: {{ noticeDetail.noticeFiles.length }}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="detail_section">
  19. <text class="section_title">通知内容</text>
  20. <view class="section_scroll_wrapper">
  21. <scroll-view scroll-y class="section_content">
  22. <rich-text :nodes="noticeDetail.noticeContent"></rich-text>
  23. </scroll-view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="attachment_modal" v-if="showAttachmentModal" @click="showAttachmentModal = false">
  28. <view class="modal_content" @click.stop>
  29. <view class="modal_header">
  30. <text class="modal_title">查看附件</text>
  31. <view class="modal_close" @click="showAttachmentModal = false">
  32. <text>×</text>
  33. </view>
  34. </view>
  35. <view class="modal_list_wrapper">
  36. <scroll-view scroll-y class="modal_list">
  37. <view class="attachment_item" v-for="(file, index) in noticeDetail.noticeFiles" :key="index">
  38. <image class="file_icon" src="/static/image/icon/file.png" mode="aspectFit"></image>
  39. <view class="file_info">
  40. <text class="file_name">{{ file.attachmentName }}</text>
  41. </view>
  42. <text class="preview_btn" @click="previewFile(file)">预览</text>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script setup>
  51. import { ref } from 'vue';
  52. import { onLoad } from '@dcloudio/uni-app';
  53. import CommonHeader from '@/components/common-header.vue';
  54. import overviewApi from '@/reqApi/overview.js';
  55. const noticeDetail = ref({
  56. noticeName: '',
  57. typeName: '',
  58. createTeacherName: '',
  59. releaseTime: '',
  60. noticeFiles: [],
  61. noticeContent: ''
  62. });
  63. const showAttachmentModal = ref(false);
  64. const previewFile = (file) => {
  65. if (file.attachmentUrl) {
  66. uni.navigateTo({
  67. url: `/pages/notice/mine/preview?url=${encodeURIComponent(file.attachmentUrl)}&name=${encodeURIComponent(file.attachmentName || '文件预览')}`
  68. });
  69. } else {
  70. uni.showToast({
  71. title: '附件链接为空',
  72. icon: 'none'
  73. });
  74. }
  75. };
  76. const fetchDetail = async (id) => {
  77. try {
  78. const res = await overviewApi.notices_detail({ id });
  79. if (res.data) {
  80. noticeDetail.value = {
  81. ...res.data,
  82. noticeFiles: Array.isArray(res.data.noticeFiles) ? res.data.noticeFiles : []
  83. };
  84. }
  85. } catch (error) {
  86. console.error('获取通知详情失败:', error);
  87. }
  88. };
  89. onLoad((options) => {
  90. if (options && options.id) {
  91. fetchDetail(options.id);
  92. }
  93. });
  94. const goBack = () => {
  95. uni.navigateBack();
  96. };
  97. </script>
  98. <style lang="scss">
  99. .page_detail {
  100. height: 100vh;
  101. display: flex;
  102. flex-direction: column;
  103. background-color: #FFFFFF;
  104. box-sizing: border-box;
  105. }
  106. .detail_content {
  107. flex: 1;
  108. display: flex;
  109. flex-direction: column;
  110. overflow: hidden;
  111. }
  112. .detail_header {
  113. padding: 24rpx;
  114. border-bottom: 2rpx solid #F3F3F3;
  115. flex-shrink: 0;
  116. .detail_title {
  117. font-weight: 500;
  118. font-size: 32rpx;
  119. color: #333333;
  120. line-height: 1.5;
  121. margin-bottom: 24rpx;
  122. display: block;
  123. word-wrap: break-word;
  124. white-space: normal;
  125. }
  126. .detail_meta {
  127. display: flex;
  128. align-items: center;
  129. justify-content: space-between;
  130. .meta_left {
  131. display: flex;
  132. align-items: center;
  133. flex-wrap: wrap;
  134. gap: 16rpx;
  135. }
  136. .meta_text {
  137. font-size: 24rpx;
  138. color: #999999;
  139. }
  140. .attachment_tag {
  141. font-size: 24rpx;
  142. color: #2E64FA;
  143. padding: 8rpx 16rpx;
  144. background-color: rgba(46, 100, 250, 0.1);
  145. border-radius: 8rpx;
  146. flex-shrink: 0;
  147. }
  148. }
  149. }
  150. .detail_section {
  151. flex: 1;
  152. display: flex;
  153. flex-direction: column;
  154. overflow: hidden;
  155. .section_title {
  156. font-weight: 500;
  157. font-size: 28rpx;
  158. color: #333333;
  159. padding: 24rpx;
  160. display: block;
  161. flex-shrink: 0;
  162. }
  163. .section_scroll_wrapper {
  164. flex: 1;
  165. overflow: hidden;
  166. padding: 0 24rpx 90rpx 24rpx;
  167. box-sizing: border-box;
  168. .section_content {
  169. height: 100%;
  170. font-size: 28rpx;
  171. color: #333333;
  172. line-height: 1.8;
  173. :deep(p) {
  174. margin-bottom: 16rpx;
  175. }
  176. :deep(ol),
  177. :deep(ul) {
  178. padding-left: 32rpx;
  179. margin-bottom: 16rpx;
  180. }
  181. :deep(li) {
  182. margin-bottom: 8rpx;
  183. }
  184. }
  185. }
  186. }
  187. .attachment_modal {
  188. position: fixed;
  189. top: 0;
  190. left: 0;
  191. right: 0;
  192. bottom: 0;
  193. background-color: rgba(0, 0, 0, 0.5);
  194. display: flex;
  195. align-items: flex-end;
  196. z-index: 1000;
  197. .modal_content {
  198. width: 100%;
  199. background-color: #FFFFFF;
  200. border-radius: 24rpx 24rpx 0 0;
  201. max-height: 70vh;
  202. display: flex;
  203. flex-direction: column;
  204. .modal_header {
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. padding: 32rpx;
  209. border-bottom: 2rpx solid #F3F3F3;
  210. .modal_title {
  211. font-weight: 500;
  212. font-size: 32rpx;
  213. color: #333333;
  214. }
  215. .modal_close {
  216. width: 64rpx;
  217. height: 64rpx;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. font-size: 48rpx;
  222. color: #999999;
  223. }
  224. }
  225. .modal_list_wrapper {
  226. flex: 1;
  227. overflow: hidden;
  228. padding: 24rpx;
  229. box-sizing: border-box;
  230. .modal_list {
  231. height: 100%;
  232. .attachment_item {
  233. display: flex;
  234. align-items: center;
  235. padding: 24rpx;
  236. background-color: #F5F7FA;
  237. border-radius: 12rpx;
  238. margin-bottom: 16rpx;
  239. .file_icon {
  240. width: 80rpx;
  241. height: 80rpx;
  242. margin-right: 20rpx;
  243. flex-shrink: 0;
  244. }
  245. .file_info {
  246. flex: 1;
  247. overflow: hidden;
  248. .file_name {
  249. font-size: 28rpx;
  250. color: #333333;
  251. display: block;
  252. white-space: nowrap;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. }
  256. }
  257. .preview_btn {
  258. font-size: 28rpx;
  259. color: #2E64FA;
  260. margin-left: 20rpx;
  261. flex-shrink: 0;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. </style>