提交 83221940 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新 统一使用 uniIm.toChat打开新会话,并在必要时携带source

上级 5fc2a1ad
...@@ -158,18 +158,14 @@ ...@@ -158,18 +158,14 @@
}, },
privateChat(user_id) { privateChat(user_id) {
if (this.canPrivateChat) { if (this.canPrivateChat) {
if (uniIm.isWidescreen) { uniIm.toChat({
uni.$emit('uni-im-toChat', { user_id,
user_id source:{
}) group_id: this.msg.group_id
} else { }
uni.navigateTo({
url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + user_id,
animationDuration: 300
}) })
} }
} }
},
} }
} }
</script> </script>
......
...@@ -46,14 +46,12 @@ export default { ...@@ -46,14 +46,12 @@ export default {
}, },
methods: { methods: {
onClick() { onClick() {
if (uniIm.isWidescreen) { uniIm.toChat({
uni.$emit('uni-im-toChat', { user_id: this.msg.body.user_id }) user_id: this.msg.body.user_id,
} else { source:{
uni.navigateTo({ group_id: this.msg.group_id
url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + this.msg.body.user_id,
animationDuration: 300
})
} }
})
}, },
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
{{ friendlyTime }} {{ friendlyTime }}
</text> </text>
</view> </view>
msg.revoke_ing:{{msg.revoke_ing}}
<view class="msg-box"> <view class="msg-box">
<view v-if="msg.is_revoke" class="revoke-text-box"> <view v-if="msg.is_revoke" class="revoke-text-box">
<text class="revoke-text"> <text class="revoke-text">
...@@ -337,17 +338,13 @@ ...@@ -337,17 +338,13 @@
}, },
toChat() { toChat() {
if (this.canPrivateChat) { if (this.canPrivateChat) {
if (uniIm.isWidescreen) { uniIm.toChat({
uni.$emit('uni-im-toChat', { user_id: this.msg.from_uid,
"user_id": this.msg.from_uid source: {
}) group_id: this.msg.group_id
} else { }
uni.navigateTo({
url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + this.msg.from_uid,
animationDuration: 300
}) })
} }
} else {}
}, },
chatInputContentAddcallUser() { chatInputContentAddcallUser() {
if (this.msg.group_id) { if (this.msg.group_id) {
......
...@@ -187,36 +187,7 @@ ...@@ -187,36 +187,7 @@
return uniIm.notification.unreadCount(param) return uniIm.notification.unreadCount(param)
}, },
toChat(item) { toChat(item) {
// console.log('this.isWidescreen',this.isWidescreen) uniIm.toChat({user_id: item._id})
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
})
}
});
}
});
}
}, },
hiddenDeleteBtn() { hiddenDeleteBtn() {
this.activeIndex = false this.activeIndex = false
......
...@@ -57,24 +57,7 @@ ...@@ -57,24 +57,7 @@
}, },
toChat(group_id) { toChat(group_id) {
let conversation_id = 'group_' + group_id let conversation_id = 'group_' + group_id
if(this.isWidescreen){ uniIm.toChat({conversation_id})
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);
}
})
}
})
}
} }
} }
} }
......
...@@ -662,16 +662,12 @@ ...@@ -662,16 +662,12 @@
}, },
toChat(user_id) { toChat(user_id) {
if (this.canPrivateChat) { if (this.canPrivateChat) {
if (uniIm.isWidescreen) { uniIm.toChat({
uni.$emit('uni-im-toChat', { user_id,
user_id source:{
}) group_id: this.conversation.group_id
} else {
uni.navigateTo({
url: '/uni_modules/uni-im/pages/chat/chat?user_id=' + user_id,
animationDuration: 300
})
} }
})
} }
}, },
onClickShowAllMenber() { onClickShowAllMenber() {
......
// 导入当前目录下的模块再导出 import $state from '@/uni_modules/uni-im/sdk/state/index.js';
import {init as indexDB} from './indexDB'
import MsgManager from './MsgManager'
export default { 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
...@@ -2,8 +2,9 @@ import init from './init/index.js'; ...@@ -2,8 +2,9 @@ import init from './init/index.js';
import methods from './methods/index.js'; import methods from './methods/index.js';
import state from './state/index.js'; import state from './state/index.js';
import utils from './utils/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 = []) { mapState(keys = []) {
let obj = {} let obj = {}
keys.forEach((key) => { keys.forEach((key) => {
...@@ -21,3 +22,5 @@ export default utils.deepAssign(state,methods,{init,utils}, { ...@@ -21,3 +22,5 @@ export default utils.deepAssign(state,methods,{init,utils}, {
return obj return obj
} }
}) })
export default uniIm
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册