提交 046dcc32 编写于 作者: guangjun.yang's avatar guangjun.yang

滚动问题

上级 c834c252
...@@ -470,8 +470,8 @@ export default { ...@@ -470,8 +470,8 @@ export default {
// 处理的消息类型只有5种: // 处理的消息类型只有5种:
// type == TEXT(showType:1) // type == TEXT(showType:1)
// type == image 或 picture(showType:2) // type == image 或 picture(showType:2)
// type == custom时,1 ~ 17: 不支持(showType:5); 18: PDF文件(showType:3); 19: 链接信息(showType:4); // type == custom时,18: PDF文件(showType:3); 19: 链接信息(showType:4); 1 ~ 17: 不支持的消息类型(showType:5);
// directFlag 1: 第一次取数据; 2: 拼接实时消息(unshift); 3: 拼接历史消息(push); // directFlag 1: 第一次取数据; 2: 拼接实时消息(push); 3: 拼接历史消息(unshift);
convertMessageList(messageList, directFlag = 1) { convertMessageList(messageList, directFlag = 1) {
console.log("@@@@@@directFlag@@@@@", directFlag); console.log("@@@@@@directFlag@@@@@", directFlag);
messageList.sort((a, b) => { messageList.sort((a, b) => {
...@@ -547,7 +547,7 @@ export default { ...@@ -547,7 +547,7 @@ export default {
this.messageList = cMessageList; this.messageList = cMessageList;
this.$nextTick(() => { this.$nextTick(() => {
const scrollBoxDom = document.querySelector(".scroll-box"); const scrollBoxDom = document.querySelector(".scroll-box");
scrollBoxDom.scrollTop = 200000; scrollBoxDom.scrollTop = scrollBoxDom.scrollHeight;
}); });
this.currentContinueTimes = this.currentContinueTimes =
this.sessionListData.currentTimestamp - this.sessionListData.currentTimestamp -
...@@ -556,12 +556,17 @@ export default { ...@@ -556,12 +556,17 @@ export default {
continueIntervalId = setInterval(() => { continueIntervalId = setInterval(() => {
this.currentContinueTimes += 1000; this.currentContinueTimes += 1000;
}, 1000); }, 1000);
// 最新消息,要合并CUSTOM类型中,bizType是-1的数据 // 最新消息,要合并CUSTOM类型中,bizType是-1的数据(系统消息)
} else if (directFlag === 2) { } else if (directFlag === 2) {
this.contactForwardMessage(cMessageList); this.contactForwardMessage(cMessageList);
// this.messageList.push(...cMessageList);
} else { } else {
if(cMessageList.length) {
this.messageList.unshift(...cMessageList); this.messageList.unshift(...cMessageList);
this.$nextTick(() => {
const scrollBoxDom = document.querySelector(".scroll-box");
scrollBoxDom.scrollTop = 50;
});
}
} }
// 重新设置历史与实时的时间戳 // 重新设置历史与实时的时间戳
...@@ -584,10 +589,16 @@ export default { ...@@ -584,10 +589,16 @@ export default {
// 接接数据 // 接接数据
contactForwardMessage(cMessageList) { contactForwardMessage(cMessageList) {
cMessageList.forEach(item => {
let content = {}, let content = {},
signature = "", signature = "",
msgIndex = -1,
newMsgList = [],
flag = false;
cMessageList.forEach(item => {
content = {};
signature = "";
msgIndex = -1; msgIndex = -1;
newMsgList = [];
if (item.type.toLowerCase() == "custom") { if (item.type.toLowerCase() == "custom") {
content = JSON.parse(item.content); content = JSON.parse(item.content);
if (content.bizType == -1) { if (content.bizType == -1) {
...@@ -596,17 +607,30 @@ export default { ...@@ -596,17 +607,30 @@ export default {
return m.signature == signature; return m.signature == signature;
}); });
if (msgIndex > -1) { if (msgIndex > -1) {
flag = true;
this.messageList[msgIndex].isErrorMsg = content.content; this.messageList[msgIndex].isErrorMsg = content.content;
this.messageList[msgIndex].isShowErrorMsg = true; this.messageList[msgIndex].isShowErrorMsg = true;
} }
this.$forceUpdate(); this.$forceUpdate();
} else { } else {
this.messageList.push(item); newMsgList.push(item);
} }
} else { } else {
this.messageList.push(item); newMsgList.push(item);
} }
}); });
if(newMsgList.length) {
this.messageList.push(...newMsgList);
}
if(flag || newMsgList.length){
this.$nextTick( () => {
var element = document.querySelector(".scroll-box");
console.log('element.scrollTop, element.scrollHeight', element.scrollTop, element.scrollHeight, element.offsetHeight);
if(element.scrollHeight <= element.scrollTop + element.offsetHeight + 100) {
element.scrollTop = element.scrollHeight - element.offsetHeight;
}
});
}
}, },
// 选择一个会话 // 选择一个会话
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册