detail.vue 6.8 KB

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