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

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

上级 5fc2a1ad
......@@ -158,18 +158,14 @@
},
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
uniIm.toChat({
user_id,
source:{
group_id: this.msg.group_id
}
})
}
}
},
}
}
</script>
......
......@@ -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
}
})
},
}
}
......
......@@ -7,6 +7,7 @@
{{ friendlyTime }}
</text>
</view>
msg.revoke_ing:{{msg.revoke_ing}}
<view class="msg-box">
<view v-if="msg.is_revoke" class="revoke-text-box">
<text class="revoke-text">
......@@ -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
uniIm.toChat({
user_id: this.msg.from_uid,
source: {
group_id: this.msg.group_id
}
})
}
} else {}
},
chatInputContentAddcallUser() {
if (this.msg.group_id) {
......
......@@ -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
......
......@@ -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})
}
}
}
......
......@@ -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() {
......
// 导入当前目录下的模块再导出
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
......@@ -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) => {
......@@ -21,3 +22,5 @@ export default utils.deepAssign(state,methods,{init,utils}, {
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.
先完成此消息的编辑!
想要评论请 注册