Files
tk-mini-program/unpackage/dist/build/mp-weixin/components/goEasyTool/tool.js
pengxiaolong 8580cd18fa 优化
2025-07-25 16:39:52 +08:00

2 lines
3.1 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(n,e){return new Promise(((t,s)=>{n.im.removeConversation({conversation:e,onSuccess:function(){t("删除会话成功")},onFailed:function(n){console.log(n),o.index.showToast({title:"删除会话失败",icon:"none"})}})}))},exports.conversationTop=function(n,e,t){return new Promise(((s,c)=>{n.im.topConversation({conversation:e,top:t,onSuccess:function(){s("成功")},onFailed:function(n){console.log("失败:",n),o.index.showToast({title:"置顶会话失败",icon:"none"})}})}))},exports.getConversationList=function(n){return new Promise(((e,t)=>{n.im.latestConversations({onSuccess:function(o){console.log("获取会话列表成功",o),e(o.content)},onFailed:function(n){console.log("获取会话列表失败, code:"+n.code+" content:"+n.content),o.index.showToast({title:"获取会话列表失败",icon:"none"})}})}))},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(n){console.log("获取消息列表失败, code:"+n.code+" content:"+n.content),o.index.showToast({title:"获取消息列表失败",icon:"none"})}})}))},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(n){console.log("标记私聊已读失败",n),o.index.showToast({title:"标记私聊已读失败",icon:"none"})}})}))},exports.sendCustomMessage=function(n,e,t,s,c,i){return new Promise(((a,r)=>{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(){a(u)},onFailed:function(n){console.log("Failed to send messagecode:"+n.code+",error"+n.content),o.index.showToast({title:"发送自定义消息失败",icon:"none"})}})}))},exports.sendGroupMessage=function(n,e){return new Promise(((t,s)=>{n.im.sendMessage({message:e,onSuccess:()=>{t(e)},onFailed:function(n){o.index.showToast({title:"发送消息失败",icon:"none"})}})}))},exports.sendMessage=function(n,e,t,s,c){return new Promise(((i,a)=>{var r=n.im;let l=r.createTextMessage({text:t,to:{type:o.jo.IM_SCENE.PRIVATE,id:e,data:{avatar:s,nickname:c}}});r.sendMessage({message:l,onSuccess:function(){i(l)},onFailed:function(n){console.log("发送消息失败code:"+n.code+" ,error "+n.content),o.index.showToast({title:"发送消息失败",icon:"none"}),a(n)}})}))};