欢迎光临本站
我们一直在努力

小程序分享朋友圈代码实例: ```javascript wx.onShareAppMessage({ title: '分享标题', path: '/pages/index/index', imageUrl: '分享图片链接', success: function () { console.log('分享成功'); }, fail: function () { console.log('分享失败'); } }); ```

<script type="text/javascript">

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

window.shareData = {

"imgUrl": "/index.php/images/jp_1.jpg",

"timeLineLink": "http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=robSmallRed&fatherid={$fatherid}",//好友

"sendFriendLink": "http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=robSmallRed&fatherid={$fatherid}",//朋友圈

"weiboLink": "",

"tTitle": "标题!",

"tContent": "内容",

"fTitle": "!",

"fContent": "!",

"wContent": ""

};

// 发送给好友

WeixinJSBridge.on('menu:share:appmessage', function (argv) {

WeixinJSBridge.invoke('sendAppMessage', {

"img_url": window.shareData.imgUrl,

"img_width": "640",

"img_height": "640",

"link": window.shareData.sendFriendLink,

"desc": window.shareData.fContent,

"title": window.shareData.fTitle

}, function (res) {

_report('send_msg', res.err_msg);

})

});

// 分享到朋友圈

WeixinJSBridge.on('menu:share:timeline', function (argv) {

WeixinJSBridge.invoke('shareTimeline', {

"img_url": window.shareData.imgUrl,

"img_width": "640",

"img_height": "640",

"link": window.shareData.timeLineLink,

"desc": window.shareData.tContent,

"title": window.shareData.tTitle

}, function (res) {

_report('timeline', res.err_msg);

});

});

// 分享到微博

WeixinJSBridge.on('menu:share:weibo', function (argv) {

WeixinJSBridge.invoke('shareWeibo', {

"content": window.shareData.wContent,

"url": window.shareData.weiboLink,

}, function (res) {

_report('weibo', res.err_msg);

});

});

}, false)

</script>
登录后复制

【相关推荐】

1. 特别推荐

2.

3.

以上就是小程序开发之分享朋友圈代码实例的详细内容,更多请关注有卡有网。

版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《小程序分享朋友圈代码实例: ```javascript wx.onShareAppMessage({ title: '分享标题', path: '/pages/index/index', imageUrl: '分享图片链接', success: function () { console.log('分享成功'); }, fail: function () { console.log('分享失败'); } }); ```》
文章链接:https://www.youkayouwang.com/kaquan-baike/xcx/152940.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。