当前位置: 首页 > 工具软件 > Q.js > 使用案例 >

微信手Q分享js定制

卢承弼
2023-12-01

define(function(require,exports,module){

    var share_data={};

    share_data.url='http://'+location.host+'/php_cgi/syb_video/html/';

    share_data.title='游戏时刻';//默认

    share_data.desc='快来游戏时刻看大神视频,记录你与好友的精彩瞬间!';

    share_data.pic=" http://ossweb-img.qq.com/images/qtalk/syb_video/logo1.jpg ";//默认

    //微信

    function onBridgeReady(share_data){

        //转发朋友圈

        WeixinJSBridge.on("menu:share:timeline",function(e){

            var data={

                img_url:share_data.pic,

                link:share_data.url,

                desc:share_data.desc,

                title:share_data.title

            };

            WeixinJSBridge.invoke("shareTimeline",data,function(res){

                WeixinJSBridge.log(res.err_msg)

            });

            try{

                QtPgvSendClick({hottag:'hero_time.weixin.share.group'})

            }catch(e){

            }

        });

        //同步到微博

        WeixinJSBridge.on("menu:share:weibo",function(){

            WeixinJSBridge.invoke("shareWeibo",{

                "content":share_data.title+share_data.url,

                "url":share_data.url

            },function(res){

                WeixinJSBridge.log(res.err_msg);

            });

            try{

                QtPgvSendClick({hottag:'hero_time.weixin.share.weibo'})

            }catch(e){

            }

        });

        //分享给朋友

        WeixinJSBridge.on('menu:share:appmessage',function(argv){

            WeixinJSBridge.invoke("sendAppMessage",{

                img_url:share_data.pic,

                link:share_data.url,

                desc:share_data.desc,

                title:share_data.title

            },function(res){

                WeixinJSBridge.log(res.err_msg)

            });

            try{

                QtPgvSendClick({hottag:'hero_time.weixin.share.friend'})

            }catch(e){

            }

        });

        try{

            QtPgvSendClick({hottag:'hero_time.weixin.index'})

        }catch(e){

        }

    }

    //QQ

    function initSQShare(data){

        require.async(' http://pub.idqqimg.com/qqmobile/qqapi.js ',function(){

            try{

                window.mqq.data.setShareInfo(data)

            }catch(e){

            }

        });

    }

    function initShare(data){

        $.extend(share_data,data);

        //console.log(share_data);

        initSQShare({

            share_url:share_data.url,

            title:share_data.title,

            desc:share_data.desc,

            image_url:share_data.pic

        });

        try{

            if(typeof WeixinJSBridge=="object"&&typeof WeixinJSBridge.invoke=="function"){

                onBridgeReady(share_data);

            }else{

                document.addEventListener('WeixinJSBridgeReady',function(){

                    onBridgeReady(share_data);

                });

            }

        }catch(e){

        }


    }

    exports.initShare=initShare;

});


 类似资料: