From 8322194057aff6fcdd13f4913b0d4354a1374277 Mon Sep 17 00:00:00 2001 From: DCloud_JSON Date: Thu, 25 Apr 2024 14:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20uniIm.toChat=E6=89=93=E5=BC=80=E6=96=B0?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E6=97=B6=E6=90=BA=E5=B8=A6source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/uni-im-msg/types/rich-text.vue | 20 +++++------- components/uni-im-msg/types/userinfo-card.vue | 14 ++++----- components/uni-im-msg/uni-im-msg.vue | 19 +++++------- pages/contacts/contacts.nvue | 31 +------------------ pages/contacts/groupList/groupList.nvue | 19 +----------- pages/group/members.nvue | 16 ++++------ sdk/ext/index.js | 16 ++++++++-- sdk/index.js | 7 +++-- 8 files changed, 48 insertions(+), 94 deletions(-) diff --git a/components/uni-im-msg/types/rich-text.vue b/components/uni-im-msg/types/rich-text.vue index a41b00a..7f913a6 100644 --- a/components/uni-im-msg/types/rich-text.vue +++ b/components/uni-im-msg/types/rich-text.vue @@ -157,19 +157,15 @@ }) }, privateChat(user_id) { - if (this.canPrivateChat) { - if (uniIm.isWidescreen) { - uni.$emit('uni-im-toChat', { - user_id - }) - } else { - uni.navigateTo({ - url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + user_id, - animationDuration: 300 - }) - } + if (this.canPrivateChat) { + uniIm.toChat({ + user_id, + source:{ + group_id: this.msg.group_id + } + }) } - }, + } } } diff --git a/components/uni-im-msg/types/userinfo-card.vue b/components/uni-im-msg/types/userinfo-card.vue index 31d4856..cd0ba10 100644 --- a/components/uni-im-msg/types/userinfo-card.vue +++ b/components/uni-im-msg/types/userinfo-card.vue @@ -46,14 +46,12 @@ export default { }, methods: { onClick() { - if (uniIm.isWidescreen) { - uni.$emit('uni-im-toChat', { user_id: this.msg.body.user_id }) - } else { - uni.navigateTo({ - url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + this.msg.body.user_id, - animationDuration: 300 - }) - } + uniIm.toChat({ + user_id: this.msg.body.user_id, + source:{ + group_id: this.msg.group_id + } + }) }, } } diff --git a/components/uni-im-msg/uni-im-msg.vue b/components/uni-im-msg/uni-im-msg.vue index f805415..ea93e0e 100644 --- a/components/uni-im-msg/uni-im-msg.vue +++ b/components/uni-im-msg/uni-im-msg.vue @@ -7,6 +7,7 @@ {{ friendlyTime }} + msg.revoke_ing:{{msg.revoke_ing}} @@ -337,17 +338,13 @@ }, toChat() { if (this.canPrivateChat) { - if (uniIm.isWidescreen) { - uni.$emit('uni-im-toChat', { - "user_id": this.msg.from_uid - }) - } else { - uni.navigateTo({ - url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + this.msg.from_uid, - animationDuration: 300 - }) - } - } else {} + uniIm.toChat({ + user_id: this.msg.from_uid, + source: { + group_id: this.msg.group_id + } + }) + } }, chatInputContentAddcallUser() { if (this.msg.group_id) { diff --git a/pages/contacts/contacts.nvue b/pages/contacts/contacts.nvue index e0cb0ec..75ee09c 100644 --- a/pages/contacts/contacts.nvue +++ b/pages/contacts/contacts.nvue @@ -187,36 +187,7 @@ return uniIm.notification.unreadCount(param) }, toChat(item) { - // console.log('this.isWidescreen',this.isWidescreen) - if (this.isWidescreen) { - //若为宽屏,则触发右侧详情页的自定义事件,通知右侧窗体刷新详情 - uni.$emit('uni-im-toChat', { - user_id: item._id - }) - } else { - // 若为窄屏,则打开新窗体,在新窗体打开详情页面 - openPages('/uni_modules/uni-im/pages/chat/chat?user_id=' + item._id); - } - - function openPages(url) { - uni.navigateTo({ - url, - fail: (err1) => { - console.log({ - err1 - }); - uni.switchTab({ - url, - fail: (err2) => { - console.error({ - err1, - err2 - }) - } - }); - } - }); - } + uniIm.toChat({user_id: item._id}) }, hiddenDeleteBtn() { this.activeIndex = false diff --git a/pages/contacts/groupList/groupList.nvue b/pages/contacts/groupList/groupList.nvue index 9088119..1abd818 100644 --- a/pages/contacts/groupList/groupList.nvue +++ b/pages/contacts/groupList/groupList.nvue @@ -57,24 +57,7 @@ }, toChat(group_id) { let conversation_id = 'group_' + group_id - if(this.isWidescreen){ - uni.$emit('uni-im-toChat',conversation_id) - }else{ - let url = "/uni_modules/uni-im/pages/chat/chat?conversation_id=" + conversation_id - uni.navigateTo({ - url, - animationDuration: 300, - fail: (error1) => { - uni.switchTab({ - url, - animationDuration: 300, - fail: (error2) => { - console.error(error1,error2); - } - }) - } - }) - } + uniIm.toChat({conversation_id}) } } } diff --git a/pages/group/members.nvue b/pages/group/members.nvue index 88e51d5..e40ef9e 100644 --- a/pages/group/members.nvue +++ b/pages/group/members.nvue @@ -662,16 +662,12 @@ }, toChat(user_id) { if (this.canPrivateChat) { - if (uniIm.isWidescreen) { - uni.$emit('uni-im-toChat', { - user_id - }) - } else { - uni.navigateTo({ - url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + user_id, - animationDuration: 300 - }) - } + uniIm.toChat({ + user_id, + source:{ + group_id: this.conversation.group_id + } + }) } }, onClickShowAllMenber() { diff --git a/sdk/ext/index.js b/sdk/ext/index.js index 06158dd..c48f729 100644 --- a/sdk/ext/index.js +++ b/sdk/ext/index.js @@ -1,5 +1,15 @@ -// 导入当前目录下的模块再导出 -import {init as indexDB} from './indexDB' -import MsgManager from './MsgManager' +import $state from '@/uni_modules/uni-im/sdk/state/index.js'; export default { + toChat(param) { + console.error('toChat', param,$state) + if ($state.isWidescreen) { + uni.$emit('uni-im-toChat', param) + } else { + let url = '/uni_modules/uni-im/pages/chat/chat?user_id=' + user_id + if (param.source) { + url += '&source=' + decodeURIComponent(JSON.stringify(param.source)) + } + uni.navigateTo({url,animationDuration: 300}) + } + }, } \ No newline at end of file diff --git a/sdk/index.js b/sdk/index.js index 15125a8..074b711 100644 --- a/sdk/index.js +++ b/sdk/index.js @@ -2,8 +2,9 @@ import init from './init/index.js'; import methods from './methods/index.js'; import state from './state/index.js'; import utils from './utils/index.js'; +import ext from './ext/index.js'; -export default utils.deepAssign(state,methods,{init,utils}, { +const uniIm = utils.deepAssign(state,methods,{init,utils},ext,{ mapState(keys = []) { let obj = {} keys.forEach((key) => { @@ -20,4 +21,6 @@ export default utils.deepAssign(state,methods,{init,utils}, { }) return obj } -}) \ No newline at end of file +}) + +export default uniIm \ No newline at end of file -- GitLab