index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="page_mine" :style="{paddingTop: statusBarHeight + 322 + 'rpx', paddingBottom: safeAreaBottom + 160 + 'rpx' }">
  3. <notice-header title="我的通知" :showSearch="true" :showFilter="true" :showTabs="true" :tabs="tabs"
  4. :activeTab="activeTab" tabMode="index" @tabChange="handleTabChange" @typeChange="handleTypeChange" @timeChange="handleTimeChange" @searchChange="handleSearchChange"></notice-header>
  5. <view class="notice_content">
  6. <view class="notice_list">
  7. <scroll-view scroll-y v-for="item in noticeList" :key="item.id" class="notice_item">
  8. <view class="item_content" @click="handleDetail(item.id)">
  9. <view class="notice_title_row">
  10. <image class="notice_icon" :src="item.icon" mode="aspectFit"></image>
  11. <text class="notice_title">{{ item.title }}</text>
  12. <image src="/static/image/icon/xiala.png" class="arrow_icon"></image>
  13. </view>
  14. <view class="notice_meta">
  15. <view class="meta_left">
  16. <text class="meta_text">{{ item.category }}</text>
  17. <text class="meta_text">{{ item.department }}</text>
  18. <text class="meta_text">{{ item.time }}</text>
  19. </view>
  20. <view class="status_tag" :class="item.statusClass">
  21. <text>{{ item.status }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </scroll-view>
  26. <no-data v-if="noticeList.length === 0" centered text="暂无通知" />
  27. </view>
  28. </view>
  29. <common-tabbar v-if="showTabbar"></common-tabbar>
  30. </view>
  31. </template>
  32. <script setup>
  33. import { ref } from 'vue';
  34. import { onShow, onLoad } from '@dcloudio/uni-app';
  35. import NoticeHeader from '@/components/notice-header.vue';
  36. import NoData from '@/components/no-data.vue';
  37. import overviewApi from '@/reqApi/overview.js';
  38. import { useSafeArea } from '@/common/safeArea';
  39. const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
  40. const tabs = ['全部', '未读', '已读'];
  41. const activeTab = ref(0);
  42. const readStatusMap = [-1, 0, 1];
  43. const typeId = ref('0');
  44. const timeType = ref(0);
  45. const word = ref('');
  46. const showTabbar = ref(true);
  47. const noticeList = ref([]);
  48. const getDeleteClass = (item) => {
  49. if (item.noticeStatus !== 2) {
  50. return 'delete disabled';
  51. }
  52. return 'delete';
  53. };
  54. const fetchNoticeList = async () => {
  55. try {
  56. const params = {
  57. readStatus: readStatusMap[activeTab.value],
  58. pageParam: {
  59. pageNum: 1,
  60. pageSize: 9999
  61. },
  62. typeId: typeId.value,
  63. timeType: timeType.value,
  64. word: word.value
  65. };
  66. const res = await overviewApi.teacher_notices_page(params);
  67. if (res.data.records && res.data.records[0] && res.data.records[0].noticePageVOList) {
  68. noticeList.value = res.data.records[0].noticePageVOList.map(item => ({
  69. id: item.id,
  70. title: item.noticeName,
  71. status: item.readStatus === 1 ? '已读' : '未读',
  72. noticeStatus: item.readStatus,
  73. statusClass: item.readStatus === 1 ? 'status-published' : 'status-closed',
  74. category: item.typeName,
  75. department: item.createTeacherName,
  76. time: item.releaseTime,
  77. readCount: item.readNum,
  78. unreadCount: item.unReadNum,
  79. icon: '/static/image/todo/xiaoxi.png'
  80. }));
  81. } else {
  82. noticeList.value = [];
  83. }
  84. } catch (error) {
  85. console.error('获取通知列表失败:', error);
  86. }
  87. };
  88. onLoad((options) => {
  89. if (options && options.hideTabbar === 'true') {
  90. showTabbar.value = false;
  91. }
  92. });
  93. onShow(() => {
  94. fetchNoticeList();
  95. });
  96. const goBack = () => {
  97. uni.navigateBack();
  98. };
  99. const handleTabChange = (idx) => {
  100. activeTab.value = idx;
  101. fetchNoticeList();
  102. };
  103. const handleTypeChange = (type) => {
  104. typeId.value = type;
  105. fetchNoticeList();
  106. };
  107. const handleTimeChange = (time) => {
  108. timeType.value = time;
  109. fetchNoticeList();
  110. };
  111. const handleSearchChange = (keyword) => {
  112. word.value = keyword;
  113. fetchNoticeList();
  114. };
  115. const handleDelete = (id) => {
  116. uni.showModal({
  117. title: '确认删除',
  118. content: '确定要删除这条通知吗?',
  119. success: (res) => {
  120. if (res.confirm) {
  121. noticeList.value = noticeList.value.filter(item => item.id !== id);
  122. uni.showToast({ title: '删除成功', icon: 'success' });
  123. }
  124. }
  125. });
  126. };
  127. const handleEdit = (id) => {
  128. uni.navigateTo({ url: `/pages/notice/publish/index?id=${id}` });
  129. };
  130. const handleDetail = (id) => {
  131. uni.navigateTo({ url: `/pages/notice/mine/detail?id=${id}` });
  132. };
  133. </script>
  134. <style lang="scss">
  135. .page_mine {
  136. height: 100vh;
  137. display: flex;
  138. flex-direction: column;
  139. background-color: #FFFFFF;
  140. box-sizing: border-box;
  141. }
  142. .notice_content {
  143. flex: 1;
  144. display: flex;
  145. flex-direction: column;
  146. overflow: hidden;
  147. padding-left: 0rpx;
  148. padding-right: 0rpx;
  149. }
  150. .notice_list {
  151. flex: 1;
  152. overflow-y: auto;
  153. overflow-x: hidden;
  154. padding: 0 24rpx;
  155. display: flex;
  156. flex-direction: column;
  157. }
  158. .notice_item {
  159. background-color: #F9FAFF;
  160. border-radius: 20rpx;
  161. margin-bottom: 24rpx;
  162. border: 2rpx solid #E4E7ED;
  163. .item_content {
  164. padding: 24rpx;
  165. .notice_title_row {
  166. display: flex;
  167. align-items: center;
  168. margin-bottom: 16rpx;
  169. .notice_icon {
  170. width: 32rpx;
  171. height: 32rpx;
  172. margin-right: 16rpx;
  173. }
  174. .arrow_icon {
  175. width: 24rpx;
  176. height: 24rpx;
  177. transform: rotate(-90deg);
  178. }
  179. .notice_title {
  180. flex: 1;
  181. font-weight: 500;
  182. font-size: 28rpx;
  183. color: #333333;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. white-space: nowrap;
  187. }
  188. }
  189. .notice_meta {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. .meta_left {
  194. display: flex;
  195. align-items: center;
  196. flex-wrap: wrap;
  197. gap: 16rpx;
  198. }
  199. .status_tag {
  200. font-size: 24rpx;
  201. height: 48rpx;
  202. width: 96rpx;
  203. text-align: center;
  204. line-height: 48rpx;
  205. border-radius: 8rpx;
  206. font-weight: 400;
  207. &.status-pending {
  208. background: rgba(46, 100, 250, 0.1);
  209. color: #2E64FA;
  210. }
  211. &.status-published {
  212. background: rgba(82, 196, 26, 0.1);
  213. color: #2BC644;
  214. }
  215. &.status-closed {
  216. background: rgba(245, 108, 108, 0.1);
  217. color: #F56C6C;
  218. }
  219. }
  220. .meta_text {
  221. font-size: 24rpx;
  222. color: #999999;
  223. height: 48rpx;
  224. line-height: 48rpx;
  225. }
  226. }
  227. }
  228. .item_bottom {
  229. border-top: 2rpx solid #E4E7ED;
  230. display: flex;
  231. flex-direction: row;
  232. justify-content: space-between;
  233. align-items: center;
  234. padding: 24rpx 16rpx;
  235. .notice_stats {
  236. display: flex;
  237. .stats_text {
  238. font-size: 24rpx;
  239. color: #999999;
  240. &:first-child {
  241. margin-right: 32rpx;
  242. }
  243. }
  244. }
  245. .notice_actions {
  246. display: flex;
  247. justify-content: flex-end;
  248. gap: 16rpx;
  249. .action_btn {
  250. font-size: 24rpx;
  251. padding: 12rpx 24rpx;
  252. border-radius: 8rpx;
  253. border: 2rpx solid transparent;
  254. &.delete {
  255. border-color: #F56C6C;
  256. color: #F56C6C;
  257. background-color: #FFFFFF;
  258. &.disabled {
  259. border-color: #C0C4CC;
  260. color: #C0C4CC;
  261. background-color: #FFFFFF;
  262. }
  263. }
  264. &.edit {
  265. border-color: #2E64FA;
  266. color: #2E64FA;
  267. background-color: #FFFFFF;
  268. &.disabled {
  269. border-color: #C0C4CC;
  270. color: #C0C4CC;
  271. background-color: #FFFFFF;
  272. }
  273. }
  274. &.detail {
  275. background-color: #2E64FA;
  276. color: #FFFFFF;
  277. &.disabled {
  278. border-color: #C0C4CC;
  279. color: #C0C4CC;
  280. background-color: #FFFFFF;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. &:last-child {
  287. margin-bottom: 0;
  288. }
  289. }
  290. </style>