Browse Source

修改快捷回复列表内容

master
[yxf] 1 month ago
parent
commit
57854b3ae0
  1. 5
      im-platform/src/main/java/com/bx/implatform/entity/User.java
  2. 10
      im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java
  3. 4
      im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java
  4. 7
      im-uniapp/pages/chat/chat-box.vue
  5. 41
      im-web/src/components/chat/ChatBox.vue

5
im-platform/src/main/java/com/bx/implatform/entity/User.java

@ -124,4 +124,9 @@ public class User {
*/ */
private String groupIds; private String groupIds;
/**
* 自定义欢迎词
*/
private String welcomeMsg;
} }

10
im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java

@ -301,9 +301,17 @@ public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> impleme
void sendAddTipMessage(Long friendId) { void sendAddTipMessage(Long friendId) {
UserSession session = SessionContext.getSession(); UserSession session = SessionContext.getSession();
PrivateMessage msg = new PrivateMessage(); 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.setSendId(session.getUserId());
msg.setRecvId(friendId); msg.setRecvId(friendId);
msg.setContent("现在可以开始聊天了"); msg.setContent(welcomeMsg);
msg.setSendTime(new Date()); msg.setSendTime(new Date());
msg.setStatus(MessageStatus.PENDING.code()); msg.setStatus(MessageStatus.PENDING.code());
msg.setType(MessageType.TIP_TEXT.code()); msg.setType(MessageType.TIP_TEXT.code());

4
im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java

@ -173,7 +173,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
// 4. 查一条(false=查不到不抛异常) // 4. 查一条(false=查不到不抛异常)
User customer = this.getOne(queryWrapper, false); User customer = this.getOne(queryWrapper, false);
if (customer == null) {
throw new GlobalException("未找到对应的客服,请检查 uniqueToken 是否正确");
}
// 5. 有客服返回ID,没有返回null // 5. 有客服返回ID,没有返回null
return customer == null ? null : customer.getId(); return customer == null ? null : customer.getId();
} }

7
im-uniapp/pages/chat/chat-box.vue

@ -1246,24 +1246,19 @@ export default {
}; };
this.chatStore.chats.unshift(chat); this.chatStore.chats.unshift(chat);
} }
// ID
this.currentTargetId = targetId; this.currentTargetId = targetId;
this.currentChatType = type; this.currentChatType = type;
await this.$nextTick(); await this.$nextTick();
// chat
if (!this.chat) { if (!this.chat) {
console.error('Chat 初始化失败'); console.error('Chat 初始化失败');
uni.hideLoading(); uni.hideLoading();
return; return;
} }
// chat
this.readedMessage(); this.readedMessage();
//
this.loadFriend(targetId); this.loadFriend(targetId);
this.loadReaded(targetId); this.loadReaded(targetId);

41
im-web/src/components/chat/ChatBox.vue

@ -151,7 +151,7 @@
:key="item.id" :key="item.id"
@click="selectQuickReply(item)" @click="selectQuickReply(item)"
> >
{{ item.replyContent }} {{ item.replyName }}
</div> </div>
<div class="quick-empty" v-if="quickReplyList.length === 0 && !quickLoading"> <div class="quick-empty" v-if="quickReplyList.length === 0 && !quickLoading">
暂无快捷回复 暂无快捷回复
@ -973,8 +973,6 @@ export default {
this.$message.error('标签设置失败'); this.$message.error('标签设置失败');
}); });
}, },
// ==================== ====================
// //
openQuickReplyBox() { openQuickReplyBox() {
this.showQuickReplyBox = true; this.showQuickReplyBox = true;
@ -994,6 +992,7 @@ export default {
}) })
.then(res => { .then(res => {
if (res && Array.isArray(res)) { if (res && Array.isArray(res)) {
console.log('快捷回复数据:', res);
this.quickReplyList = res; this.quickReplyList = res;
} else { } else {
this.quickReplyList = []; 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) { selectQuickReply(item) {
if (!item || !item.replyContent) return; if (!item || !item.replyContent) return;
console.log('快捷回复数据:', item);
// //
this.showQuickReplyBox = false; this.showQuickReplyBox = false;
@ -1105,7 +1070,7 @@ export default {
let imageData = { let imageData = {
originUrl: imageUrl, originUrl: imageUrl,
thumbUrl: imageUrl, // 使URL thumbUrl: imageUrl, // 使URL
width: 0, // 0 width: 0,
height: 0 height: 0
}; };

Loading…
Cancel
Save