• 微信分享到朋友圈的内容和图片的定制


    // 微信分享到朋友圈的内容和图片的定制
    (function () {
    
        // data for weixin
        var dataForWeixin = {
            appId: "wx4654ffed0376f250",  // ttfund app id
            imgUrl: "http://j5.dfcfw.com/image/201407/20140725182526.jpg",
            imgWidth: "200",
            imgHeight: "200",
            url: location.href,
            title: "",
            desc: "",
            callback: function () {}
        };
    
        var onBridgeReady = function () {
    
            // 禁止分享
            // WeixinJSBridge.call('hideOptionMenu');
    
            // 发送给朋友
            WeixinJSBridge.on("menu:share:appmessage", function (argv) {
                WeixinJSBridge.invoke("sendAppMessage", {
                    "appid": dataForWeixin.appId,
                    "img_url": dataForWeixin.imgUrl,
                    "img_width": dataForWeixin.imgWidth,
                    "img_height": dataForWeixin.imgHeight,
                    "link": dataForWeixin.url,
                    "desc": dataForWeixin.desc,
                    "title": dataForWeixin.title
                }, function (res) { dataForWeixin.callback(); });
            });
    
            // 发送到朋友圈
            WeixinJSBridge.on("menu:share:timeline", function (argv) {
                WeixinJSBridge.invoke("shareTimeline", {
                    "appid": dataForWeixin.appId,
                    "img_url": dataForWeixin.imgUrl,
                    "img_width": dataForWeixin.imgWidth,
                    "img_height": dataForWeixin.imgHeight,
                    "link": dataForWeixin.url,
                    "desc": dataForWeixin.desc,
                    "title": dataForWeixin.title
                }, function (res) { dataForWeixin.callback(); });
            });
    
            // 分享到微博
            WeixinJSBridge.on("menu:share:weibo", function (argv) {
                WeixinJSBridge.invoke("shareWeibo", {
                    "content": dataForWeixin.title,
                    "url": dataForWeixin.url
                }, function (res) { dataForWeixin.callback(); });
            });
    
            // 分享到facebook
            WeixinJSBridge.on("menu:share:facebook", function (argv) {
                WeixinJSBridge.invoke("shareFB", {
                    "img_url": dataForWeixin.imgUrl,
                    "img_width": dataForWeixin.imgWidth,
                    "img_height": dataForWeixin.imgHeight,
                    "link": dataForWeixin.url,
                    "desc": dataForWeixin.desc,
                    "title": dataForWeixin.title
                }, function (res) { dataForWeixin.callback(); });
            });
        };
    
        if (document.addEventListener) {
            document.addEventListener("WeixinJSBridgeReady", onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
        }
    })();
  • 相关阅读:
    20160913
    20160912
    VI中的多行删除与复制(转)
    Linux 压缩文件 和解压文件
    开心消消乐兑换码 亲测
    房地产行业清洗公司 特殊词汇
    java 截取替换掉括号 包括括号中的内容
    numpy运算简介(一)
    numpy : random.rand 和 random.random 的区别
    numpy.random.seed()的使用解析
  • 原文地址:https://www.cnblogs.com/xiankui/p/3770970.html
Copyright © 2020-2023  润新知