noticeDetail.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="sub-page">
  3. <TopBar title="公告详情" showBack />
  4. <view class="px-4 pt-3">
  5. <view v-if="notice" class="glass-card p-5">
  6. <view class="flex items-start justify-between mb-3">
  7. <text class="notice-title flex-1 mr-2">{{ notice.title }}</text>
  8. <text v-if="notice.priority >= 2" class="important-tag flex-shrink-0">重要</text>
  9. </view>
  10. <view class="meta-row mb-4">
  11. <text class="meta-text">{{ formatDate(notice.publishTime, 'YYYY-MM-DD') }}</text>
  12. <text class="meta-text mx-2">|</text>
  13. <text class="meta-text">{{ notice.publisherName }}</text>
  14. </view>
  15. <view class="notice-body">
  16. <text class="body-p">{{ notice.content }}</text>
  17. </view>
  18. </view>
  19. <EmptyState v-else message="公告不存在" icon="" />
  20. </view>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref } from 'vue'
  25. import { onLoad } from '@dcloudio/uni-app'
  26. import TopBar from '../../components/common/TopBar.vue'
  27. import EmptyState from '../../components/common/EmptyState.vue'
  28. import { getNoticeDetail } from '../../api/notice'
  29. import { formatDate } from '../../utils'
  30. const notice = ref<any>(null)
  31. onLoad(async (options) => {
  32. if (!options?.id) return
  33. try {
  34. notice.value = await getNoticeDetail(Number(options.id))
  35. } catch (error) {
  36. console.error('获取通知详情失败:', error)
  37. }
  38. })
  39. </script>
  40. <style scoped>
  41. .sub-page {
  42. max-width: 430px;
  43. margin: 0 auto;
  44. min-height: 100vh;
  45. background-color: #f6fbf9;
  46. padding-bottom: 24px;
  47. }
  48. .glass-card {
  49. background-color: rgba(255, 255, 255, 0.85);
  50. backdrop-filter: blur(14px);
  51. -webkit-backdrop-filter: blur(14px);
  52. border: 1px solid rgba(164, 216, 152, 0.35);
  53. border-radius: 24px;
  54. box-shadow: 0 18px 50px -12px rgba(54, 143, 111, 0.28);
  55. overflow: hidden;
  56. margin-bottom: 12px;
  57. }
  58. .notice-title {
  59. font-size: 17px;
  60. font-weight: 700;
  61. color: #1f2937;
  62. line-height: 1.4;
  63. }
  64. .important-tag {
  65. padding: 2px 10px;
  66. border-radius: 999px;
  67. font-size: 11px;
  68. font-weight: 600;
  69. color: #ef4444;
  70. background-color: rgba(239, 68, 68, 0.1);
  71. }
  72. .meta-row {
  73. display: flex;
  74. align-items: center;
  75. padding-bottom: 12px;
  76. border-bottom: 1px solid rgba(164, 216, 152, 0.18);
  77. }
  78. .meta-text {
  79. font-size: 12px;
  80. color: #9ca3af;
  81. }
  82. .notice-body {
  83. padding-top: 4px;
  84. }
  85. .body-p {
  86. display: block;
  87. margin-bottom: 12px;
  88. font-size: 14px;
  89. line-height: 1.8;
  90. color: #4b5563;
  91. }
  92. .body-item {
  93. display: block;
  94. margin-bottom: 8px;
  95. font-size: 14px;
  96. line-height: 1.8;
  97. color: #4b5563;
  98. }
  99. .body-sign {
  100. display: block;
  101. text-align: right;
  102. font-size: 13px;
  103. line-height: 1.8;
  104. color: #6b7280;
  105. }
  106. </style>