2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
"use strict";const o=require("../../common/vendor.js");exports.getConversationList=function(o){return new Promise(((n,e)=>{o.im.latestConversations({onSuccess:function(o){console.log("获取会话列表成功",o),n(o.content)},onFailed:function(o){console.log("获取会话列表失败, code:"+o.code+" content:"+o.content)}})}))},exports.getConversationMessages=function(n,e,t){return new Promise(((c,s)=>{n.im.history({id:e,type:o.jo.IM_SCENE.PRIVATE,lastTimestamp:t,limit:30,onSuccess:function(o){console.log("获取消息列表成功",o),c(o.content)},onFailed:function(o){console.log("获取消息列表失败, code:"+o.code+" content:"+o.content)}})}))},exports.goEasylogin=function(o,n,e,t){console.log("`````````````````goEasylogin`````````````````",n,e,t),o.connect({id:n,data:{avatar:e,nickname:t},onSuccess:function(){console.log("IM连接成功")},onFailed:function(o){console.log("IM连接失败, code:"+o.code+",error:"+o.content)},onProgress:function(o){console.log("IM连接或自动重连中",o)}})},exports.goEasylogout=function(o){o.disconnect({onSuccess:function(){console.log("IM断开成功")},onFailed:function(o){console.log("IM断开失败, code:"+o.code+",error:"+o.content)}})},exports.sendMessage=function(n,e,t,c,s){return new Promise(((i,r)=>{var l=n.im;let a=l.createTextMessage({text:t,to:{type:o.jo.IM_SCENE.PRIVATE,id:e,data:{avatar:c,nickname:s}}});l.sendMessage({message:a,onSuccess:function(){console.log("发送消息成功",a),i(a)},onFailed:function(o){console.log("发送消息失败,code:"+o.code+" ,error "+o.content),r(o)}})}))};
|