官网提供的第三方API接口支持5种消息格式,分别是:
文本(“text”)
图片(“image”)
视频(“video”)
文件(“file”)
H5(“news”)
wx.invoke('sendChatMessage', {
msgtype:"text", //消息类型,必填
text: {
content:"你好", //文本内容
},
image:
{
mediaid: "", //图片的素材id
},
video:
{
mediaid: "", //视频的素材id
},
file:
{
mediaid: "", //文件的素材id
},
news:
{
link: "", //H5消息页面url 必填
title: "", //H5消息标题
desc: "", //H5消息摘要
imgUrl: "", //H5消息封面图片URL
}
}, function(res) {
if (res.err_msg == 'sendChatMessage:ok') {
//发送成功
}
})
以发送话术(文本)为例:

function runDisplayAction(key, value, $view = view) {
vue.$store.dispatch("weixin/get").then(function(wx) {
//发送信息
wx.invoke('sendChatMessage', {
msgtype: "text", //消息类型,必填
text:
{
//value为当前点击的数据JSON
content:value["5f8941df2447e4265cd62a21"]
}
}, function (res) {
if (res.err_msg == 'sendChatMessage:ok') {
//发送成功
} else {
//发送失败
alert("发送失败,错误信息:"+JSON.Stringfy(res));
}
})
})
}

企业微信 不支持(value)=>{}的写法,必须用回 function(value){}的写法,否则无法正常运行。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69981626/viewspace-2729281/ ,如需转载,请注明出处,否则将追究法律责任。