This commit is contained in:
2022-02-18 14:39:51 +08:00
7 changed files with 41 additions and 29 deletions

View File

@@ -373,9 +373,7 @@
{
"path": "pages/im/private/chat",
"style": {
"disableScroll": true,
"navigationBarTitleText": "聊天",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F3F6FB"
}
},

View File

@@ -20,7 +20,7 @@
:src="contact(friendItem.targetId).portraitUrl" />
<view class="info">
<view class="name">{{ contact(friendItem.targetId).name }}</view>
<!-- <view class="address">Hash:{{ friendItem.address }}</view> -->
<!-- <view class="address">地址:{{ friendItem.address }}</view> -->
</view>
</view>
</u-index-item>
@@ -66,13 +66,8 @@
})
},
checkNewFriendPending() {
// 获取是否有新的好友申请
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
if (res.code === 0) {
this.pendingCount = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification
}).length
}
im.getPendingList((pendings) => {
this.pendingCount = pendings.length
})
},
toGroup() {

View File

@@ -15,7 +15,7 @@
<script>
import applyCell from '../components/friendApplyCell'
import im from '@/utils/im/index.js'
export default {
components: {
applyCell

View File

@@ -17,9 +17,9 @@
</view>
</view>
</view>
</view>
</view>
<!-- content -->
<view v-if="$store.state.token !== ''">
<view v-if="$store.state.token !== ''">
<connection-status :connection="connection" />
<conversation-list @refresh="getConversationList()" :conversations="conversations" />
</view>
@@ -38,7 +38,7 @@
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js'
import userAuth from '@/public/userAuth'
import conversationList from './components/conversationList'
import conversationList from './components/conversationList'
import connectionStatus from './components/connectionStatus'
export default {
@@ -50,7 +50,7 @@
}
},
components: {
conversationList,
conversationList,
connectionStatus
},
onLoad() {
@@ -99,7 +99,7 @@
code,
conversations
}) => {
if (code === 0) {
if (code === 0) {
this.conversations = conversations
}
})

View File

@@ -2,10 +2,11 @@
<view class="chat">
<!-- chat -->
<view class="body">
<view class="cell" v-for="(item, index) in messages" :key="index">
<view class="cell" v-for="(item, index) in messages" :key="index">
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
<view :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
<u-avatar class="avatar" size="40" shape="square" @click="showUser(item.senderUserId, item.messageDirection)"
<u-avatar class="avatar" size="40" shape="square"
@click="showUser(item.senderUserId, item.messageDirection)"
:src="contact(item.senderUserId).portraitUrl" />
<view class="msg">
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
@@ -56,7 +57,7 @@
computed: {
latestMessage() {
if (this.messages.length) {
return this.messages[this.messages.length - 1]
return this.messages[0]
} else {
return {
sentTime: 0
@@ -108,7 +109,8 @@
1,
false,
(messages) => {
this.messages.unshift(...messages)
console.log(messages);
this.messages.unshift(...messages)
// this.scrollBottom()
})
},
@@ -158,20 +160,19 @@
<style scoped lang="scss">
/* 窗口 */
.chat {
background: $window-color;
height: 100vh;
display: flex;
flex-direction: column;
overflow: scroll;
.body {
flex: 1;
overflow-y: scroll;
display: flex;
flex-direction: column-reverse;
.body {
flex: 1;
display: flex;
flex-direction: column-reverse;
justify-content: flex-end;
.cell {
padding: 10rpx 30rpx;
padding: 10rpx 30rpx;
.time {
text-align: center;

View File

@@ -69,7 +69,8 @@ const imLibListeners = () => {
store.dispatch('updateContact', JSON.parse(message.content.data))
// 调用完更新之后,删除这条消息
IMLib.deleteMessagesByIds([message.messageId])
} else if (message.objectName === IMLib.ObjectName.ContactNotification) {
} else if (message.objectName === IMLib.ObjectName.ContactNotification) {
console.error('触发一个新好友的通知事件', message);
// 触发一个新好友的通知事件
uni.$emit('onContactNotification', message)
} else if (message.objectName === IMLib.ObjectName.GroupNotification) {

View File

@@ -15,7 +15,7 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
'RC:LBSMsg',
'RC:SightMsg',
'RC:ReferenceMsg',
'RC:CombineMsg',
'RC:CombineMsg',
'RC:GrpNtf'
]
@@ -57,6 +57,22 @@ const getPendingList = (callback, total) => {
})
}
// 群组申请列表,邀请列表
const getGroupPendinglist = (targetId, callback) => {
total = total || 100
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
if (res.code === 0) {
const pendings = res.conversations.filter((item) => {
return item.targetId == targetId &&
item.objectName == RongIMLib.ObjectName.ContactNotification &&
item.latestMessage.operation === 'GroupPending'
})
callback(pendings)
}
})
}
/**
* 发送文本消息
* @param {number} conversationType 消息类型
@@ -209,6 +225,7 @@ const sendFile = (conversationType, targetId, fileUrl, time, user, callback) =>
export default {
getMessageList,
getPendingList,
getGroupPendinglist,
sentText,
sentVoice,
sentImage,