码迷,mamicode.com
首页 > 移动开发 > 详细

IOS android平台上都可使用的js分享代码

时间:2015-03-03 18:40:52      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

<span style="font-size:18px;">
</span>
<span style="font-size:18px;">document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        window.shareData = {  
            "imgUrl": "{$shareimg}", 
            "timeLineLink":   "{$sharelink}",
            "sendFriendLink": "{$sharelink}",
            "weiboLink":      "{$sharelink}",
            "tTitle":   "{$sharetitle}",
            "tContent": "{$sharedesc}",
            "fTitle":   "{$sharetitle}",
            "fContent": "{$sharedesc}",
            "wContent": "{$sharedesc}",
        };
       /*发送给好友*/
        WeixinJSBridge.on('menu:share:appmessage', function (argv) {
            WeixinJSBridge.invoke('sendAppMessage', { 
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.sendFriendLink,
                "desc": window.shareData.fContent,
                "title": window.shareData.fTitle
            }, function (res) {
                   if(res.err_msg == 'send_app_msg:ok' || res.err_msg == 'send_app_msg:confirm'){
                        
                    };
                _report('send_msg', res.err_msg);
            })
        });

        //分享到朋友圈
        WeixinJSBridge.on('menu:share:timeline', function (argv) {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": window.shareData.imgUrl,
                "img_width": "640",
                "img_height": "640",
                "link": window.shareData.timeLineLink,
                "desc": window.shareData.tContent,
                "title": window.shareData.tTitle
            }, function (res) {
                if(res.err_msg == 'share_timeline:ok' || res.err_msg == 'share_timeline:confirm'){
                        
                    };
                _report('timeline', res.err_msg);
            });
        });

        //分享到微博
        WeixinJSBridge.on('menu:share:weibo', function (argv) {
            WeixinJSBridge.invoke('shareWeibo', {
                "content": window.shareData.wContent,
                "url": window.shareData.weiboLink,
            }, function (res) {
                _report('weibo', res.err_msg);
            });
        });
        }, false)
         
</script></span>

IOS android平台上都可使用的js分享代码

标签:

原文地址:http://blog.csdn.net/kewin_edward/article/details/44040657

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!