|
@@ -13,30 +13,118 @@
|
|
|
<text>加载中...</text>
|
|
<text>加载中...</text>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- 会话列表 -->
|
|
|
|
|
|
|
+ <!-- 消息内容 -->
|
|
|
<view v-else-if="conversationList.length > 0">
|
|
<view v-else-if="conversationList.length > 0">
|
|
|
- <view
|
|
|
|
|
- v-for="conversation in conversationList"
|
|
|
|
|
- :key="conversation.conversationID"
|
|
|
|
|
- class="message-item user-message"
|
|
|
|
|
- @click="openChat(conversation)"
|
|
|
|
|
- >
|
|
|
|
|
- <image
|
|
|
|
|
- v-if="conversation.userProfile.avatar"
|
|
|
|
|
- :src="conversation.userProfile.avatar"
|
|
|
|
|
- class="message-avatar-img"
|
|
|
|
|
- />
|
|
|
|
|
- <view v-else class="message-avatar">
|
|
|
|
|
- {{ conversation.userProfile.nick || conversation.userProfile.userID.charAt(0) }}
|
|
|
|
|
- </view>
|
|
|
|
|
|
|
+ <!-- 系统通知卡片 -->
|
|
|
|
|
+ <view class="message-item system-notification" v-if="systemNotification" @click="openSystemMessages">
|
|
|
|
|
+ <text class="message-type">{{ systemNotification.title }}</text>
|
|
|
|
|
+ <text class="message-time">{{ systemNotification.timeText }}</text>
|
|
|
|
|
+ <text class="message-content">{{ systemNotification.content }}</text>
|
|
|
|
|
+ <text class="message-footer">{{ systemNotification.footer }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 撮合成功通知卡片 -->
|
|
|
|
|
+ <view class="message-item match-success" v-if="matchSuccessNotification">
|
|
|
|
|
+ <view class="message-icon heart"></view>
|
|
|
<view class="message-body">
|
|
<view class="message-body">
|
|
|
- <text class="message-type">{{ conversation.userProfile.nick || conversation.userProfile.userID }}</text>
|
|
|
|
|
- <text class="message-content">{{ getLastMessageText(conversation.lastMessage) }}</text>
|
|
|
|
|
|
|
+ <text class="message-type">{{ matchSuccessNotification.title }}</text>
|
|
|
|
|
+ <text class="message-content">{{ matchSuccessNotification.content }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <text class="message-time">{{ matchSuccessNotification.timeText }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 今天 -->
|
|
|
|
|
+ <view v-if="todayConversations.length > 0">
|
|
|
|
|
+ <view class="time-group">
|
|
|
|
|
+ <text class="time-label">今天</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="message-right">
|
|
|
|
|
- <text class="message-time">{{ formatTime(conversation.lastMessage.lastTime) }}</text>
|
|
|
|
|
- <view v-if="conversation.unreadCount > 0" class="unread-badge">
|
|
|
|
|
- {{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
|
|
|
|
|
|
|
+ <view
|
|
|
|
|
+ v-for="conversation in todayConversations"
|
|
|
|
|
+ :key="conversation.conversationID"
|
|
|
|
|
+ class="message-item user-message"
|
|
|
|
|
+ @click="openChat(conversation)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <image
|
|
|
|
|
+ v-if="conversation.userProfile.avatar"
|
|
|
|
|
+ :src="conversation.userProfile.avatar"
|
|
|
|
|
+ class="message-avatar-img"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view v-else class="message-avatar">
|
|
|
|
|
+ {{ conversation.userProfile.nick || conversation.userProfile.userID.charAt(0) }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-body">
|
|
|
|
|
+ <text class="message-type">{{ conversation.userProfile.nick || conversation.userProfile.userID }}</text>
|
|
|
|
|
+ <text class="message-content">{{ getLastMessageText(conversation.lastMessage) }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-right">
|
|
|
|
|
+ <text class="message-time">{{ formatTime(conversation.lastMessage.lastTime) }}</text>
|
|
|
|
|
+ <view v-if="conversation.unreadCount > 0" class="unread-badge">
|
|
|
|
|
+ {{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 昨日 -->
|
|
|
|
|
+ <view v-if="yesterdayConversations.length > 0">
|
|
|
|
|
+ <view class="time-group">
|
|
|
|
|
+ <text class="time-label">昨日</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view
|
|
|
|
|
+ v-for="conversation in yesterdayConversations"
|
|
|
|
|
+ :key="conversation.conversationID"
|
|
|
|
|
+ class="message-item user-message"
|
|
|
|
|
+ @click="openChat(conversation)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <image
|
|
|
|
|
+ v-if="conversation.userProfile.avatar"
|
|
|
|
|
+ :src="conversation.userProfile.avatar"
|
|
|
|
|
+ class="message-avatar-img"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view v-else class="message-avatar">
|
|
|
|
|
+ {{ conversation.userProfile.nick || conversation.userProfile.userID.charAt(0) }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-body">
|
|
|
|
|
+ <text class="message-type">{{ conversation.userProfile.nick || conversation.userProfile.userID }}</text>
|
|
|
|
|
+ <text class="message-content">{{ getLastMessageText(conversation.lastMessage) }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-right">
|
|
|
|
|
+ <text class="message-time">{{ formatTime(conversation.lastMessage.lastTime) }}</text>
|
|
|
|
|
+ <view v-if="conversation.unreadCount > 0" class="unread-badge">
|
|
|
|
|
+ {{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 更早 -->
|
|
|
|
|
+ <view v-if="earlierConversations.length > 0">
|
|
|
|
|
+ <view class="time-group">
|
|
|
|
|
+ <text class="time-label">更早</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view
|
|
|
|
|
+ v-for="conversation in earlierConversations"
|
|
|
|
|
+ :key="conversation.conversationID"
|
|
|
|
|
+ class="message-item user-message"
|
|
|
|
|
+ @click="openChat(conversation)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <image
|
|
|
|
|
+ v-if="conversation.userProfile.avatar"
|
|
|
|
|
+ :src="conversation.userProfile.avatar"
|
|
|
|
|
+ class="message-avatar-img"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view v-else class="message-avatar">
|
|
|
|
|
+ {{ conversation.userProfile.nick || conversation.userProfile.userID.charAt(0) }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-body">
|
|
|
|
|
+ <text class="message-type">{{ conversation.userProfile.nick || conversation.userProfile.userID }}</text>
|
|
|
|
|
+ <text class="message-content">{{ getLastMessageText(conversation.lastMessage) }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="message-right">
|
|
|
|
|
+ <text class="message-time">{{ formatTime(conversation.lastMessage.lastTime) }}</text>
|
|
|
|
|
+ <view v-if="conversation.unreadCount > 0" class="unread-badge">
|
|
|
|
|
+ {{ conversation.unreadCount > 99 ? '99+' : conversation.unreadCount }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -64,7 +152,9 @@
|
|
|
</view>
|
|
</view>
|
|
|
<view class="tabbar-item message active" @click="navigateToMessage">
|
|
<view class="tabbar-item message active" @click="navigateToMessage">
|
|
|
<view class="tabbar-icon">
|
|
<view class="tabbar-icon">
|
|
|
- <view class="badge">3</view>
|
|
|
|
|
|
|
+ <view v-if="totalUnreadCount > 0" class="badge">
|
|
|
|
|
+ {{ totalUnreadCount > 99 ? '99+' : totalUnreadCount }}
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
<text class="tabbar-text">消息</text>
|
|
<text class="tabbar-text">消息</text>
|
|
|
</view>
|
|
</view>
|
|
@@ -79,6 +169,7 @@
|
|
|
<script>
|
|
<script>
|
|
|
import timManager from '@/utils/tim-manager.js'
|
|
import timManager from '@/utils/tim-manager.js'
|
|
|
import TIM from 'tim-wx-sdk'
|
|
import TIM from 'tim-wx-sdk'
|
|
|
|
|
+ import api from '@/utils/api.js'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
@@ -87,12 +178,56 @@
|
|
|
conversationList: [],
|
|
conversationList: [],
|
|
|
matchmakerInfo: null,
|
|
matchmakerInfo: null,
|
|
|
imUserId: '',
|
|
imUserId: '',
|
|
|
- totalUnreadCount: 0
|
|
|
|
|
|
|
+ totalUnreadCount: 0,
|
|
|
|
|
+ // 系统消息未读数
|
|
|
|
|
+ systemUnread: 0,
|
|
|
|
|
+
|
|
|
|
|
+ // 顶部系统通知占位(后续可从后端加载)
|
|
|
|
|
+ systemNotification: {
|
|
|
|
|
+ title: '系统通知',
|
|
|
|
|
+ content: '您的线索审核已通过,获得20积分奖励,当期积分可兑换【资源查看权限】x1',
|
|
|
|
|
+ footer: '完成线索录采集,积分+20(距离黄金级还差72分)',
|
|
|
|
|
+ timeText: '刚刚'
|
|
|
|
|
+ },
|
|
|
|
|
+ // 撮合成功通知占位
|
|
|
|
|
+ matchSuccessNotification: {
|
|
|
|
|
+ title: '撮合成功通知',
|
|
|
|
|
+ content: '您推荐的李先生和王女士已成功匹配,获得50积分+100元现金奖励',
|
|
|
|
|
+ timeText: '10分钟前'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ // 今天的会话
|
|
|
|
|
+ todayConversations() {
|
|
|
|
|
+ const today = new Date()
|
|
|
|
|
+ return this.conversationList.filter(conv => this.isSameDay(conv.lastMessage, today))
|
|
|
|
|
+ },
|
|
|
|
|
+ // 昨日会话
|
|
|
|
|
+ yesterdayConversations() {
|
|
|
|
|
+ const yesterday = new Date()
|
|
|
|
|
+ yesterday.setDate(yesterday.getDate() - 1)
|
|
|
|
|
+ return this.conversationList.filter(conv => this.isSameDay(conv.lastMessage, yesterday))
|
|
|
|
|
+ },
|
|
|
|
|
+ // 更早会话
|
|
|
|
|
+ earlierConversations() {
|
|
|
|
|
+ const today = new Date()
|
|
|
|
|
+ const yesterday = new Date()
|
|
|
|
|
+ yesterday.setDate(yesterday.getDate() - 1)
|
|
|
|
|
+ return this.conversationList.filter(conv => {
|
|
|
|
|
+ const msg = conv.lastMessage
|
|
|
|
|
+ if (!msg || !msg.lastTime) return false
|
|
|
|
|
+ const isToday = this.isSameDay(msg, today)
|
|
|
|
|
+ const isYesterday = this.isSameDay(msg, yesterday)
|
|
|
|
|
+ return !isToday && !isYesterday
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- async onLoad() {
|
|
|
|
|
- await this.initIM()
|
|
|
|
|
|
|
+ onLoad() {
|
|
|
|
|
+ // 为避免误用用户端 IM 账号,这里不再复用当前 TIM 登录状态,进入页面即按红娘流程重新初始化
|
|
|
|
|
+ console.log('🔍 红娘消息页强制按红娘流程初始化 IM')
|
|
|
|
|
+ this.initIM()
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onShow() {
|
|
onShow() {
|
|
@@ -100,6 +235,8 @@
|
|
|
if (this.imUserId) {
|
|
if (this.imUserId) {
|
|
|
this.loadConversationList()
|
|
this.loadConversationList()
|
|
|
}
|
|
}
|
|
|
|
|
+ // 同步系统消息未读
|
|
|
|
|
+ this.loadSystemUnread()
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onUnload() {
|
|
onUnload() {
|
|
@@ -108,6 +245,77 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // 判断消息是否与给定日期同一天
|
|
|
|
|
+ isSameDay(lastMessage, baseDate) {
|
|
|
|
|
+ if (!lastMessage || !lastMessage.lastTime) return false
|
|
|
|
|
+ const msgDate = new Date(lastMessage.lastTime * 1000)
|
|
|
|
|
+ const d = baseDate instanceof Date ? baseDate : new Date(baseDate)
|
|
|
|
|
+ return (
|
|
|
|
|
+ msgDate.getFullYear() === d.getFullYear() &&
|
|
|
|
|
+ msgDate.getMonth() === d.getMonth() &&
|
|
|
|
|
+ msgDate.getDate() === d.getDate()
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 加载系统消息未读数,并同步最新一条系统通知到顶部卡片
|
|
|
|
|
+ async loadSystemUnread() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const userId = uni.getStorageSync('userId')
|
|
|
|
|
+ if (!userId) return
|
|
|
|
|
+ const count = await api.message.getSystemUnreadCount(userId)
|
|
|
|
|
+ // getSystemUnreadCount 可能返回 {code,data} 或直接 number,这里统一兼容
|
|
|
|
|
+ if (typeof count === 'number') {
|
|
|
|
|
+ this.systemUnread = count
|
|
|
|
|
+ } else if (count && typeof count.data === 'number') {
|
|
|
|
|
+ this.systemUnread = count.data
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 同时拉取最新一条系统通知,用于顶部卡片展示
|
|
|
|
|
+ const res = await api.message.getSystemList(userId, 1, 1)
|
|
|
|
|
+ const list = (res && (res.list || res.data?.list)) || []
|
|
|
|
|
+ if (list.length > 0) {
|
|
|
|
|
+ const item = list[0]
|
|
|
|
|
+ // 计算时间文案
|
|
|
|
|
+ let timeText = ''
|
|
|
|
|
+ const t = item.createdAt || item.created_at
|
|
|
|
|
+ if (t) {
|
|
|
|
|
+ const d2 = new Date(t)
|
|
|
|
|
+ const now = new Date()
|
|
|
|
|
+ const diff = now - d2
|
|
|
|
|
+ if (diff < 60000) {
|
|
|
|
|
+ timeText = '刚刚'
|
|
|
|
|
+ } else if (diff < 3600000) {
|
|
|
|
|
+ timeText = Math.floor(diff / 60000) + '分钟前'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const mm = String(d2.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
+ const dd = String(d2.getDate()).padStart(2, '0')
|
|
|
|
|
+ const hh = String(d2.getHours()).padStart(2, '0')
|
|
|
|
|
+ const mi = String(d2.getMinutes()).padStart(2, '0')
|
|
|
|
|
+ timeText = `${mm}-${dd} ${hh}:${mi}`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 用最新系统通知更新卡片文案(小字显示最新内容)
|
|
|
|
|
+ this.systemNotification = {
|
|
|
|
|
+ ...this.systemNotification,
|
|
|
|
|
+ title: '系统通知',
|
|
|
|
|
+ content: item.title || this.systemNotification.content,
|
|
|
|
|
+ footer: item.content || this.systemNotification.footer,
|
|
|
|
|
+ timeText: timeText || this.systemNotification.timeText
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.log('红娘消息页加载系统未读失败', e)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 跳转系统通知列表
|
|
|
|
|
+ openSystemMessages() {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pages/matchmaker-workbench/system-messages'
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
// 初始化 IM
|
|
// 初始化 IM
|
|
|
async initIM() {
|
|
async initIM() {
|
|
|
try {
|
|
try {
|
|
@@ -181,13 +389,21 @@
|
|
|
// 加载会话列表
|
|
// 加载会话列表
|
|
|
async loadConversationList() {
|
|
async loadConversationList() {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // SDK 未登录 / 未 ready 时不调用会话列表接口,避免报“接口调用时机不合理”
|
|
|
|
|
+ if (!timManager.isLogin || !timManager.tim) {
|
|
|
|
|
+ console.log('⚠️ TIM 未 ready,暂不加载会话列表')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
const tim = timManager.getTim()
|
|
const tim = timManager.getTim()
|
|
|
const { data } = await tim.getConversationList()
|
|
const { data } = await tim.getConversationList()
|
|
|
- this.conversationList = data.conversationList
|
|
|
|
|
|
|
+ this.conversationList = data.conversationList || []
|
|
|
|
|
+
|
|
|
|
|
+ // 补全用户头像和昵称
|
|
|
|
|
+ await this.loadUserAvatars()
|
|
|
|
|
|
|
|
// 计算总未读数
|
|
// 计算总未读数
|
|
|
this.totalUnreadCount = this.conversationList.reduce((total, conv) => {
|
|
this.totalUnreadCount = this.conversationList.reduce((total, conv) => {
|
|
|
- return total + conv.unreadCount
|
|
|
|
|
|
|
+ return total + (conv.unreadCount || 0)
|
|
|
}, 0)
|
|
}, 0)
|
|
|
|
|
|
|
|
console.log('✅ 会话列表:', this.conversationList)
|
|
console.log('✅ 会话列表:', this.conversationList)
|
|
@@ -224,12 +440,84 @@
|
|
|
// 会话列表更新
|
|
// 会话列表更新
|
|
|
onConversationListUpdated(event) {
|
|
onConversationListUpdated(event) {
|
|
|
console.log('🔄 会话列表更新:', event.data)
|
|
console.log('🔄 会话列表更新:', event.data)
|
|
|
- this.conversationList = event.data
|
|
|
|
|
|
|
+ this.conversationList = event.data || []
|
|
|
|
|
|
|
|
- // 更新总未读数
|
|
|
|
|
- this.totalUnreadCount = this.conversationList.reduce((total, conv) => {
|
|
|
|
|
- return total + conv.unreadCount
|
|
|
|
|
- }, 0)
|
|
|
|
|
|
|
+ // 补全头像昵称后再计算未读
|
|
|
|
|
+ this.loadUserAvatars().then(() => {
|
|
|
|
|
+ this.totalUnreadCount = this.conversationList.reduce((total, conv) => {
|
|
|
|
|
+ return total + (conv.unreadCount || 0)
|
|
|
|
|
+ }, 0)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 批量补全用户头像和昵称
|
|
|
|
|
+ async loadUserAvatars() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!this.conversationList || this.conversationList.length === 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 收集对端用户ID(排除红娘 m_ 开头的ID)
|
|
|
|
|
+ const userIds = []
|
|
|
|
|
+ this.conversationList.forEach(conv => {
|
|
|
|
|
+ let targetUserId = ''
|
|
|
|
|
+ if (conv.userProfile && conv.userProfile.userID) {
|
|
|
|
|
+ targetUserId = String(conv.userProfile.userID)
|
|
|
|
|
+ } else if (conv.conversationID && conv.conversationID.indexOf('C2C') === 0) {
|
|
|
|
|
+ targetUserId = conv.conversationID.replace('C2C', '')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!targetUserId) return
|
|
|
|
|
+ if (targetUserId.startsWith('m_')) return
|
|
|
|
|
+ userIds.push(targetUserId)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const uniqueIds = Array.from(new Set(userIds))
|
|
|
|
|
+ if (uniqueIds.length === 0) return
|
|
|
|
|
+
|
|
|
|
|
+ console.log('🔄 红娘消息页批量获取用户信息,数量:', uniqueIds.length)
|
|
|
|
|
+
|
|
|
|
|
+ const res = await uni.request({
|
|
|
|
|
+ url: 'http://localhost:8083/api/user/batch',
|
|
|
|
|
+ method: 'GET',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ userIds: uniqueIds.join(',')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ if (!res[1] || res[1].statusCode !== 200 || res[1].data.code !== 200) {
|
|
|
|
|
+ console.warn('⚠️ 红娘消息页批量获取用户信息失败')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const list = res[1].data.data || []
|
|
|
|
|
+ const userMap = {}
|
|
|
|
|
+ list.forEach(user => {
|
|
|
|
|
+ if (!user || user.userId == null) return
|
|
|
|
|
+ userMap[String(user.userId)] = {
|
|
|
|
|
+ nickname: user.nickname,
|
|
|
|
|
+ avatarUrl: user.avatarUrl
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 回填到会话列表的 userProfile 中
|
|
|
|
|
+ this.conversationList = this.conversationList.map(conv => {
|
|
|
|
|
+ let targetUserId = ''
|
|
|
|
|
+ if (conv.userProfile && conv.userProfile.userID) {
|
|
|
|
|
+ targetUserId = String(conv.userProfile.userID)
|
|
|
|
|
+ } else if (conv.conversationID && conv.conversationID.indexOf('C2C') === 0) {
|
|
|
|
|
+ targetUserId = conv.conversationID.replace('C2C', '')
|
|
|
|
|
+ }
|
|
|
|
|
+ const info = targetUserId ? userMap[targetUserId] : null
|
|
|
|
|
+ if (info) {
|
|
|
|
|
+ conv.userProfile = conv.userProfile || {}
|
|
|
|
|
+ conv.userProfile.nick = info.nickname || conv.userProfile.nick || `用户${targetUserId}`
|
|
|
|
|
+ conv.userProfile.avatar = info.avatarUrl || conv.userProfile.avatar || ''
|
|
|
|
|
+ }
|
|
|
|
|
+ return conv
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('❌ 红娘消息页加载用户头像失败:', error)
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 打开聊天页面
|
|
// 打开聊天页面
|