聊天会话管理1.在插件底部加载会话列表会话缓存已经处理完毕。我们只需要根据腾讯提供的api加载即可。具体定义如下:具体调用代码如下。这里需要注意插件提供的nextSeq参数。因此,我们在第一次执行getConversationList后,需要在回调中记录最新的nextSeqexportdefault{data(){return{nextSeq:0,conversationList:[]}},mounted(){let{data}=awaitthis.$txim.getConversationList(this.nextSeq,999)//需要在这里更新nextSeqthis.nextSeq=data.nextSeqdata.conversationList=data.conversationList||data.conversations让conversationList=data.conversationList.sort((a,b)=>b.lastMessage.timestamp-a.lastMessage.timestamp)this.conversationList=conversationList}}2.删除对话项删除某个对话项。我们使用的API是deleteConversation,也就是删除对话记录的API。请注意,删除会话会同时删除本地保存的聊天记录,请谨慎使用。this.$txim.deleteConversation(conversationID)//这里删除后,不会有事件通知我们你删除了这个会话//所以我们需要自己删除会话列表中的元素,并触发界面刷新this.conversationList.splice(index,1)3.设置会话草稿微信中有一个特殊的情况,就是会话草稿。大致情况如下图所示。这里我们主要使用setConversationDraft方法。这仅用于标记对话项目。MarkhisDraft,无实际作用,仅供本地展示。constconversation=uni.requireNativePlugin("TXIM-Conversation");letconversationID='129308-4291-94810-428190-1238921'letdraftText='draft'conversation.setConversationDraft(conversationID,draftText,res=>{//res=复制代码{type,data,code}console.log(res)})项目开源地址及交流群项目成品效果查看:请点击项目介绍项目开源地址:https://gitee.com/ckong/Zhimi...Uniapp开发交流群:755910061
