小程序开发之分享朋友圈代码实例

Y2J
Y2J 原创
2017-05-13 15:34:59 3774浏览
<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:果库更新版

以上就是小程序开发之分享朋友圈代码实例的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。