Home > WeChat Applet > Mini Program Development > Mini Program Development Sharing Moments Code Example

Mini Program Development Sharing Moments Code Example

Y2J
Release: 2017-05-13 15:34:59
Original
4453 people have browsed it

<script type="text/javascript">
 
document.addEventListener(&#39;WeixinJSBridgeReady&#39;, 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(&#39;menu:share:appmessage&#39;, function (argv) {
 
WeixinJSBridge.invoke(&#39;sendAppMessage&#39;, {
 
"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(&#39;send_msg&#39;, res.err_msg);
 
})
 
});
 
// 分享到朋友圈
 
WeixinJSBridge.on(&#39;menu:share:timeline&#39;, function (argv) {
 
WeixinJSBridge.invoke(&#39;shareTimeline&#39;, {
 
"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(&#39;timeline&#39;, res.err_msg);
 
});
 
});
 
// 分享到微博
 
WeixinJSBridge.on(&#39;menu:share:weibo&#39;, function (argv) {
 
WeixinJSBridge.invoke(&#39;shareWeibo&#39;, {
 
"content": window.shareData.wContent,
 
"url": window.shareData.weiboLink,
 
}, function (res) {
 
_report(&#39;weibo&#39;, res.err_msg);
 
});
 
});
 
}, false)
 
</script>
Copy after login

【Related Recommendations】

1. Special Recommendations: "php Programmer Toolbox" V0.1 version download

2. Complete source code download of WeChat Mini Program

3. WeChat Mini Program demo: Guoku updated version

The above is the detailed content of Mini Program Development Sharing Moments Code Example. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template