index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="page_mine">
  3. <notice-header title="我的通知"></notice-header>
  4. <view class="mine_content">
  5. <view class="tabs_bar">
  6. <text v-for="(tab, idx) in tabs" :key="idx" class="tab_item" :class="{ active: activeTab === idx }" @click="activeTab = idx">{{ tab }}</text>
  7. </view>
  8. <scroll-view scroll-y class="notice_list">
  9. <view v-for="item in noticeList" :key="item.id" class="notice_item">
  10. <view class="notice_content">
  11. <view class="notice_title_row">
  12. <uni-icons type="info" size="20" color="#4A6CF7"></uni-icons>
  13. <text class="notice_title">{{ item.title }}</text>
  14. </view>
  15. <view class="notice_meta">
  16. <text class="status_tag" :class="item.statusClass">{{ item.status }}</text>
  17. <text class="meta_text">{{ item.category }}</text>
  18. <text class="meta_text">{{ item.department }}</text>
  19. <text class="meta_text">{{ item.time }}</text>
  20. </view>
  21. </view>
  22. <view class="notice_stats">
  23. <text class="stats_text">已读: {{ item.readCount }}人</text>
  24. <text class="stats_text">未读: {{ item.unreadCount }}人</text>
  25. </view>
  26. <view class="notice_actions">
  27. <text v-if="item.status === '待发布'" class="action_btn delete" @click="handleDelete(item.id)">删除</text>
  28. <text v-if="item.status !== '已关闭'" class="action_btn edit" @click="handleEdit(item.id)">编辑</text>
  29. <text class="action_btn detail" :class="{ disabled: item.status === '待发布' }" @click="handleDetail(item.id)">详情</text>
  30. </view>
  31. </view>
  32. <view v-if="noticeList.length === 0" class="no_data">
  33. <text class="no_data_text">暂无通知</text>
  34. </view>
  35. </scroll-view>
  36. </view>
  37. <common-tabbar></common-tabbar>
  38. </view>
  39. </template>
  40. <script setup>
  41. import { ref } from 'vue';
  42. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  43. import NoticeHeader from '@/components/notice-header.vue';
  44. const tabs = ['全部', '待发布', '已发布', '已关闭'];
  45. const activeTab = ref(0);
  46. const noticeList = ref([
  47. {
  48. id: '1',
  49. title: '25-26学年第一学期初一期中考试安排通知',
  50. status: '已发布',
  51. statusClass: 'status-published',
  52. category: '教学教务',
  53. department: '教务处',
  54. time: '2024-06-03 18:00:00',
  55. readCount: 1500,
  56. unreadCount: 50
  57. },
  58. {
  59. id: '2',
  60. title: '关于开展教师培训的通知',
  61. status: '已发布',
  62. statusClass: 'status-published',
  63. category: '教师培训',
  64. department: '人事处',
  65. time: '2024-06-02 10:00:00',
  66. readCount: 280,
  67. unreadCount: 15
  68. },
  69. {
  70. id: '3',
  71. title: '暑期放假安排通知',
  72. status: '待发布',
  73. statusClass: 'status-pending',
  74. category: '学校通知',
  75. department: '校长办公室',
  76. time: '2024-06-01 09:00:00',
  77. readCount: 0,
  78. unreadCount: 0
  79. }
  80. ]);
  81. const goBack = () => {
  82. uni.navigateBack();
  83. };
  84. const handleDelete = (id) => {
  85. uni.showModal({
  86. title: '确认删除',
  87. content: '确定要删除这条通知吗?',
  88. success: (res) => {
  89. if (res.confirm) {
  90. noticeList.value = noticeList.value.filter(item => item.id !== id);
  91. uni.showToast({ title: '删除成功', icon: 'success' });
  92. }
  93. }
  94. });
  95. };
  96. const handleEdit = (id) => {
  97. uni.navigateTo({ url: `/pages/notice/publish/index?id=${id}` });
  98. };
  99. const handleDetail = (id) => {
  100. const item = noticeList.value.find(item => item.id === id);
  101. if (item && item.status === '待发布') {
  102. uni.showToast({ title: '待发布通知暂无法查看详情', icon: 'none' });
  103. return;
  104. }
  105. uni.showToast({ title: `查看详情: ${id}`, icon: 'none' });
  106. };
  107. </script>
  108. <style lang="scss">
  109. .page_mine {
  110. min-height: 100vh;
  111. background-color: #F5F5F5;
  112. padding-bottom: 120rpx;
  113. }
  114. .mine_content {
  115. padding-top: 100rpx;
  116. }
  117. .tabs_bar {
  118. display: flex;
  119. padding: 20rpx 24rpx;
  120. background-color: #FFFFFF;
  121. gap: 40rpx;
  122. .tab_item {
  123. font-size: 28rpx;
  124. color: #666666;
  125. position: relative;
  126. &.active {
  127. color: #2E64FA;
  128. font-weight: 600;
  129. &::after {
  130. content: '';
  131. position: absolute;
  132. bottom: -16rpx;
  133. left: 0;
  134. right: 0;
  135. height: 4rpx;
  136. background-color: #2E64FA;
  137. border-radius: 2rpx;
  138. }
  139. }
  140. }
  141. }
  142. .notice_list {
  143. height: calc(100vh - 320rpx);
  144. padding: 16rpx 24rpx;
  145. }
  146. .notice_item {
  147. background-color: #FFFFFF;
  148. border-radius: 12rpx;
  149. padding: 20rpx;
  150. margin-bottom: 16rpx;
  151. .notice_content {
  152. .notice_title_row {
  153. display: flex;
  154. align-items: flex-start;
  155. margin-bottom: 12rpx;
  156. .notice_title {
  157. flex: 1;
  158. font-size: 28rpx;
  159. color: #333333;
  160. font-weight: 500;
  161. margin-left: 8rpx;
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. white-space: nowrap;
  165. }
  166. }
  167. .notice_meta {
  168. display: flex;
  169. align-items: center;
  170. flex-wrap: wrap;
  171. gap: 12rpx;
  172. .status_tag {
  173. font-size: 22rpx;
  174. padding: 4rpx 12rpx;
  175. border-radius: 4rpx;
  176. &.status-pending {
  177. background-color: rgba(74, 108, 247, 0.1);
  178. color: #4A6CF7;
  179. }
  180. &.status-published {
  181. background-color: rgba(82, 196, 26, 0.1);
  182. color: #52C41A;
  183. }
  184. &.status-closed {
  185. background-color: rgba(245, 108, 108, 0.1);
  186. color: #F56C6C;
  187. }
  188. }
  189. .meta_text {
  190. font-size: 24rpx;
  191. color: #999999;
  192. }
  193. }
  194. }
  195. .notice_stats {
  196. display: flex;
  197. margin-top: 12rpx;
  198. padding-top: 12rpx;
  199. border-top: 1rpx dashed #E8E8E8;
  200. .stats_text {
  201. font-size: 24rpx;
  202. color: #999999;
  203. &:first-child {
  204. margin-right: 24rpx;
  205. }
  206. }
  207. }
  208. .notice_actions {
  209. display: flex;
  210. justify-content: flex-end;
  211. gap: 16rpx;
  212. margin-top: 16rpx;
  213. .action_btn {
  214. font-size: 24rpx;
  215. padding: 8rpx 24rpx;
  216. border-radius: 8rpx;
  217. &.delete {
  218. background-color: rgba(245, 108, 108, 0.1);
  219. color: #F56C6C;
  220. }
  221. &.edit {
  222. background-color: rgba(74, 108, 247, 0.1);
  223. color: #4A6CF7;
  224. }
  225. &.detail {
  226. background-color: #2E64FA;
  227. color: #FFFFFF;
  228. &.disabled {
  229. background-color: #CCCCCC;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. .no_data {
  236. display: flex;
  237. flex-direction: column;
  238. align-items: center;
  239. padding: 100rpx 0;
  240. .no_data_text {
  241. font-size: 28rpx;
  242. color: #999999;
  243. }
  244. }
  245. .mine_tabbar {
  246. position: fixed;
  247. bottom: 0;
  248. left: 0;
  249. right: 0;
  250. display: flex;
  251. justify-content: space-around;
  252. background-color: #FFFFFF;
  253. padding: 16rpx 0;
  254. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  255. border-top: 1rpx solid #F0F0F0;
  256. height: 84px;
  257. box-sizing: border-box;
  258. .tabbar_item {
  259. display: flex;
  260. flex-direction: column;
  261. align-items: center;
  262. justify-content: center;
  263. .tabbar_icon {
  264. width: 48rpx;
  265. height: 48rpx;
  266. }
  267. .tabbar_text {
  268. font-size: 22rpx;
  269. color: #999999;
  270. margin-top: 4rpx;
  271. }
  272. &.active {
  273. .tabbar_text {
  274. color: #2E64FA;
  275. }
  276. }
  277. }
  278. }
  279. </style>