hookehuyr

refactor(消息系统): 统一将通知类型从notification改为system

- 修改API文档注释,增加消息状态和类型参数说明
- 更新组件中notification相关类名和逻辑为system
- 调整消息列表页的tab和过滤逻辑
- 添加默认头像常量
......@@ -11,6 +11,9 @@ const Api = {
/**
* @description: 所有消息列表
* @param {*} params
* @param {number} params.status - 消息状态, 3=未读,5=已读
* @param {number} params.type - 消息类型, system=系统消息,chat=聊天消息
* @param {number} params.keyword - 搜索关键词
* @param {number} params.page - 页码,从0开始
* @param {number} params.limit - 每页数量
* @returns data.list[{
......@@ -20,6 +23,8 @@ const Api = {
* note: 消息内容
* create_time: 创建时间
* created_time_desc: 消息创建时间描述
* partner_nickname: 聊天人昵称
* partner_avatar_url: 聊天人头像
* }]
*/
export const getMessagesListAPI = (params) => fn(fetch.get(Api.GET_MESSAGES_LIST, params));
......
......@@ -30,7 +30,7 @@
<!-- 消息内容区域 -->
<view class="detail-content">
<!-- 系统通知样式 -->
<view v-if="conversation?.type === 'notification'" class="notification-content">
<view v-if="conversation?.type === 'system'" class="system-content">
<view class="message-content">
<text class="text-base">{{ conversation?.lastMessage }}</text>
</view>
......@@ -97,7 +97,7 @@
@click="handleClose"
color="orange"
>
{{ conversation?.type === 'notification' ? '关闭' : '返回' }}
{{ conversation?.type === 'system' ? '关闭' : '返回' }}
</nut-button>
</view>
</view>
......@@ -339,7 +339,7 @@ watch(visible, (newVisible) => {
}
// 系统通知样式
.notification-content {
.system-content {
padding: 24rpx;
height: 100%;
overflow-y: auto;
......
......@@ -29,8 +29,8 @@
<view class="tab-item" :class="{ active: activeTab === 'unread' }" @click="setActiveTab('unread')">
未读
</view>
<view class="tab-item" :class="{ active: activeTab === 'notification' }"
@click="setActiveTab('notification')">
<view class="tab-item" :class="{ active: activeTab === 'system' }"
@click="setActiveTab('system')">
通知
</view>
</view>
......@@ -46,7 +46,7 @@
<nut-row>
<nut-col :span="6" class="avatar-container">
<view class="relative">
<image v-if="conversation.avatar" :src="conversation.avatar"
<image v-if="conversation.type === 'chat'" :src="conversation.avatar || defaultAvatar"
class="w-12 h-12 rounded-full object-cover" mode="aspectFill" />
<view v-else class="w-12 h-12 rounded-full bg-gray-100 flex items-center justify-center">
<component :is="conversation.icon" />
......@@ -104,7 +104,7 @@ import { $ } from '@tarojs/extend'
import Taro from '@tarojs/taro'
// 默认头像
// const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
const scrollStyle = ref({
height: 'calc(100vh - 500rpx)'
......@@ -146,15 +146,15 @@ const initData = () => {
// 生成更多初始数据确保可以滚动
for (let i = 1; i <= 15; i++) {
const types = ['chat', 'notification']
const types = ['chat', 'system']
const type = types[i % 2]
mockData.push({
id: i,
name: type === 'notification' ? '系统通知' : `用户${i}`,
name: type === 'system' ? '系统通知' : `用户${i}`,
avatar: type === 'chat' ? `https://randomuser.me/api/portraits/men/${(i % 50) + 1}.jpg` : '',
icon: type === 'notification' ? markRaw(Notice) : null,
lastMessage: type === 'notification' ? '您有新的系统通知' : `这是第${i}条消息内容`,
icon: type === 'system' ? markRaw(Notice) : null,
lastMessage: type === 'system' ? '您有新的系统通知' : `这是第${i}条消息内容`,
time: i <= 5 ? `${i * 5}分钟前` : i <= 10 ? `${i}小时前` : `${i - 10}天前`,
unread: Math.random() > 0.5,
type: type
......@@ -171,8 +171,8 @@ const filteredConversations = computed(() => {
// 根据Tab过滤
if (activeTab.value === 'unread') {
filtered = filtered.filter(conv => conv.unread)
} else if (activeTab.value === 'notification') {
filtered = filtered.filter(conv => conv.type === 'notification')
} else if (activeTab.value === 'system') {
filtered = filtered.filter(conv => conv.type === 'system')
}
// 根据搜索关键词过滤
......