hookehuyr

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

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