首頁  >  文章  >  web前端  >  javascript實作微信分享_javascript技巧

javascript實作微信分享_javascript技巧

WBOY
WBOY原創
2016-05-16 16:24:541209瀏覽

程式碼很簡單,我這裡就不多廢話了,直接奉上原始碼:

複製程式碼 程式碼如下:


String path = request.getContextPath();
String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() 路徑 "/";
%>
渡//EN">

 
   
    喝喝標題>
   
   
       
   
   
   

var imgUrl = 'http://qqfood.tc.qq.com/meishio/16/4585bf7c-be04-420f-ac8a-2dba61a7561f/0';
var lineLink = 'http://life.qq.com/weixin/r/lottery/13826036970196242008#wechat_redirect';
var descContent = "萬達狂歡節,奪寶幸運星大抽獎活動開始囉!";
var shareTitle = '萬達狂歡節';
var appid = 'wxc9937e3a66af6dc8';
函數 shareFriend() {
    WeixinJSBridge.invoke('sendAppMessage',{
                            「appid」:appid,
                            「img_url」:imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            「連結」:lineLink,
                            「desc」:描述內容,
                            “標題”:分享標題
                            }, 函數(res) {
                            _report('send_msg', res.err_msg);
                            })
}
函數 shareTimeline() {
    WeixinJSBridge.invoke('shareTimeline',{
                            「img_url」:imgUrl,
                            "img_width": "640",
                            "img_height": "640",
                            「連結」:lineLink,
                            「desc」:描述內容,
                            “標題”:分享標題
                            }, function(res) {
                            _report('timeline', res.err_msg);
;                             });
}
function shareWeibo() {
    WeixinJSBridge.invoke('shareWeibo',{
                            "content": descContent,
                            "url": lineLink,
                            }, function(res) {
                            _report('weibo', res.err_msg);
                            });
}
// 當微信內建瀏覽器完成內部初始化後會觸發WeixinJSBridgeReady事件。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        // 寄給好友
        WeixinJSBridge.on('menu:share:appmessage', function(argv){
            shareFriend();
            });
        // 分享到朋友圈
        WeixinJSBridge.on('menu:share:timeline', function(argv){
            shareTimeline();
            });
        // 分享至微博
        WeixinJSBridge.on('menu:share:weibo', function(argv){
            shareWeibo();
            });
        }, false);

  頭>
 
 
      
           

呵呵呵呵

          
 
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn