jiuyiUniapp/service/pages/chat/fn.js

30 lines
1.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 获取历史记录
// C2C${userID}(单聊)
// GROUP${groupID}(群聊)
// GROUP${topicID}(话题)
// @TIM#SYSTEM系统通知会话
/**
* 获取历史记录
* @param {String} option 聊天属性
* @param {String} option.chatType C2C单聊 GROUP群聊/话题 @TIM#SYSTEM系统通知会话
* @param {String} option.msgId 聊天对象id 单聊/群聊/话题
* @param {String} option.nextReqMessageID 用于分页续拉的消息 ID。第一次拉取时不要传入 nextReqMessageID续拉时填入上次调用 getMessageList 接口返回的该字段的值
*/
export const getHistoryMsg = async (option) => {
let options = {
// 对方的用户 ID 或者群组 ID 或聊天室 ID。
conversationID: `${option.chatType}${option.msgId}`,
nextReqMessageID: option.nextReqMessageID,
}
console.log('options', options);
return new Promise((resolve, reject) => {
uni.$chat.getMessageList(options).then((res) => {
resolve(res)
}).catch((e) => {
console.log('Promise reject', e);
reject(e)
});
})
}