detail.vue 6.9 KB

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