index.vue 7.1 KB

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