The code is super simple, so I won’t talk much nonsense here. Please read the comments for yourself.
Provide the code:
The code copy is as follows:
<script>
//Share on WeChat
var wimg = "Share image URL 123";
var wurl = "Share URL 123";
var wdesc = 'Share content 123';
var wtit = 'Share title 123';
var wappid = '';
function shareMsg() {//<span style="font-family: Arial, Helvetica, sans-serif;">Send to friends</span><span style="font-family: Arial, Helvetica, sans-serif;">Title and content are displayed by default</span>
WeixinJSBridge.invoke('sendAppMessage',{
"appid": wappid,
"img_url": wimg,
"img_width": "200",
"img_height": "200",
"link": wurl,
"desc": wdesc,
"title": wtit,
})
}
function shareQuan() { //<span style="font-family: Arial, Helvetica, sans-serif;">Share to friends circle only the title display</span>
WeixinJSBridge.invoke('shareTimeline',{
"img_url": wimg,
"img_width": "200",
"img_height": "200",
"link": wurl,
"desc": wdesc,
"title": wtit
});
}
function shareWeibo() { <span style="font-family: Arial, Helvetica, sans-serif;">//</span><span style="font-family: Arial, Helvetica, sans-serif;">Share to Weibo only content displays</span>
WeixinJSBridge.invoke('shareWeibo',{
"content": wdesc,
"url": wurl,
});
}
// WeixinJSBridgeReady event will be triggered when the built-in WeChat browser completes internal initialization.
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
// Send it to friends
WeixinJSBridge.on('menu:share:appmessage', function(argv){
shareMsg();
});
// Share to friends
WeixinJSBridge.on('menu:share:timeline', function(argv){
shareQuan();
});
// Share on Weibo
WeixinJSBridge.on('menu:share:weibo', function(argv){
shareWeibo();
});
}, false);
</script>
Isn't it very practical? Please use it according to your needs.