index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="page_mine" :style="{paddingTop: statusBarHeight + 352 + 'rpx', paddingBottom: showTabbar ? safeAreaBottom + 160 : '24' + 'rpx' }">
  3. <noticeHeader title="我的通知" :showSearch="true" :showFilter="true" :showTabs="true" :tabs="tabs"
  4. :activeTab="activeTab" tabMode="index" @tabChange="handleTabChange" @typeChange="handleTypeChange" @timeChange="handleTimeChange" @searchChange="handleSearchChange"></noticeHeader>
  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">{{ truncateText(item.category, 5) }}</text>
  17. <text class="meta_text">{{ truncateText(item.department, 5) }}</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. <noData 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/noticeHeader.vue';
  36. import NoData from '@/components/noData.vue';
  37. import overviewApi from '@/reqApi/overview.js';
  38. import { useSafeArea } from '@/common/safeArea';
  39. import { truncateText } from '@/common/common.js';
  40. const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
  41. const tabs = ['全部', '未读', '已读'];
  42. const activeTab = ref(0);
  43. const readStatusMap = [-1, 0, 1];
  44. const typeId = ref('0');
  45. const timeType = ref(0);
  46. const word = ref('');
  47. const showTabbar = ref(true);
  48. const noticeList = ref([]);
  49. const getDeleteClass = (item) => {
  50. if (item.noticeStatus !== 2) {
  51. return 'delete disabled';
  52. }
  53. return 'delete';
  54. };
  55. const fetchNoticeList = async () => {
  56. try {
  57. const params = {
  58. readStatus: readStatusMap[activeTab.value],
  59. pageParam: {
  60. pageNum: 1,
  61. pageSize: 9999
  62. },
  63. typeId: typeId.value,
  64. timeType: timeType.value,
  65. word: word.value
  66. };
  67. const res = await overviewApi.teacher_notices_page(params);
  68. if (res.data.records && res.data.records[0] && res.data.records[0].noticePageVOList) {
  69. noticeList.value = res.data.records[0].noticePageVOList.map(item => ({
  70. id: item.id,
  71. title: item.noticeName,
  72. status: item.readStatus === 1 ? '已读' : '未读',
  73. noticeStatus: item.readStatus,
  74. statusClass: item.readStatus === 1 ? 'status_published' : 'status_pending',
  75. category: item.typeName,
  76. department: item.createTeacherName,
  77. time: item.releaseTime,
  78. readCount: item.readNum,
  79. unreadCount: item.unReadNum,
  80. icon: '/static/image/todo/xiaoxi.png'
  81. }));
  82. } else {
  83. noticeList.value = [];
  84. }
  85. } catch (error) {
  86. console.error('获取通知列表失败:', error);
  87. }
  88. };
  89. onLoad((options) => {
  90. if (options && options.hideTabbar === 'true') {
  91. showTabbar.value = false;
  92. }
  93. });
  94. onShow(() => {
  95. fetchNoticeList();
  96. });
  97. const goBack = () => {
  98. uni.navigateBack();
  99. };
  100. const handleTabChange = (idx) => {
  101. activeTab.value = idx;
  102. fetchNoticeList();
  103. };
  104. const handleTypeChange = (type) => {
  105. typeId.value = type;
  106. fetchNoticeList();
  107. };
  108. const handleTimeChange = (time) => {
  109. timeType.value = time;
  110. fetchNoticeList();
  111. };
  112. const handleSearchChange = (keyword) => {
  113. word.value = keyword;
  114. fetchNoticeList();
  115. };
  116. const handleDelete = (id) => {
  117. uni.showModal({
  118. title: '确认删除',
  119. content: '确定要删除这条通知吗?',
  120. success: (res) => {
  121. if (res.confirm) {
  122. noticeList.value = noticeList.value.filter(item => item.id !== id);
  123. uni.showToast({ title: '删除成功', icon: 'success' });
  124. }
  125. }
  126. });
  127. };
  128. const handleEdit = (id) => {
  129. uni.navigateTo({ url: `/pages/notice/publish/index?id=${id}` });
  130. };
  131. const handleDetail = (id) => {
  132. uni.navigateTo({ url: `/pages/notice/mine/detail?id=${id}` });
  133. };
  134. </script>
  135. <style lang="scss">
  136. .page_mine {
  137. height: 100vh;
  138. display: flex;
  139. flex-direction: column;
  140. background-color: #FFFFFF;
  141. box-sizing: border-box;
  142. }
  143. .notice_content {
  144. flex: 1;
  145. display: flex;
  146. flex-direction: column;
  147. overflow: hidden;
  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>