You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
5.2 KiB

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="message-page">
<view class="header-title">消息</view>
<!-- 消息卡片列表 -->
<view class="message-list">
<!-- 实时 -->
<view class="message-card realtime">
<view class="message-card-header">
<view class="tag realtime"><text class="tag-text">实时</text></view>
<view class="date">2024-01-15 10:30</view>
</view>
<view class="message-title">过闸通知</view>
<view class="message-content">北向南2025040102批次准备过闸请相关船只做好准备</view>
</view>
<!-- 公告 -->
<view class="message-card notice">
<view class="message-card-header">
<view class="tag notice"><text class="tag-text">公告</text></view>
<view class="date">2024-01-15 10:30</view>
</view>
<view class="message-title">系统维护通知</view>
<view class="message-content">系统将于2024年1月20凌晨2:00-4:00进行例行维护期间在线服务暂停使用</view>
</view>
<!-- 预警 -->
<view class="message-card warning">
<view class="message-card-header">
<view class="tag warning"><text class="tag-text">预警</text></view>
<view class="date">2024-01-15 10:30</view>
</view>
<view class="message-title">天气预警</view>
<view class="message-content">受寒潮影响未来24小时内可能出现大雾天气请过往船只注意安全</view>
</view>
<!-- 提醒 -->
<view class="message-card remind">
<view class="message-card-header">
<view class="tag remind"><text class="tag-text">提醒</text></view>
<view class="date">2024-01-15 10:30</view>
</view>
<view class="message-title">购票成功</view>
<view class="message-content">您已成功购买北向南2025040101批次过闸船票请按时到达指定位置</view>
</view>
</view>
</view>
</template>
<script>
import { API } from '@/config/index.js';
export default {
name: 'MessagePage',
data() {
return {
notifications: [],
page: 1,
per_page: 5,
status: '', // 可选: '', 'unread', 'read'
}
},
onShow() {
this.fetchNotifications();
},
methods: {
async fetchNotifications() {
const token = uni.getStorageSync('token');
if (!token) return;
try {
const res = await new Promise((resolve, reject) => {
uni.request({
url: `${API.NOTIFICATION_LIST}?token=${token}&page=${this.page}&per_page=${this.per_page}${this.status ? `&status=${this.status}` : ''}`,
method: 'GET',
success: resolve,
fail: reject
});
});
if (res.data && res.data.errcode === 0) {
this.notifications = res.data.data.list || [];
}
} catch (e) {
console.error('Failed to fetch notifications:', e);
}
},
},
}
</script>
<style scoped>
.message-page {
background: linear-gradient(180deg, #cbe6ff 0%, #f6faff 100%);
min-height: 100vh;
padding-bottom: 80px;
font-family: 'SourceHanSansCN', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.header-title {
text-align: center;
font-size: 36rpx;
font-weight: bold;
padding-top: 7vh;
letter-spacing: 2rpx;
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 16px 10px 16px;
background: linear-gradient(180deg, #cbe6ff 0%, #f6faff 100%);
}
.back-btn, .more-btn {
font-size: 24px;
color: #333;
}
.title {
font-size: 22px;
font-weight: bold;
color: #222;
}
.message-list {
padding: 10px 0 0 0;
margin-top: 44rpx;
}
.message-card {
background: #fff;
border-radius: 10px;
margin: 0 16px 16px 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
padding: 18px 18px 12px 18px;
height: 272rpx;
}
.message-card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.tag {
font-size: 22rpx;
padding: 4rpx 18rpx;
border-radius: 8rpx;
margin-right: 24rpx;
white-space: nowrap;
color: #fff;
display: inline-block;
background: linear-gradient(90deg, #2b70ee 0%, #3b7cff 100%);
transform: skewX(-20deg);
font-weight: 500;
border: none;
}
.tag-text {
display: inline-block;
transform: skewX(20deg);
}
.tag.realtime { background: linear-gradient(90deg, #ffb980 0%, #ffc99a 100%); }
.tag.notice { background: linear-gradient(90deg, #217aff 0%, #3b7cff 100%); }
.tag.warning { background: linear-gradient(90deg, #ff5c5c 0%, #ff7a7a 100%); }
.tag.remind { background: linear-gradient(90deg, #22c58b 0%, #2ed9a3 100%); }
.date { color: #173766; font-size: 15px; }
.message-title {
font-size: 16px;
font-weight: 550;
margin-bottom: 12px;
color: #222;
margin-top: 12px;
}
.message-content {
color: #355;
font-size: 14px;
color: #173766;
}
.tabbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 60px;
background: #fff;
display: flex;
border-top: 1px solid #eaeaea;
z-index: 10;
}
.tab-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #888;
font-size: 14px;
}
.tab-item.active {
color: #217aff;
}
.icon {
font-size: 22px;
margin-bottom: 2px;
}
</style>