当前位置:   article > 正文

微信公众号分享设置JS脚本

微信转发公众号脚本

var dataForWeixin = {
           appId: "xxxxxx",
           MsgImg: "素材图片地址",
           TLImg: "素材图片地址",
           url: location.href,
           title: '关注有奖,万元购物卡免费送 ',
           desc: '通过“xxx”微信服务号即可参与抽奖',
           fakeid: "",
           callback: function () {
//                window.location.href="test.json";
           }
       };
       (function () {
           var onBridgeReady = function () {
               // 发送给好友;
               WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                   WeixinJSBridge.invoke('sendAppMessage', {
                       "appid": dataForWeixin.appId,
                       "img_url": dataForWeixin.MsgImg,
                       "img_width": "120",
                       "img_height": "120",
                       "link": dataForWeixin.url,
                       "desc": dataForWeixin.desc,
                       "title": dataForWeixin.title
                   }, function (res) { _czc.push(['_trackEvent', '分享', '发送给好友', '2048']); });
               });
               // 分享到朋友圈;
               WeixinJSBridge.on('menu:share:timeline', function (argv) {
                   (dataForWeixin.callback)();
                   WeixinJSBridge.invoke('shareTimeline', {
                       "img_url": dataForWeixin.TLImg,
                       "img_width": "120",
                       "img_height": "120",
                       "link": dataForWeixin.url,
                       "desc": dataForWeixin.desc,
                       "title": dataForWeixin.title
                   }, function (res) { _czc.push(['_trackEvent', '分享', '分享到朋友圈', '2048']); });
               });
               // 分享到微博;
               WeixinJSBridge.on('menu:share:weibo', function (argv) {
                   WeixinJSBridge.invoke('shareWeibo', {
                       "content": dataForWeixin.title,
                       "url": dataForWeixin.url
                   }, function (res) { _czc.push(['_trackEvent', '分享', '分享到微博', '2048']); });
               });
           };
           if (document.addEventListener) {
               document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
           } else if (document.attachEvent) {
               document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
               document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
           }
       })();

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/70680
推荐阅读
相关标签
  

闽ICP备14008679号