diff --git a/components/uni-im-msg/types/rich-text.vue b/components/uni-im-msg/types/rich-text.vue index a41b00ad279974b0b38c61ebdfd4d7d4d2fd9c25..7f913a6e4d033624f910d167cfeb26bc86deeb34 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 31d485695533e3d07fc1bf02d674b589fe99dd48..cd0ba101a51bed9a7de4dd4a05c4cb609a1fc48c 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 f805415f113a75b436b85029ba959b74d54b88a1..ea93e0e8015fb5951ba9100f7f4660f026108884 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 e0cb0eca4dedb560e6879e6da08e4f4a17b858cb..75ee09c9a50cf39a7e6e3d676dd93f919311f6ec 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 9088119cf942013191218b9b034c140cba267ffc..1abd818fb606322ed27fe1cd7107b3cae8b2c08e 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 88e51d58b468c0ba1331aedcb635de1894e7ee21..e40ef9e9d07d02001e517bc8911cb30533427dd5 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 06158dd15d08862a04e20c38999742b5856ed166..c48f7291caa1a2322fa64df45cc496c22ace8aad 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 15125a8cf1e958f4de226c8791276381933df282..074b7114e7fb435109f295c41355e475c9b61f4f 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