Browse Source

修复客服列表页进入聊天详情页无法发送消息的问题

pull/1/head
徐飞洋 3 months ago
parent
commit
0960e67d74
  1. 21
      pages/chat-detail/index.js

21
pages/chat-detail/index.js

@ -14,19 +14,26 @@ Page({
}, },
onLoad: function (options) { onLoad: function (options) {
if (options.id) { // 支持两种参数传递方式:
// 1. 从聊天列表页传递的 id 参数
// 2. 从客服列表页传递的 userId、userName、phone 参数
let chatId = options.id || options.userId;
let managerPhone = options.phone;
if (chatId) {
this.setData({ this.setData({
chatId: options.id, chatId: chatId,
managerPhone: options.id // 直接将chatId作为managerPhone使用,因为聊天列表页传递的是manager_phone managerPhone: managerPhone || options.id // 如果没有直接传递phone,则使用chatId作为fallback
}); });
// 如果有传递name参数,直接使用该名称作为聊天标题 // 如果有传递name或userName参数,使用该名称作为聊天标题
if (options.name) { let chatTitle = options.name || options.userName;
if (chatTitle) {
this.setData({ this.setData({
chatTitle: decodeURIComponent(options.name) chatTitle: decodeURIComponent(chatTitle)
}); });
} else { } else {
// 如果没有传递name参数,加载聊天标题 // 如果没有传递名称参数,加载聊天标题
this.loadChatTitle(); this.loadChatTitle();
} }
} }

Loading…
Cancel
Save