<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="https://cdn.botorange.com/js/sidebar/juzi-helper-1.0.11.js"></script>
<!--
1.juzi-helper仅在系统侧边栏环境下覆写wx对象,成功后window.wx.isJuziWx === true
2.如果使用npm安装的jweixin或页面不存在wx对象,juzi-helper的覆写可能不会成功,此时可使用window.juziWx
-->wx.invoke('getCurExternalContact', { }, function(res){
if (res.err_msg == "getCurExternalContact:ok") {
//成功处理 {userId: 'xxx', err_msg: 'getCurExternalContact:ok'}
} else {
//错误处理 {userId: undefined, err_msg: 'getCurExternalContact:fail'}
}
});wx.invoke('getCurExternalChat', {}, function(res){
if (res.err_msg == "getCurExternalChat:ok") {
//成功处理 {chatId: 'xxx', err_msg: 'getCurExternalChat:ok'}
} else {
//错误处理 {chatId: undefined, err_msg: 'getCurExternalChat:fail'}
}
});wx.getCurChatInfo({
success: function(res) {
// 成功处理
},
fail: function(res) {
// 失败处理 {err_msg: 'xxx'}
}
})| 名称 | 数据类型 | 描述 |
|---|---|---|
| Id | string | 会话id |
| name | string | 会话名称 |
| type | number | 会话类型:0 单聊,1群聊 |
| external | boolean | 是否是外部的:true 外部的 false 内部的 |
| wxUserId | string | 企业联系人userId 可选 当type为 0 时有 等同 getCurExternalContact 接口拿到的userId |
| wxChatId | string | 企业群聊chatId 可选 当type为 1 时有 等同 getCurExternalChat 接口拿到的chatId |
| botId | string | 托管账号ID |
| botName | string | 托管账号名称 |
| botStatus | number | 托管账号状态:1离线 2在线 |
| botType | number | 托管账号类型 export enum BotType { BOTTYPE_NONE = 0, // 未知 WECHAT = 1, // 微信 WXWORK = 2, // 企业微信 OA = 3, // 公众号 WHATSAPP = 4, // WhatsApp WXKF = 5, // 微信客服-三方安装 TIKTOK = 6, // TikTok WX_MINI_PROGRAM = 7, // 小程序 DOUYIN = 8, // 抖音 INSTAGRAM = 9, // Instagram DING_TALK = 10, // 钉钉 FEI_SHU = 11, // 飞书 RED_NOTE = 12, // 小红书-企业号 WXXD = 13, // 微信小店 XIAOHONGSHUSTAFF = 14, // 小红书-员工号 WXKF_SELF = 15, // 微信客服-自建应用 } |
| jzGroupId | string | 系统小组ID |
| jzUserId | string | 系统用户(右上角用户)的ID 注意:非托管账号用户ID 托管账号用户ID请参考"身份认证" |
| botWxid | string | 托管账号的系统wxid |
| wxid | string | 单聊or群聊的系统wxid |
type TextMsg = { msgtype: 'text'; text: { content: string; } };
type ImageMsg = {
msgtype: 'image';
image: {
url: string;
title?: string;
};
}
type VideoMsg = {
msgtype: 'video';
video: {
url: string;
title?: string;
};
}
type FileMsg = {
msgtype: 'file';
file: {
url: string;
title?: string;
};
}
type NewsMsg = {
msgtype: 'news',
news: {
link: string,
title: string,
desc: string,
imgUrl: string,
},
}
type MiniprogramMsg = {
msgtype: "miniprogram",
miniprogram: {
appid: string, // 小程序的appid
title: string, // 小程序消息的title
imgUrl: string, // 小程序消息的封面图,必须带http或者https协议头。
page: string, // 小程序消息打开后的路径
desc: string, // 小程序描述
iconUrl: string, // 小程序icon地址
officialAccountId: string, // 小程序原始id
},
}
type SendParams = TextMsg | ImageMsg | VideoMsg | FileMsg | NewsMsg | MiniprogramMsg;
type ErrMsg = 'sendChatMessage:ok' | 'text content is empty' | 'url is empty';
type Callback = (res: { err_msg: ErrMsg; }) => void;
wx.invoke('sendChatMessage', sendParams: SendParams, callback: Callback);
wx.openEnterpriseChat({
userIds: 'zhangsan', // 企业微信企业成员userId,必传
externalUserIds: 'wmEAlECwAAHrbWYDOK5u3Bf13xlYDAAA', // 企业微信外部联系人userId
chatId: 'CHATID', // 企业微信外部群chatId
success: function(res) {
// 成功处理 {err_msg: 'openEnterpriseChat:ok'}
},
fail: function(res) {
// 失败处理 {err_msg: 'xxx'}
}
})
wx.previewImage({
current: '', // 可选,第一张显示的图片链接
urls: [], // 必填,需要预览的图片http链接列表
})
https://{企业控制台域名}/api/oauth/connect/authorize?redirect_uri=REDIRECT_URI&state=STATE| 参数 | 必须 | 说明 |
|---|---|---|
| redirect_uri | 是 | 授权后重定向的回调链接地址,请使用urlencode对链接进行处理 。 |
| state | 否 | 重定向后会带上state参数,企业可以填写a-zA-Z0-9的参数值,长度不可超过128个字节。 |
GET https://{企业控制台域名}/api/v1/oauth/getUserInfo?code=**| 参数 | 类型 | 备注 | 是否必须 |
|---|---|---|---|
| code | string |