群解散的本地消息删除,提醒

This commit is contained in:
2022-02-17 12:06:30 +08:00
parent 155d59a6a3
commit 411b1ea349
7 changed files with 42 additions and 21 deletions

View File

@@ -6,10 +6,12 @@
</view> </view>
<view class="content"> <view class="content">
<view class="header"> <view class="header">
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3" class='qun'>[]</text></view> <view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3"
class='qun'>[]</text></view>
<view class="time">{{ item.sentTime|timeCustomCN }}</view> <view class="time">{{ item.sentTime|timeCustomCN }}</view>
</view> </view>
<message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType" :user="item.latestMessage.userInfo" /> <message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType"
:user="item.latestMessage.userInfo" />
</view> </view>
</view> </view>
</template> </template>
@@ -17,10 +19,6 @@
<script> <script>
import messagePreview from './messagePreview' import messagePreview from './messagePreview'
export default { export default {
props: { props: {
item: { item: {
@@ -72,9 +70,9 @@
.name { .name {
font-size: $title-size + 2; font-size: $title-size + 2;
color: #454545; color: #454545;
display: flex; display: flex;
align-items: center; align-items: center;
.qun { .qun {
color: $main-color; color: $main-color;

View File

@@ -23,6 +23,9 @@
</view> </view>
<view class="preview" v-if="msg.objectName=='RC:VideoMsg'"> <view class="preview" v-if="msg.objectName=='RC:VideoMsg'">
<text v-if="conversationType == 3">{{ user.name }}</text>[视频通话] <text v-if="conversationType == 3">{{ user.name }}</text>[视频通话]
</view>
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
[{{ msg.message }}]
</view> </view>
</view> </view>
</template> </template>

View File

@@ -3,7 +3,7 @@
<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-system" v-if="item.senderUserId === '__system__'"> <view class="cell-system" v-if="item.senderUserId === '__system__'">
<text class="text">{{ item.content.content }}</text> <text class="text">{{ item.content.message }}</text>
</view> </view>
<view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']"> <view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square" <u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
@@ -178,8 +178,9 @@
.cell { .cell {
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
.cell-system { .cell-system {
align-items: center; align-items: center;
.text { .text {
font-size: 24rpx; font-size: 24rpx;
color: $text-gray-m; color: $text-gray-m;

View File

@@ -273,6 +273,7 @@
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
dismissGroup(this.targetId).then(res => { dismissGroup(this.targetId).then(res => {
console.log('解散群', res);
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '解散成功' title: '解散成功'

View File

@@ -53,10 +53,10 @@
}, },
onLoad() { onLoad() {
// 好友申请数量 // 好友申请数量
this.checkNewFriendPending() this.checkNewFriendPending()
// 监听新的好友申请 // 监听新的好友申请
uni.$on('onContactNotification', () => { uni.$on('onContactNotification', () => {
this.checkNewFriendPending() this.checkNewFriendPending()
}) })
}, },
onShow() { onShow() {
@@ -76,7 +76,7 @@
}, },
methods: { methods: {
checkNewFriendPending() { checkNewFriendPending() {
im.getPendingList((pendings) => { im.getPendingList((pendings) => {
console.log(pendings); console.log(pendings);
this.hasNewFriends = pendings.length this.hasNewFriends = pendings.length
}) })
@@ -94,9 +94,13 @@
getConversationList() { getConversationList() {
const count = 1000 const count = 1000
const timestamp = 0 const timestamp = 0
RongIMLib.getConversationList([1, 3], count, timestamp, (res) => { RongIMLib.getConversationList([1, 3], count, timestamp, ({
if (res.code === 0) { code,
this.conversations = res.conversations conversations
}) => {
console.log(conversations);
if (code === 0) {
this.conversations = conversations
} }
}) })
}, },

View File

@@ -159,9 +159,22 @@ const addListeners = () => {
}) => { }) => {
console.log('消息删除结果', code) console.log('消息删除结果', code)
}) })
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) { } else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
// 触发一个新好友的通知事件 // 触发一个新好友的通知事件
uni.$emit('onContactNotification', message) uni.$emit('onContactNotification', message)
} else if (message.objectName === RongIMLib.ObjectName.GroupNotification) {
// 解散群
if (message.content.operation === 'Dismiss') {
RongIMLib.cleanHistoryMessages(message.conversationType, message.targetId,
message.sentTime - 1, false, ({
code
}) => {
if (code == 0) {
uni.$emit('onGroupDismiss', message.targetId)
}
})
}
uni.$emit('onReceiveMessage', message)
} }
}) })

View File

@@ -15,7 +15,8 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
'RC:LBSMsg', 'RC:LBSMsg',
'RC:SightMsg', 'RC:SightMsg',
'RC:ReferenceMsg', 'RC:ReferenceMsg',
'RC:CombineMsg' 'RC:CombineMsg',
'RC:GrpNtf'
] ]
RongIMLib.getHistoryMessagesByTimestamp( RongIMLib.getHistoryMessagesByTimestamp(