<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. 特别推荐:“php程序员工具箱”v0.1版本下载
2. 微信小程序完整源码下载
3. 微信小程序demo:果库更新版
以上就是小程序开发之分享朋友圈代码实例的详细内容。