| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <template>
- <view class="page_message" :style="{paddingTop: statusBarHeight + 160 + 'rpx', paddingBottom: safeAreaBottom + 150 + 'rpx' }">
- <page-header></page-header>
- <view class="message_content">
- <view class="message_header">
- <text class="message_title">系统消息({{ unreadCount }}项)</text>
- <text class="mark_all_read" @click="mark_all_read" v-if="messageList.length > 0">全部已读</text>
- </view>
- <view class="message_list" v-if="messageList.length > 0">
- <view v-for="item in messageList" :key="item.id" class="message_item">
- <view class="message_left">
- <view class="message_info">
- <view class="message_title_row">
- <image src="/static/image/todo/daiban.png" class="message_icon" mode="aspectFit"></image>
- <text class="message_name">{{ item.taskName }}</text>
- </view>
- <view class="message_meta">
- <view class="meta_left">
- <text class="meta_tag" :class="getTagStyle(item.taskStatus)">{{ item.taskStatus }}</text>
- <text class="meta_type">{{ item.taskRemark }}</text>
- <text class="meta_time">{{ item.taskTime }}</text>
- </view>
- <text class="mark_read" @click="markNoticeRead(item.id)">{{ item.readStatus === 0 ? '标记已读' : '' }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- <view v-if="messageList.length === 0" class="schedule_empty">
- <image src="@/static/image/bg/no_data.png" class="empty_image" mode="aspectFit"></image>
- <text class="empty_text">暂无系统消息</text>
- </view> -->
- <no-data v-if="messageList.length === 0" centered text="暂无系统消息"></no-data>
- </view>
- <common-tabbar></common-tabbar>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue';
- import { onShow } from '@dcloudio/uni-app';
- import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
- import PageHeader from '@/components/page-header.vue';
- import CommonTabbar from '@/components/commonTabbar.vue';
- import workspace from '@/reqApi/workspace.js';
- import { useSafeArea } from '@/common/safeArea';
- import NoData from '@/components/no-data.vue';
- import { truncateText } from '@/common/common.js';
- const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
- const messageList = ref([]);
- const unreadCount = ref(0);
- const getTagStyle = (status) => {
- if (status === '已驳回') {
- return 'meta_tag_red'
- }
- if (status === '进行中' || status === "已通过") {
- return 'meta_tag_green'
- }
- return ''
- }
- const fetchMessageList = async () => {
- try {
- const res = await workspace.getNoticeList();
- if (res && res.data) {
- messageList.value = res.data
- unreadCount.value = messageList.value.filter((item) => item.readStatus === 0).length;
- }
- } catch (error) {
- console.error('获取系统消息列表失败:', error);
- }
- };
- const markNoticeRead = async (id) => {
- try {
- const res = await workspace.markNoticeRead(id);
- if (res.code === 200) {
- const item = messageList.value.find((item) => item.id === id);
- if (item) {
- item.readStatus = 1;
- }
- unreadCount.value--;
- uni.showToast({
- title: '当前消息标记成功',
- icon: 'success',
- duration: 2000
- });
- }
- } catch (error) {
- console.error('标记系统消息已读失败:', error);
- }
- };
- const mark_all_read = async () => {
- try {
- const res = await workspace.mark_all_as_read();
- if (res.code === 200) {
- messageList.value.forEach((item) => {
- item.readStatus = 1;
- });
- unreadCount.value = 0;
- uni.showToast({
- title: '全部已读成功',
- icon: 'success',
- duration: 2000
- });
- }
- } catch (error) {
- console.error('标记所有消息已读失败:', error);
- }
- };
- onMounted(() => {
- initSafeArea();
- });
- onShow(() => {
- fetchMessageList();
- });
- </script>
- <style lang="scss">
- .page_message {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- background-color: #FFFFFF;
- box-sizing: border-box;
- }
- .message_content {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- padding-left: 0rpx;
- padding-right: 0rpx;
- }
- .message_header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 24rpx;
- flex-shrink: 0;
- padding:0 24rpx;
- .message_title {
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- height: 64rpx;
- line-height: 64rpx;
- }
- .mark_all_read {
- border-radius: 8rpx;
- border: 2rpx solid #2E64FA;
- background: #FFFFFF;
- font-weight: 400;
- font-size: 24rpx;
- color: #2E64FA;
- width: 136rpx;
- height: 64rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- .message_list {
- flex: 1;
- overflow-y: auto;
- padding:0 24rpx;
- .message_item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 16rpx;
- background: #F9FAFF;
- border-radius: 20rpx;
- margin-bottom: 24rpx;
- border: 2rpx solid #E4E7ED;
- &:last-child {
- margin-bottom: 0;
- }
- .message_left {
- display: flex;
- flex: 1;
- align-items: flex-start;
- gap: 16rpx;
- }
- .message_icon {
- flex-shrink: 0;
- margin-top: 4rpx;
- width: 32rpx;
- height: 32rpx;
- }
- .message_info {
- flex: 1;
- overflow: hidden;
- }
- .message_title_row {
- display: flex;
- align-items: center;
- gap: 16rpx;
- margin-bottom: 16rpx;
- .message_name {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- flex: 1;
- width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- .message_meta {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .meta_left {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 16rpx;
- flex: 1;
- overflow: hidden;
- }
- .meta_tag {
- font-size: 22rpx;
- padding: 8rpx 12rpx;
- background-color: rgba(74, 108, 247, 0.1);
- color: #4A6CF7;
- border-radius: 4rpx;
- }
- .mark_read {
- font-weight: 400;
- font-size: 24rpx;
- color: #2E64FA;
- flex-shrink: 0;
- margin-left: 16rpx;
- }
- .meta_tag_red {
- background-color: rgba(245, 108, 108, 0.1);
- color: #F56C6C;
- }
- .meta_tag_green {
- background-color: rgba(43, 198, 68, 0.1);
- color: #2BC644;
- }
- .meta_type {
- font-size: 24rpx;
- color: #999999;
- }
- .meta_time {
- margin-top: 5rpx;
- font-size: 24rpx;
- color: #999999;
- }
- }
- }
- }
- .schedule_empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- font-size: 28rpx;
- color: #999999;
- position: relative;
- height: 100%;
- overflow: hidden;
- .empty_image {
- width: 400rpx;
- height: 400rpx;
- }
- .empty_text {
- position: absolute;
- bottom: 15%;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- }
- </style>
|