From 75900adf634c0149e4e6ced3ff9ad2d8f2998207 Mon Sep 17 00:00:00 2001 From: DCloud_JSON Date: Wed, 15 May 2024 16:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=85=E5=9C=A8?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E5=88=97=E8=A1=A8=E7=82=B9=E5=BC=80=E2=80=9C?= =?UTF-8?q?=E7=BE=A4=E2=80=9D=E4=BC=9A=E8=AF=9D=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.nvue | 65 +++++++++++++------------------ sdk/methods/conversation/index.js | 10 ++--- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/pages/index/index.nvue b/pages/index/index.nvue index 99db0d2..2d650c9 100644 --- a/pages/index/index.nvue +++ b/pages/index/index.nvue @@ -551,47 +551,22 @@ async toChat(param) { this.chatInfoIsShow = false; // console.log('toChat param',param); - let conversation_id = '' - if (typeof param == 'string') { - conversation_id = param - } else { - if (param.conversation_id) { - conversation_id = param.conversation_id - } else if (param.group_id) { - conversation_id = 'group_' + param.group_id - } else if (param.user_id || param.friend_uid) { - conversation_id = (await uniIm.conversation.get(param)).id - // console.log('conversation_id',conversation_id) - // // #ifdef H5 - // setTimeout(async ()=>{ - // const query = uni.createSelectorQuery().in(this); - // query.select('#'+conversation_id).boundingClientRect(data => { - // if(!data){ - // // console.log('找不到 showMsgByIndex #'+conversation_id); - // return - // }else{ - // // console.log(data); - // } - // let listHeight = document.querySelector('#user-list-box').clientHeight - // if(data.top - 70 < listHeight){ - // return - // } - // this.listScrollTop = '' - // this.$nextTick(()=>{ - // this.listScrollTop = currentScrollTop - listHeight + data.top + data.height - // // console.log('this.listScrollTop',this.listScrollTop); - // }) - // }).exec() - // },0); - // // #endif - } else { - throw new Error("toChat param is error") - } - } + let conversation_id = getConversationId(param) this.keyword = '' this.filteredConversationId = false uniIm.currentConversationId = conversation_id + + console.log('conversation_id',conversation_id); + + if(conversation_id.indexOf('group_') === 0){ + uni.showLoading({ + title: '加载中', + mask: false + }); + const conversation = await uniIm.conversation.get(conversation_id) + uni.hideLoading() + } if (this.isWidescreen) { // 若为宽屏,则切换右侧的组件 this.$nextTick(() => { @@ -606,6 +581,22 @@ animationDuration: 300 }) } + + function getConversationId(param){ + if (typeof param == 'string') { + return param + } else { + if (param.conversation_id) { + return param.conversation_id + } else if (param.group_id) { + return 'group_' + param.group_id + } else if (param.user_id || param.friend_uid) { + return uniIm.utils.getConversationId(param.user_id || param.friend_uid) + } else { + throw new Error("toChat param is error") + } + } + } }, showChatInfo() { this.chatInfoIsShow = !this.chatInfoIsShow diff --git a/sdk/methods/conversation/index.js b/sdk/methods/conversation/index.js index 81824bd..dea574b 100644 --- a/sdk/methods/conversation/index.js +++ b/sdk/methods/conversation/index.js @@ -118,12 +118,12 @@ export default { // 指定获取某个id的群会话时,判断如果群会话的 群成员为空就从云端拉取 if (conversationData.group_id && Object.keys(conversationData.group_member).length == 0 && !conversationData .leave) { - uni.showLoading({ - title: '加载中', - mask: true - }); + // uni.showLoading({ + // title: '加载中', + // mask: true + // }); await $group.loadMember(conversationData.group_id) - uni.hideLoading() + // uni.hideLoading() } // console.log('conversationData*-*--*-**-',conversationData) -- GitLab