detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. padding-bottom: env(safe-area-inset-bottom);
  105. box-sizing: border-box;
  106. }
  107. .detail_content {
  108. flex: 1;
  109. display: flex;
  110. flex-direction: column;
  111. overflow: hidden;
  112. padding-top: calc(140rpx + env(safe-area-inset-top));
  113. }
  114. .detail_header {
  115. padding: 24rpx;
  116. border-bottom: 2rpx solid #F3F3F3;
  117. flex-shrink: 0;
  118. .detail_title {
  119. font-weight: 500;
  120. font-size: 32rpx;
  121. color: #333333;
  122. line-height: 1.5;
  123. margin-bottom: 24rpx;
  124. display: block;
  125. word-wrap: break-word;
  126. white-space: normal;
  127. }
  128. .detail_meta {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. .meta_left {
  133. display: flex;
  134. align-items: center;
  135. flex-wrap: wrap;
  136. gap: 16rpx;
  137. }
  138. .meta_text {
  139. font-size: 24rpx;
  140. color: #999999;
  141. }
  142. .attachment_tag {
  143. font-size: 24rpx;
  144. color: #2E64FA;
  145. padding: 8rpx 16rpx;
  146. background-color: rgba(46, 100, 250, 0.1);
  147. border-radius: 8rpx;
  148. flex-shrink: 0;
  149. }
  150. }
  151. }
  152. .detail_section {
  153. flex: 1;
  154. display: flex;
  155. flex-direction: column;
  156. overflow: hidden;
  157. .section_title {
  158. font-weight: 500;
  159. font-size: 28rpx;
  160. color: #333333;
  161. padding: 24rpx;
  162. display: block;
  163. flex-shrink: 0;
  164. }
  165. .section_scroll_wrapper {
  166. flex: 1;
  167. overflow: hidden;
  168. padding: 0 24rpx 90rpx 24rpx;
  169. box-sizing: border-box;
  170. .section_content {
  171. height: 100%;
  172. font-size: 28rpx;
  173. color: #333333;
  174. line-height: 1.8;
  175. :deep(p) {
  176. margin-bottom: 16rpx;
  177. }
  178. :deep(ol),
  179. :deep(ul) {
  180. padding-left: 32rpx;
  181. margin-bottom: 16rpx;
  182. }
  183. :deep(li) {
  184. margin-bottom: 8rpx;
  185. }
  186. }
  187. }
  188. }
  189. .attachment_modal {
  190. position: fixed;
  191. top: 0;
  192. left: 0;
  193. right: 0;
  194. bottom: 0;
  195. background-color: rgba(0, 0, 0, 0.5);
  196. display: flex;
  197. align-items: flex-end;
  198. z-index: 1000;
  199. .modal_content {
  200. width: 100%;
  201. background-color: #FFFFFF;
  202. border-radius: 24rpx 24rpx 0 0;
  203. max-height: 70vh;
  204. display: flex;
  205. flex-direction: column;
  206. .modal_header {
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. padding: 32rpx;
  211. border-bottom: 2rpx solid #F3F3F3;
  212. .modal_title {
  213. font-weight: 500;
  214. font-size: 32rpx;
  215. color: #333333;
  216. }
  217. .modal_close {
  218. width: 64rpx;
  219. height: 64rpx;
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. font-size: 48rpx;
  224. color: #999999;
  225. }
  226. }
  227. .modal_list_wrapper {
  228. flex: 1;
  229. overflow: hidden;
  230. padding: 24rpx;
  231. box-sizing: border-box;
  232. .modal_list {
  233. height: 100%;
  234. .attachment_item {
  235. display: flex;
  236. align-items: center;
  237. padding: 24rpx;
  238. background-color: #F5F7FA;
  239. border-radius: 12rpx;
  240. margin-bottom: 16rpx;
  241. .file_icon {
  242. width: 80rpx;
  243. height: 80rpx;
  244. margin-right: 20rpx;
  245. flex-shrink: 0;
  246. }
  247. .file_info {
  248. flex: 1;
  249. overflow: hidden;
  250. .file_name {
  251. font-size: 28rpx;
  252. color: #333333;
  253. display: block;
  254. white-space: nowrap;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. }
  258. }
  259. .preview_btn {
  260. font-size: 28rpx;
  261. color: #2E64FA;
  262. margin-left: 20rpx;
  263. flex-shrink: 0;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. }
  270. </style>