提交 cd02a5f0 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 优化多个会话切换的草稿功能,提升性能

上级 e1b28dd3
...@@ -253,7 +253,9 @@ ...@@ -253,7 +253,9 @@
aboutUserKeyword: '', aboutUserKeyword: '',
memberListScrollTop: 0, memberListScrollTop: 0,
chooseMoreMsg: false, chooseMoreMsg: false,
checkedMsgList: [] checkedMsgList: [],
// 聊天输入框内容
chatInputContent: '',
}; };
}, },
props: { props: {
...@@ -319,24 +321,6 @@ ...@@ -319,24 +321,6 @@
}) })
}, },
//聊天数据 //聊天数据
//当前会话的聊天框文字内容
chatInputContent: {
get() {
// console.log('this.conversation',this.conversation);
return this.conversation?.chatInputContent || '';
},
set(chatInputContent) {
// #ifdef APP-NVUE
if(this.nvueSetChatInputContent){
clearTimeout(this.nvueSetChatInputContent)
}
this.nvueSetChatInputContent = setTimeout(()=>this.conversation.chatInputContent = chatInputContent,1000)
// #endif
// #ifndef APP-NVUE
this.conversation.chatInputContent = chatInputContent
// #endif
}
},
canSend() { canSend() {
if(typeof this.chatInputContent === 'string'){ if(typeof this.chatInputContent === 'string'){
return this.chatInputContent.trim() != '' return this.chatInputContent.trim() != ''
...@@ -577,14 +561,14 @@ ...@@ -577,14 +561,14 @@
}, },
onUnload() { onUnload() {
// console.log('onUnload'); // console.log('onUnload');
// 关闭监听消息推送事件 // 关闭监听消息推送事件
uniIm.offMsg(this.onImMsg); uniIm.offMsg(this.onImMsg);
// #ifndef H5 // #ifndef H5
uni.offKeyboardHeightChange(this.onKeyboardHeightChange) uni.offKeyboardHeightChange(this.onKeyboardHeightChange)
// #endif // #endif
//页面销毁之前销毁 全局变量 正在聊天的用户的id //页面销毁之前销毁 全局变量 正在聊天的用户的id
uniIm.currentConversationId = false uniIm.currentConversationId = false
// console.log('beforeDestroy'); // console.log('beforeDestroy');
...@@ -660,9 +644,15 @@ ...@@ -660,9 +644,15 @@
async load(param) { async load(param) {
this.answerMsg = false this.answerMsg = false
// conversation_id = "single_eff0518ad35e16a8a025cc8af03e0388" // conversation_id = "single_eff0518ad35e16a8a025cc8af03e0388"
if(this.conversation.id){
// 设置(含清空)上一个会话的chatInputContent 实现多个会话之间的草稿功能
this.conversation.chatInputContent = this.chatInputContent
}
// console.log('conversation_id',conversation_id); // console.log('conversation_id',conversation_id);
this.conversation = await uniIm.conversation.get(param) this.conversation = await uniIm.conversation.get(param)
// 初始化会话的chatInputContent
this.chatInputContent = this.conversation.chatInputContent
// this.conversation.call_list = [] // this.conversation.call_list = []
// console.log('this.conversation',this.conversation) // console.log('this.conversation',this.conversation)
...@@ -1118,10 +1108,7 @@ ...@@ -1118,10 +1108,7 @@
msg.body = msg.body.trim(); msg.body = msg.body.trim();
// 阻止发送空消息 // 阻止发送空消息
if (!msg.body.length) { if (!msg.body.length) {
this.$nextTick(() => { this.resetChatInput()
this.chatInputContent = '';
this.textareaHeight = 26;
});
return uni.showToast({ return uni.showToast({
title: '不能发送空消息', title: '不能发送空消息',
icon: 'none' icon: 'none'
...@@ -1162,12 +1149,6 @@ ...@@ -1162,12 +1149,6 @@
}) })
} }
} }
this.$nextTick(e => {
this.chatInputContent = '';
this.textareaHeight = 26;
this.answerMsg = false
});
//如果是回复某一条消息,需要带上相关id //如果是回复某一条消息,需要带上相关id
if (this.answerMsg !== false) { if (this.answerMsg !== false) {
...@@ -1176,6 +1157,8 @@ ...@@ -1176,6 +1157,8 @@
// 消息列表追加此消息。此时消息状态值为0,表示发送中 // 消息列表追加此消息。此时消息状态值为0,表示发送中
let resMsg = this.conversation.msgList.push(msg) let resMsg = this.conversation.msgList.push(msg)
this.resetChatInput()
this.$nextTick(() => { this.$nextTick(() => {
this.showLast() this.showLast()
...@@ -1197,6 +1180,12 @@ ...@@ -1197,6 +1180,12 @@
return msg; return msg;
} }
}, },
resetChatInput() {
this.chatInputContent = ''
this.textareaHeight = 26
// 关闭引用的消息
this.answerMsg = false
},
getCallUid(param){ getCallUid(param){
let aboutNicknameList = [] let aboutNicknameList = []
if( this.isWidescreen){ if( this.isWidescreen){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册