最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

一、可定義的信息

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

二、使用方法

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

復(fù)制代碼 代碼如下:

/*******************************
 * Author:Mr.Think
 * Description:微信分享通用代碼
 * 使用方法:_WXShare('分享顯示的LOGO','LOGO寬度','LOGO高度','分享標(biāo)題','分享描述','分享鏈接','微信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);
              });
    }
    // 當(dāng)微信內(nèi)置瀏覽器初始化后會(huì)觸發(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)文章

最新評(píng)論

仲巴县| 顺平县| 突泉县| 北京市| 东乌珠穆沁旗| 长寿区| 司法| 祁连县| 邹城市| 桐梓县| 石首市| 高雄县| 七台河市| 崇义县| 固安县| 汝南县| 关岭| 高安市| 兰州市| 鄂伦春自治旗| 丰城市| 马尔康县| 麻阳| 龙泉市| 射阳县| 庆元县| 溧阳市| 山阴县| 霍林郭勒市| 太康县| 赤壁市| 宝应县| 英吉沙县| 大石桥市| 响水县| 客服| 名山县| 威海市| 本溪| 平武县| 谷城县|