diff --git a/im-platform/src/main/java/com/bx/implatform/entity/User.java b/im-platform/src/main/java/com/bx/implatform/entity/User.java index a943825..7ea084a 100644 --- a/im-platform/src/main/java/com/bx/implatform/entity/User.java +++ b/im-platform/src/main/java/com/bx/implatform/entity/User.java @@ -124,4 +124,9 @@ public class User { */ private String groupIds; + /** + * 自定义欢迎词 + */ + private String welcomeMsg; + } diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java index ad5f781..d7f9358 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java @@ -301,9 +301,17 @@ public class FriendServiceImpl extends ServiceImpl impleme void sendAddTipMessage(Long friendId) { UserSession session = SessionContext.getSession(); PrivateMessage msg = new PrivateMessage(); + User loginUser = userMapper.selectById(friendId); + if (loginUser == null) { + return; + } + String welcomeMsg = loginUser.getWelcomeMsg(); + if (welcomeMsg == null || welcomeMsg.trim().isEmpty()) { + welcomeMsg = "现在可以开始聊天了"; + } msg.setSendId(session.getUserId()); msg.setRecvId(friendId); - msg.setContent("现在可以开始聊天了"); + msg.setContent(welcomeMsg); msg.setSendTime(new Date()); msg.setStatus(MessageStatus.PENDING.code()); msg.setType(MessageType.TIP_TEXT.code()); diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java index 9dd1860..4988a09 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java @@ -173,7 +173,9 @@ public class UserServiceImpl extends ServiceImpl implements Us // 4. 查一条(false=查不到不抛异常) User customer = this.getOne(queryWrapper, false); - + if (customer == null) { + throw new GlobalException("未找到对应的客服,请检查 uniqueToken 是否正确"); + } // 5. 有客服返回ID,没有返回null return customer == null ? null : customer.getId(); } diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index 00d0ed6..df617c0 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -1246,24 +1246,19 @@ export default { }; this.chatStore.chats.unshift(chat); } - - // ✅ 永久锁定 ID,绝不乱跳 + this.currentTargetId = targetId; this.currentChatType = type; await this.$nextTick(); - - // ✅ 重要:先等待 chat 初始化完成 if (!this.chat) { console.error('Chat 初始化失败'); uni.hideLoading(); return; } - // ✅ 然后再调用需要 chat 的方法 this.readedMessage(); - // 加载好友信息 this.loadFriend(targetId); this.loadReaded(targetId); diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 616bc7b..47886c7 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -151,7 +151,7 @@ :key="item.id" @click="selectQuickReply(item)" > - {{ item.replyContent }} + {{ item.replyName }}
暂无快捷回复 @@ -973,8 +973,6 @@ export default { this.$message.error('标签设置失败'); }); }, - - // ==================== 快捷回复相关 ==================== // 打开快捷回复并加载列表 openQuickReplyBox() { this.showQuickReplyBox = true; @@ -994,6 +992,7 @@ export default { }) .then(res => { if (res && Array.isArray(res)) { + console.log('快捷回复数据:', res); this.quickReplyList = res; } else { this.quickReplyList = []; @@ -1007,42 +1006,8 @@ export default { }); }, // 选择快捷语,插入输入框并发送 - // selectQuickReply(item) { - // if (!item || !item.replyContent) return; - // console.log('item',item) - // // 先清空输入框 - // this.$refs.chatInputEditor.clear(); - - // // 插入快捷回复内容(如果组件有 insertText 或类似方法) - // // 方法1:如果 ChatInput 有 insertText 方法 - // if (this.$refs.chatInputEditor.insertText) { - // this.$refs.chatInputEditor.insertText(item.replyContent); - // } - // // 方法2:如果只能通过设置 content 属性 - // else { - // this.$refs.chatInputEditor.content = item.replyContent; - // } - - // // 关闭弹窗 - // this.showQuickReplyBox = false; - // const fullList = [ - // { - // content: item.replyContent, - // type: item.replyType == 0 ? 'text' : 'image' - // } - // ]; - // // 延迟一点确保内容已设置,然后自动发送 - // this.$nextTick(() => { - // setTimeout(() => { - // this.sendMessage(fullList); - // // this.notifySend(); - // }, 50); - // }); - // } - // 选择快捷语,插入输入框并发送 selectQuickReply(item) { if (!item || !item.replyContent) return; - console.log('快捷回复数据:', item); // 关闭弹窗 this.showQuickReplyBox = false; @@ -1105,7 +1070,7 @@ export default { let imageData = { originUrl: imageUrl, thumbUrl: imageUrl, // 缩略图使用相同URL,或者后端会生成缩略图 - width: 0, // 如果不知道尺寸,设为0 + width: 0, height: 0 };