1. 分享消息到当前会话
wx.invoke('sendChatMessage', {
msgtype:"text", //消息类型,必填
enterChat: true, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
text: {
content:"你好", //文本内容
},
image:
{
mediaid: "", //图片的素材id
},
video:
{
mediaid: "", //视频的素材id
},
file:
{
mediaid: "", //文件的素材id
},
news:
{
link: "", //H5消息页面url 必填
title: "", //H5消息标题
desc: "", //H5消息摘要
imgUrl: "", //H5消息封面图片URL
},
miniprogram:
{
appid: "wx8bd80126147df384",//小程序的appid,企业已关联的任一个小程序
title: "this is title", //小程序消息的title
imgUrl:"https://search-operate.cdn.bcebos.com/d054b8892a7ab572cb296d62ec7f97b6.png",//小程序消息的封面图。必须带http或者https协议头,否则报错 $apiName$:fail invalid imgUrl
page:"/index/page.html", //小程序消息打开后的路径,注意要以.html作为后缀,否则在微信端打开会提示找不到页面
},
}, function(res) {
if (res.err_msg == 'sendChatMessage:ok') {
//发送成功
}
})
2. 示例
miniprogramList: [
{
appid:"wx8bd80126147df384",
title: "个人小程序",
imgUrl: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi3%2F206824074%2FO1CN01XTzvn61fxw8q88nXw_%21%21206824074.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660704764&t=03948fd5c9727cfc1c291f71b5390ec6",
page: "pages/getUserInfo/getUserInfo.html", //小程序消息打开后的路径,注意要以.html作为后缀,否则在微信端打开会提示找不到页面
}
],