组件迁移,发送完消息之后的展示,延迟

This commit is contained in:
2022-02-07 11:24:46 +08:00
parent b202a62d5d
commit eb88bf56f8
7 changed files with 302 additions and 266 deletions

View File

@@ -1,5 +1,43 @@
import store from '@/store/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import store from '@/store/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
const getMessageList = (conversationType, targetId, callback) => {
// 获取消息列表
const objectNames = [
'RC:TxtMsg',
'RC:VcMsg',
'RC:HQVCMsg',
'RC:ImgMsg',
'RC:GIFMsg',
'RC:ImgTextMsg',
'RC:FileMsg',
'RC:LBSMsg',
'RC:SightMsg',
'RC:ReferenceMsg',
'RC:CombineMsg'
]
const timeStamp = new Date().getTime()
const count = 10 // 获取的消息数量
const isForward = true // 是否向前获取
RongIMLib.getHistoryMessagesByTimestamp(conversationType, targetId, objectNames, timeStamp,
count,
isForward,
({
code,
messages
}) => {
if (code === 0) {
callback(messages)
} else {
uni.showToast({
icon: 'error',
title: code
})
}
}
)
}
/**
* 发送文本消息
* @param {number} conversationType 消息类型
@@ -7,7 +45,7 @@ import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
* @param {string} content 消息内容
* @param {function} callback 回调函数
*/
const sentText = (conversationType, targetId, content, callback) => {
const sentText = (conversationType, targetId, content, callback) => {
console.log('发送');
const msg = {
conversationType: conversationType,
@@ -31,7 +69,7 @@ const sentText = (conversationType, targetId, content, callback) => {
})
}
})
}
}
/**
* 发送消息
@@ -144,11 +182,12 @@ const sendFile = (conversationType, targetId, fileUrl, time, callback) => {
}
})
}
export default {
sentText,
sentVoice,
sentImage,
sentGif,
sendFile
}
export default {
getMessageList,
sentText,
sentVoice,
sentImage,
sentGif,
sendFile
}