agri-app/pages/news/subpages/sysNotice/index.vue

336 lines
9.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view class="notice-page">
<!-- 未读/已读标签栏 -->
<view class="tab-bar">
<view
class="tab-item"
:class="{ active: currentTab === 0 }"
@click="switchTab(0)"
>
未读
</view>
<view
class="tab-item"
:class="{ active: currentTab === 1 }"
@click="switchTab(1)"
>
已读
</view>
</view>
<!-- 公告列表 -->
<scroll-view scroll-y class="notice-list" v-if="noticeList.length>0">
<view
v-for="(item, index) in noticeList"
:key="index"
class="notice-item"
@click="handleClick(item)"
>
<!-- 状态点 + 标题 -->
<view class="notice-header">
<view class="status-dot" :style="{ borderColor: item.dotColor }">
<view class="dot-inner" :style="{ backgroundColor: item.dotColor }" v-if="Math.random() < 0.5"></view>
</view>
<text class="notice-title">{{ item.title }}</text>
</view>
<!-- 内容描述 -->
<view class="notice-content">
<text class="content-text">{{ item.content }}</text>
</view>
<!-- 底部:头像 + 作者 + 时间 -->
<view class="notice-footer">
<view class="author-info">
<image class="avatar" :src="authorList[Math.round(Math.random())].avatar" mode="aspectFill"></image>
<text class="author-name">{{ authorList[Math.round(Math.random())].name }}</text>
</view>
<text class="notice-time">{{ item.time }}</text>
</view>
</view>
</scroll-view>
<view class="empty__item tn-margin-top" v-else>
<tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png"
text="暂无公告" :imgWidth="200"
:imgHeight="200"></tn-empty>
</view>
<uni-popup ref="showNotice" mode="center" >
<!-- 新增修改运行时间的弹窗 -->
<view class="modal-container">
<view class="modal-title">{{ notice.title }}</view>
<view class="modal-content">&nbsp; &nbsp;&nbsp; &nbsp;{{ notice.content }}</view>
<view class="modal-remark">
<view class="remark">
发布人{{ notice.author }}
</view>
<view class="remark">
发布时间{{ notice.time }}
</view>
</view>
<view class="modal-btn-wrap">
<button class="modal-btn confirm" @click="closeShowNotice"></button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
data() {
return {
currentTab: 0, // 0未读 1已读
authorList: [
{
name: '那只猪-图鸟人事部',
avatar: 'https://img.xiaoces.com/photos/profile.jpg'
},
{
name: '你的名字',
avatar: 'https://img.xiaoces.com/photos/logo200.png'
}
],
dotColorList: [
'#e53935',
'#007bff',
'#4caf50',
'#ff9800'
],
contentList: [
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, // 实心红点
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' // 替换为你的头像路径
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01retrt345日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, // 实心红点
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' // 替换为你的头像路径
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春45353535节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, // 实心红点
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' // 替换为你的头像路径
},
{
title: '关于年前请假审批流程通知',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '你的名字',
time: '2024-01-20 14:02',
dotColor: '#007bff',
dotInner: false, // 空心蓝点
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '图鸟OA系统更新通知',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '不许凶我吖',
time: '2024-01-12 09:56',
dotColor: '#4caf50',
dotInner: true, // 实心绿点
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '凑数的文案,凑够一行超出隐藏,不喜勿喷',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '图鸟西西',
time: '2024-01-06 17:59',
dotColor: '#007bff',
dotInner: false, // 空心蓝点
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '2023年12月考勤统计核对表',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '',
time: '',
dotColor: '#4caf50',
dotInner: true, // 实心绿点
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
}
],
noticeList: [],
notice: {
title:null,
content:null,
author:null,
avatar:null
}
}
},
methods: {
switchTab(currentTab) {
this.currentTab = currentTab;
this.noticeList = this.contentList.filter(item =>
item.isRead===currentTab);
},
handleClick(item) {
this.notice = item;
this.$refs.showNotice.open();
},
closeShowNotice() {
this.$refs.showNotice.close();
}
},
onShow() {
// 系统通知按照最新时间升序排序
this.noticeList = this.contentList.filter(item =>
item.isRead===0);
},
}
</script>
<style scoped>
page {
box-sizing: border-box;
background-color: #f8f8f8;
}
/* 页面容器 */
.notice-page {
display: flex;
flex-direction: column;
box-sizing: border-box;
}
/* 标签栏 */
.tab-bar {
display: flex;
height: 80rpx;
padding: 0 20rpx;
background-color: #fff;
border-bottom: 1rpx solid #eee;
}
.tab-item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: #999;
position: relative;
}
.tab-item.active {
color: #007bff;
font-weight: 500;
}
.tab-item.active::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background-color: #007bff;
border-radius: 2rpx;
}
/* 公告列表 */
.notice-list {
flex: 1;
padding: 20rpx;
background-color: transparent;
border-radius: 8rpx;
overflow: hidden;
/* 新增H5端避免滚动条样式不一致 */
scrollbar-width: thin;
}
.notice-item {
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
}
/* 公告头部:状态点 + 标题 */
.notice-header {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.status-dot {
width: 24rpx;
height: 24rpx;
border: 2rpx solid;
border-radius: 50%;
margin-right: 16rpx;
display: flex;
align-items: center;
justify-content: center;
}
.dot-inner {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
}
.notice-title {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
/* 公告内容 */
.notice-content {
margin-bottom: 20rpx;
}
.content-text {
font-size: 28rpx;
color: #666;
line-height: 1.5;
/* 超出两行隐藏(可按需调整) */
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
/* 公告底部:头像 + 作者 + 时间 */
.notice-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
.author-info {
display: flex;
align-items: center;
}
.avatar {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
margin-right: 12rpx;
}
.author-name {
font-size: 26rpx;
color: #999;
}
.notice-time {
font-size: 26rpx;
color: #999;
}
</style>