Commit dcecea5d authored by songrui's avatar songrui

im加载云端消息

parent d3ea72cf
......@@ -162,7 +162,8 @@ export default {
onconnect: () => {
console.log('连接成功 ================>')
this.isConnect = true
this.getLocalMsgs()
// this.getLocalMsgs()
this.getHistoryMsgs()
this.toBottom('instant')
setTimeout(() => {
// 开启滚动加载
......@@ -245,8 +246,34 @@ export default {
}
})
},
// 加载云端消息
getHistoryMsgs() {
const msg = this.msgs[0] || {}
this.loading = true
this.nim.getHistoryMsgs({
// sessionId: `p2p-${this.targetId}`,
scene: 'p2p',
to: this.targetId,
limit: 40,
end: msg.time,
done: (error, obj) => {
console.log('获取p2p历史消息' + (!error?'成功':'失败'), obj);
const msgs = obj.msgs || []
this.loading = false
if (!msgs.length) {
this.finished = true
return
}
msgs.sort((a, b) => {
return a.time - b.time
})
this.msgs = msgs.concat(this.msgs)
}
})
},
loadHistory() {
this.getLocalMsgs()
// this.getLocalMsgs()
this.getHistoryMsgs()
},
handleFiles() {
let files = this.$refs['fileElem'].files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment