| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <template>
- <view class="page_mine" :style="{paddingTop: statusBarHeight + 322 + 'rpx', paddingBottom: safeAreaBottom + 160 + 'rpx' }">
- <notice-header title="我的通知" :showSearch="true" :showFilter="true" :showTabs="true" :tabs="tabs"
- :activeTab="activeTab" tabMode="index" @tabChange="handleTabChange" @typeChange="handleTypeChange" @timeChange="handleTimeChange" @searchChange="handleSearchChange"></notice-header>
- <view class="notice_content">
- <view class="notice_list">
- <scroll-view scroll-y v-for="item in noticeList" :key="item.id" class="notice_item">
- <view class="item_content" @click="handleDetail(item.id)">
- <view class="notice_title_row">
- <image class="notice_icon" :src="item.icon" mode="aspectFit"></image>
- <text class="notice_title">{{ item.title }}</text>
- <image src="/static/image/icon/xiala.png" class="arrow_icon"></image>
- </view>
- <view class="notice_meta">
- <view class="meta_left">
- <text class="meta_text">{{ item.category }}</text>
- <text class="meta_text">{{ item.department }}</text>
- <text class="meta_text">{{ item.time }}</text>
- </view>
- <view class="status_tag" :class="item.statusClass">
- <text>{{ item.status }}</text>
- </view>
- </view>
- </view>
- </scroll-view>
- <no-data v-if="noticeList.length === 0" centered text="暂无通知" />
- </view>
- </view>
- <common-tabbar v-if="showTabbar"></common-tabbar>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue';
- import { onShow, onLoad } from '@dcloudio/uni-app';
- import NoticeHeader from '@/components/notice-header.vue';
- import NoData from '@/components/no-data.vue';
- import overviewApi from '@/reqApi/overview.js';
- import { useSafeArea } from '@/common/safeArea';
- const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
- const tabs = ['全部', '未读', '已读'];
- const activeTab = ref(0);
- const readStatusMap = [-1, 0, 1];
- const typeId = ref('0');
- const timeType = ref(0);
- const word = ref('');
- const showTabbar = ref(true);
- const noticeList = ref([]);
- const getDeleteClass = (item) => {
- if (item.noticeStatus !== 2) {
- return 'delete disabled';
- }
- return 'delete';
- };
- const fetchNoticeList = async () => {
- try {
- const params = {
- readStatus: readStatusMap[activeTab.value],
- pageParam: {
- pageNum: 1,
- pageSize: 9999
- },
- typeId: typeId.value,
- timeType: timeType.value,
- word: word.value
- };
- const res = await overviewApi.teacher_notices_page(params);
- if (res.data.records && res.data.records[0] && res.data.records[0].noticePageVOList) {
- noticeList.value = res.data.records[0].noticePageVOList.map(item => ({
- id: item.id,
- title: item.noticeName,
- status: item.readStatus === 1 ? '已读' : '未读',
- noticeStatus: item.readStatus,
- statusClass: item.readStatus === 1 ? 'status-published' : 'status-closed',
- category: item.typeName,
- department: item.createTeacherName,
- time: item.releaseTime,
- readCount: item.readNum,
- unreadCount: item.unReadNum,
- icon: '/static/image/todo/xiaoxi.png'
- }));
- } else {
- noticeList.value = [];
- }
- } catch (error) {
- console.error('获取通知列表失败:', error);
- }
- };
- onLoad((options) => {
- if (options && options.hideTabbar === 'true') {
- showTabbar.value = false;
- }
- });
- onShow(() => {
- fetchNoticeList();
- });
- const goBack = () => {
- uni.navigateBack();
- };
- const handleTabChange = (idx) => {
- activeTab.value = idx;
- fetchNoticeList();
- };
- const handleTypeChange = (type) => {
- typeId.value = type;
- fetchNoticeList();
- };
- const handleTimeChange = (time) => {
- timeType.value = time;
- fetchNoticeList();
- };
- const handleSearchChange = (keyword) => {
- word.value = keyword;
- fetchNoticeList();
- };
- const handleDelete = (id) => {
- uni.showModal({
- title: '确认删除',
- content: '确定要删除这条通知吗?',
- success: (res) => {
- if (res.confirm) {
- noticeList.value = noticeList.value.filter(item => item.id !== id);
- uni.showToast({ title: '删除成功', icon: 'success' });
- }
- }
- });
- };
- const handleEdit = (id) => {
- uni.navigateTo({ url: `/pages/notice/publish/index?id=${id}` });
- };
- const handleDetail = (id) => {
- uni.navigateTo({ url: `/pages/notice/mine/detail?id=${id}` });
- };
- </script>
- <style lang="scss">
- .page_mine {
- height: 100vh;
- display: flex;
- flex-direction: column;
- background-color: #FFFFFF;
- box-sizing: border-box;
- }
- .notice_content {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- padding-left: 0rpx;
- padding-right: 0rpx;
- }
- .notice_list {
- flex: 1;
- overflow-y: auto;
- overflow-x: hidden;
- padding: 0 24rpx;
- display: flex;
- flex-direction: column;
- }
- .notice_item {
- background-color: #F9FAFF;
- border-radius: 20rpx;
- margin-bottom: 24rpx;
- border: 2rpx solid #E4E7ED;
- .item_content {
- padding: 24rpx;
- .notice_title_row {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
- .notice_icon {
- width: 32rpx;
- height: 32rpx;
- margin-right: 16rpx;
- }
- .arrow_icon {
- width: 24rpx;
- height: 24rpx;
- transform: rotate(-90deg);
- }
- .notice_title {
- flex: 1;
- font-weight: 500;
- font-size: 28rpx;
- color: #333333;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- .notice_meta {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .meta_left {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 16rpx;
-
- }
- .status_tag {
- font-size: 24rpx;
- height: 48rpx;
- width: 96rpx;
- text-align: center;
- line-height: 48rpx;
- border-radius: 8rpx;
- font-weight: 400;
- &.status-pending {
- background: rgba(46, 100, 250, 0.1);
- color: #2E64FA;
- }
- &.status-published {
- background: rgba(82, 196, 26, 0.1);
- color: #2BC644;
- }
- &.status-closed {
- background: rgba(245, 108, 108, 0.1);
- color: #F56C6C;
- }
- }
- .meta_text {
- font-size: 24rpx;
- color: #999999;
- height: 48rpx;
- line-height: 48rpx;
- }
- }
- }
- .item_bottom {
- border-top: 2rpx solid #E4E7ED;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 24rpx 16rpx;
- .notice_stats {
- display: flex;
- .stats_text {
- font-size: 24rpx;
- color: #999999;
- &:first-child {
- margin-right: 32rpx;
- }
- }
- }
- .notice_actions {
- display: flex;
- justify-content: flex-end;
- gap: 16rpx;
- .action_btn {
- font-size: 24rpx;
- padding: 12rpx 24rpx;
- border-radius: 8rpx;
- border: 2rpx solid transparent;
- &.delete {
- border-color: #F56C6C;
- color: #F56C6C;
- background-color: #FFFFFF;
- &.disabled {
- border-color: #C0C4CC;
- color: #C0C4CC;
- background-color: #FFFFFF;
- }
- }
- &.edit {
- border-color: #2E64FA;
- color: #2E64FA;
- background-color: #FFFFFF;
- &.disabled {
- border-color: #C0C4CC;
- color: #C0C4CC;
- background-color: #FFFFFF;
- }
- }
- &.detail {
- background-color: #2E64FA;
- color: #FFFFFF;
- &.disabled {
- border-color: #C0C4CC;
- color: #C0C4CC;
- background-color: #FFFFFF;
- }
- }
- }
- }
- }
- &:last-child {
- margin-bottom: 0;
- }
- }
- </style>
|