diff --git a/pages/index/index.nvue b/pages/index/index.nvue index 99db0d2e6a7d82c3d2355b954176d59cc3157320..2d650c979c9525ea4a5296adedf85f7f7f6b3bb2 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 81824bd2baf053e7f8b25268bfb54b6c5f5d9e96..dea574b0126f8bd8cb7af4c82086aa4b7e220fe1 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)