1、WeixinJSBridge share(微信自定義分享內容)
可以自定義分享內容。(在右上角的分享)
<!DOCTYPE html> <html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta name="format-detection" content="telephone=no"> <title>智能點菜</title> </head> <body> <script> document.addEventListener("WeixinJSBridgeReady",function(){ weixinJSBgReadyEventSet(); }) ; function weixinJSBgReadyEventSet(){ var appid="";//經常設置為'' var title = "title"; var link = "http://www.baidu.com"; var desc = "desc"; var img_url = "http://dongway.com.cn/resources/front/new/images/logo.png"; var img_width = "120";//好像設置成其他也沒用 var img_height = "120"; share(appid,title,link,desc,img_url,img_width,img_height,'menu:share:timeline','shareTimeline');//timeline:分享至朋友圈 share(appid,title,link,desc,img_url,img_width,img_height,'menu:share:appmessage','sendAppMessage');//appmessage分享至微信好友 } function share(appid,title,link,desc,img_url,img_width,img_height,button,event) { if (typeof WeixinJSBridge == "undefined") { alert("請先通過微信分享文章 "); } else if (typeof window.WeixinJSBridge.invoke == 'undefined'){ alert("invoke!"); } else { WeixinJSBridge.on(button, function(argv){ WeixinJSBridge.invoke(event,{ "appid":appid, //設置為null "title": title, "link": link, "desc": desc, "img_url": img_url, "img_width":img_width, //圖片寬度 "img_height":img_height //圖片高度 }, function(d) { //alert(d.err_msg);//這里是分享功能的回調函數,有錯誤的時候有用 }); }); } } </script> </body></html>
