| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view class="container">
- <!-- 自定义导航栏 -->
- <view class="nav-bar">
- <view class="nav-left" @click="navBack">
- <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);">
- </image>
- </view>
- <text class="nav-title">消息中心</text>
- <view class="nav-right">
- <view class="more-dots">
- <view class="dot"></view>
- <view class="dot"></view>
- <view class="dot"></view>
- </view>
- </view>
- </view>
- <view class="nav-placeholder"></view>
- <!-- 消息分类列表 -->
- <view class="message-list">
- <!-- 订单消息 -->
- <view class="message-item" @click="navToOrderMsg">
- <view class="icon-wrapper">
- <image class="msg-icon" src="/static/icons/icon_order_msg.svg"></image>
- <view class="red-dot-badge" v-if="orderUnread > 0"></view>
- </view>
- <view class="content-wrapper">
- <view class="top-row">
- <text class="msg-title">订单消息</text>
- <text class="msg-time" v-if="latestOrderMsg">{{ formatTime(latestOrderMsg.createTime) }}</text>
- </view>
- <text class="msg-preview text-ellipsis">{{ latestOrderMsg ? latestOrderMsg.content : '暂无新订单消息' }}</text>
- </view>
- </view>
- <!-- 系统消息 -->
- <view class="message-item" @click="navToSystemMsg">
- <view class="icon-wrapper">
- <image class="msg-icon" src="/static/icons/icon_system_msg.svg"></image>
- <view class="red-dot-badge" v-if="systemUnread > 0"></view>
- </view>
- <view class="content-wrapper">
- <view class="top-row">
- <text class="msg-title">系统消息</text>
- <text class="msg-time" v-if="latestSystemMsg">{{ formatTime(latestSystemMsg.createTime) }}</text>
- </view>
- <text class="msg-preview text-ellipsis">{{ latestSystemMsg ? latestSystemMsg.content : '暂无新系统消息' }}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { listMyNotice } from '@/api/system/notice'
- import { formatTime } from '@/utils/index'
- export default {
- data() {
- return {
- orderUnread: 0,
- systemUnread: 0,
- latestOrderMsg: null,
- latestSystemMsg: null
- }
- },
- onShow() {
- this.loadMessageSummary();
- },
- methods: {
- formatTime,
- async loadMessageSummary() {
- try {
- // 加载订单消息概览 (type=0)
- const orderRes = await listMyNotice({
- type: 0,
- pageNum: 1,
- pageSize: 1
- });
- this.latestOrderMsg = orderRes.rows && orderRes.rows.length > 0 ? orderRes.rows[0] : null;
-
- const orderUnreadRes = await listMyNotice({
- type: 0,
- readFlag: false,
- pageNum: 1,
- pageSize: 1
- });
- this.orderUnread = Number(orderUnreadRes.total) || 0;
- // 加载系统消息概览 (type=1) - 假设系统消息是1
- const systemRes = await listMyNotice({
- type: 1,
- pageNum: 1,
- pageSize: 1
- });
- this.latestSystemMsg = systemRes.rows && systemRes.rows.length > 0 ? systemRes.rows[0] : null;
- const systemUnreadRes = await listMyNotice({
- type: 1,
- readFlag: false,
- pageNum: 1,
- pageSize: 1
- });
- this.systemUnread = Number(systemUnreadRes.total) || 0;
- } catch (err) {
- console.error('加载消息概览失败:', err);
- }
- },
- navBack() {
- uni.navigateBack();
- },
- navToOrderMsg() {
- uni.navigateTo({
- url: '/pages/mine/message/order/index'
- });
- },
- navToSystemMsg() {
- uni.navigateTo({
- url: '/pages/mine/message/system/index'
- });
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #fff;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
- }
- .nav-bar {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 88rpx;
- padding-top: var(--status-bar-height);
- background-color: #fff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 30rpx;
- padding-top: var(--status-bar-height);
- /* Ensure padding top includes status bar */
- box-sizing: border-box;
- z-index: 100;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .nav-placeholder {
- height: calc(88rpx + var(--status-bar-height));
- }
- .back-icon {
- width: 40rpx;
- height: 40rpx;
- }
- .nav-title {
- font-size: 34rpx;
- font-weight: bold;
- color: #333;
- }
- .nav-right {
- width: 40rpx;
- display: flex;
- justify-content: flex-end;
- }
- .more-dots {
- display: flex;
- gap: 4rpx;
- }
- .dot {
- width: 6rpx;
- height: 6rpx;
- background-color: #333;
- border-radius: 50%;
- }
- .message-list {
- padding: 0 30rpx;
- }
- .message-item {
- display: flex;
- align-items: center;
- padding: 30rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .icon-wrapper {
- position: relative;
- margin-right: 30rpx;
- }
- .msg-icon {
- width: 96rpx;
- height: 96rpx;
- border-radius: 50%;
- }
- .red-dot-badge {
- position: absolute;
- top: 0;
- right: 0;
- width: 16rpx;
- height: 16rpx;
- background-color: #FF3B30;
- border-radius: 50%;
- border: 2rpx solid #fff;
- }
- .content-wrapper {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .top-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10rpx;
- }
- .msg-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
- .msg-time {
- font-size: 24rpx;
- color: #999;
- }
- .msg-preview {
- font-size: 26rpx;
- color: #666;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- width: 500rpx;
- }
- </style>
|