欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js實現(xiàn)通用的微信分享組件示例

 更新時間:2014年03月10日 15:34:58   作者:  
這篇文章主要介紹了微信分享通用組件,用于微信瀏覽器內(nèi)瀏覽網(wǎng)頁的分享信息定義,需要的朋友可以參考下

一、可定義的信息

1、分享時顯示的LOGO;
2、分享LOGO的寬度;
3、分享LOGO的高度;
4、分享出去顯示的標題(默認調(diào)用網(wǎng)頁標題);
5、分享出去顯示的描述(默認調(diào)用網(wǎng)頁標題);
6、分享鏈接(默認為當前頁面的URL)。
7、分享微信的APPID(一般為空)。

二、使用方法

1、引入微信分享組件js:

復制代碼 代碼如下:

/*******************************
 * Author:Mr.Think
 * Description:微信分享通用代碼
 * 使用方法:_WXShare('分享顯示的LOGO','LOGO寬度','LOGO高度','分享標題','分享描述','分享鏈接','微信APPID(一般不用填)');
 *******************************/
function _WXShare(img,width,height,title,desc,url,appid){
    //初始化參數(shù)
    img=img||'http://a.zhixun.in/plug/img/ico-share.png';
    width=width||100;
    height=height||100;
    title=title||document.title;
    desc=desc||document.title;
    url=url||document.location.href;
    appid=appid||'';
    //微信內(nèi)置方法
    function _ShareFriend() {
        WeixinJSBridge.invoke('sendAppMessage',{
              'appid': appid,
              'img_url': img,
              'img_width': width,
              'img_height': height,
              'link': url,
              'desc': desc,
              'title': title
              }, function(res){
                _report('send_msg', res.err_msg);
          })
    }
    function _ShareTL() {
        WeixinJSBridge.invoke('shareTimeline',{
              'img_url': img,
              'img_width': width,
              'img_height': height,
              'link': url,
              'desc': desc,
              'title': title
              }, function(res) {
              _report('timeline', res.err_msg);
              });
    }
    function _ShareWB() {
        WeixinJSBridge.invoke('shareWeibo',{
              'content': desc,
              'url': url,
              }, function(res) {
              _report('weibo', res.err_msg);
              });
    }
    // 當微信內(nèi)置瀏覽器初始化后會觸發(fā)WeixinJSBridgeReady事件。
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            // 發(fā)送給好友
            WeixinJSBridge.on('menu:share:appmessage', function(argv){
                _ShareFriend();
          });

            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function(argv){
                _ShareTL();
                });

            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function(argv){
                _ShareWB();
           });
    }, false);
}

相關(guān)文章

最新評論