Files
tk-mini-program/unpackage/dist/build/mp-weixin/components/goEasyTool/tool.js
pengxiaolong 7116e57fc3 优化
2025-07-21 22:10:59 +08:00

2 lines
2.4 KiB
JavaScript
Raw 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.

"use strict";const o=require("../../common/vendor.js");exports.conversationDelete=function(o,n){return new Promise(((e,t)=>{o.im.removeConversation({conversation:n,onSuccess:function(){e("删除会话成功")},onFailed:function(o){console.log(o)}})}))},exports.conversationTop=function(o,n,e){return new Promise(((t,s)=>{o.im.topConversation({conversation:n,top:e,onSuccess:function(){t("成功")},onFailed:function(o){console.log("失败:",o)}})}))},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(((s,c)=>{n.im.history({id:e,type:o.jo.IM_SCENE.PRIVATE,lastTimestamp:t,limit:30,onSuccess:function(o){console.log("获取消息列表成功",o),s(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.messageRead=function(n,e){return new Promise(((t,s)=>{n.im.markMessageAsRead({id:e,type:o.jo.IM_SCENE.PRIVATE,onSuccess:function(){t()},onFailed:function(o){console.log("标记私聊已读失败",o)}})}))},exports.sendCustomMessage=function(n,e,t,s,c,i){return new Promise(((r,a)=>{var l=n.im,u=l.createCustomMessage({type:e,payload:s,to:{type:o.jo.IM_SCENE.PRIVATE,id:t,data:{avatar:c,nickname:i}}});l.sendMessage({message:u,onSuccess:function(){r(u)},onFailed:function(o){console.log("Failed to send messagecode:"+o.code+",error"+o.content)}})}))},exports.sendMessage=function(n,e,t,s,c){return new Promise(((i,r)=>{var a=n.im;let l=a.createTextMessage({text:t,to:{type:o.jo.IM_SCENE.PRIVATE,id:e,data:{avatar:s,nickname:c}}});a.sendMessage({message:l,onSuccess:function(){i(l)},onFailed:function(o){console.log("发送消息失败code:"+o.code+" ,error "+o.content),r(o)}})}))};