Browse Source

修复聊天详情页从客服页面进入时数据不刷新的问题

pull/1/head
徐飞洋 3 months ago
parent
commit
38f285f2b0
  1. 9
      pages/chat-detail/index.js

9
pages/chat-detail/index.js

@ -151,8 +151,12 @@ Page({
} }
} }
// 重要修复:当有managerPhone时,应该使用managerPhone作为chatId传递给服务器
// 因为服务器端查询需要的是手机号,而不是客服人员的ID
const chatIdForApi = this.data.managerPhone || this.data.chatId;
// 使用新添加的API获取聊天记录 // 使用新添加的API获取聊天记录
API.getChatMessages(this.data.chatId, userPhone).then(res => { API.getChatMessages(chatIdForApi, userPhone).then(res => {
if (Array.isArray(res)) { if (Array.isArray(res)) {
// 处理每条消息,确定发送者和格式化时间 // 处理每条消息,确定发送者和格式化时间
const processedMessages = res.map(message => { const processedMessages = res.map(message => {
@ -256,7 +260,8 @@ Page({
const earliestTime = this.data.messages.length > 0 ? this.data.messages[0].originalTime : null; const earliestTime = this.data.messages.length > 0 ? this.data.messages[0].originalTime : null;
// 使用API获取更多聊天记录(带分页参数) // 使用API获取更多聊天记录(带分页参数)
API.getChatMessages(this.data.chatId, userPhone, { before: earliestTime }).then(res => { const chatIdForApi = this.data.managerPhone || this.data.chatId;
API.getChatMessages(chatIdForApi, userPhone, { before: earliestTime }).then(res => {
if (Array.isArray(res) && res.length > 0) { if (Array.isArray(res) && res.length > 0) {
// 处理每条消息,确定发送者和格式化时间 // 处理每条消息,确定发送者和格式化时间
const processedMessages = res.map(message => { const processedMessages = res.map(message => {

Loading…
Cancel
Save