解决时间戳不一致的问题
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
<list class="body" :show-scrollbar="false">
|
<list class="body" :show-scrollbar="false">
|
||||||
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
||||||
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square" :src="item.content.userInfo.portraitUrl" />
|
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
||||||
|
:src="item.content.userInfo.portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||||
:msg="item.content" :name="item.content.userInfo.name" />
|
:msg="item.content" :name="item.content.userInfo.name" />
|
||||||
@@ -43,13 +44,18 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
targetId: '',
|
targetId: '',
|
||||||
conversationType: 3,
|
conversationType: RongIMLib.ConversationType.GROUP,
|
||||||
messages: [],
|
messages: [],
|
||||||
groupInfo: {
|
groupInfo: {
|
||||||
name: ''
|
name: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
latestMessage() {
|
||||||
|
return this.messages[this.messages.length - 1]
|
||||||
|
}
|
||||||
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.targetId = e.targetId
|
this.targetId = e.targetId
|
||||||
this.groupInfo = this.$store.getters.contactInfo(this.targetId)
|
this.groupInfo = this.$store.getters.contactInfo(this.targetId)
|
||||||
@@ -64,10 +70,6 @@
|
|||||||
})
|
})
|
||||||
uni.$once('cleanGroupMessage', this.getMessageList)
|
uni.$once('cleanGroupMessage', this.getMessageList)
|
||||||
},
|
},
|
||||||
onBackPress() {
|
|
||||||
uni.$off('onReceiveMessage')
|
|
||||||
console.log('Off onReceiveMessage');
|
|
||||||
},
|
|
||||||
onNavigationBarButtonTap() {
|
onNavigationBarButtonTap() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/group/info?targetId=' + this.targetId
|
url: '/pages/im/group/info?targetId=' + this.targetId
|
||||||
@@ -82,18 +84,18 @@
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/friends/mine?targetId=' + item.senderUserId
|
url: '/pages/im/friends/mine?targetId=' + item.senderUserId
|
||||||
})
|
})
|
||||||
} else{
|
} else {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/friends/info?targetId=' + item.senderUserId
|
url: '/pages/im/friends/info?targetId=' + item.senderUserId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getNewMessage() {
|
getNewMessage() {
|
||||||
im.getMessageList(
|
im.getMessageList(
|
||||||
this.conversationType,
|
this.conversationType,
|
||||||
this.targetId,
|
this.targetId,
|
||||||
new Date().getTime(),
|
this.latestMessage.sentTime,
|
||||||
10,
|
1,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
this.messages = this.messages.concat(messages)
|
this.messages = this.messages.concat(messages)
|
||||||
@@ -105,7 +107,7 @@
|
|||||||
im.getMessageList(
|
im.getMessageList(
|
||||||
this.conversationType,
|
this.conversationType,
|
||||||
this.targetId,
|
this.targetId,
|
||||||
new Date().getTime(),
|
0,
|
||||||
100,
|
100,
|
||||||
true,
|
true,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
@@ -115,12 +117,15 @@
|
|||||||
},
|
},
|
||||||
// 滚动到底部
|
// 滚动到底部
|
||||||
scrollBottom(type) {
|
scrollBottom(type) {
|
||||||
// 清理当前会话,未读消息数量
|
if (this.latestMessage) {
|
||||||
RongIMLib.clearMessagesUnreadStatus(this.conversationType, this.targetId, new Date().getTime() + 1100)
|
// 清理当前会话,未读消息数量
|
||||||
// 发送消息已读状态给对方
|
RongIMLib.clearMessagesUnreadStatus(this.conversationType, this.targetId, this.latestMessage
|
||||||
RongIMLib.sendReadReceiptMessage(this.conversationType, this.targetId, new Date().getTime())
|
.sentTime)
|
||||||
// 更新badge提醒数量
|
// // 发送消息已读状态给对方
|
||||||
im.setNotifyBadge()
|
// RongIMLib.sendReadReceiptMessage(this.conversationType, this.targetId, this.latestMessage.sentTime)
|
||||||
|
// 更新badge提醒数量
|
||||||
|
im.setNotifyBadge()
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let el = this.$refs.chatBottom
|
let el = this.$refs.chatBottom
|
||||||
|
|||||||
@@ -42,6 +42,12 @@
|
|||||||
const ChatList = uni.requireNativePlugin('dom')
|
const ChatList = uni.requireNativePlugin('dom')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
sentMessageBar,
|
||||||
|
showVoice,
|
||||||
|
showImage,
|
||||||
|
showText
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
targetId: '',
|
targetId: '',
|
||||||
@@ -54,11 +60,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
computed: {
|
||||||
sentMessageBar,
|
latestMessage() {
|
||||||
showVoice,
|
return this.messages[this.messages.length - 1]
|
||||||
showImage,
|
}
|
||||||
showText
|
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.targetId = e.targetId
|
this.targetId = e.targetId
|
||||||
@@ -98,8 +103,8 @@
|
|||||||
im.getMessageList(
|
im.getMessageList(
|
||||||
this.conversationType,
|
this.conversationType,
|
||||||
this.targetId,
|
this.targetId,
|
||||||
new Date().getTime(),
|
this.latestMessage.sentTime,
|
||||||
10,
|
1,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
this.messages = this.messages.concat(messages)
|
this.messages = this.messages.concat(messages)
|
||||||
@@ -111,7 +116,7 @@
|
|||||||
im.getMessageList(
|
im.getMessageList(
|
||||||
this.conversationType,
|
this.conversationType,
|
||||||
this.targetId,
|
this.targetId,
|
||||||
new Date().getTime(),
|
0,
|
||||||
100,
|
100,
|
||||||
true,
|
true,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
@@ -128,12 +133,15 @@
|
|||||||
},
|
},
|
||||||
// 滚动到底部
|
// 滚动到底部
|
||||||
scrollBottom(type) {
|
scrollBottom(type) {
|
||||||
// 清理当前会话,未读消息数量
|
if (this.latestMessage) {
|
||||||
RongIMLib.clearMessagesUnreadStatus(this.conversationType, this.targetId, new Date().getTime())
|
// 清理当前会话,未读消息数量
|
||||||
// 发送消息已读状态给对方
|
RongIMLib.clearMessagesUnreadStatus(this.conversationType, this.targetId, this.latestMessage
|
||||||
RongIMLib.sendReadReceiptMessage(this.conversationType, this.targetId, new Date().getTime())
|
.sentTime)
|
||||||
// 更新badge提醒数量
|
// // 发送消息已读状态给对方
|
||||||
im.setNotifyBadge()
|
RongIMLib.sendReadReceiptMessage(this.conversationType, this.targetId, this.latestMessage.sentTime)
|
||||||
|
// 更新badge提醒数量
|
||||||
|
im.setNotifyBadge()
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let el = this.$refs.chatBottom
|
let el = this.$refs.chatBottom
|
||||||
ChatList.scrollToElement(el, {
|
ChatList.scrollToElement(el, {
|
||||||
|
|||||||
Reference in New Issue
Block a user