fkcqwq

先引入以下文件

<script src="./js/jquery-1.6.2.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>刘寿永医生深度解读男性健康</title>
    <link rel="stylesheet" href="./css/index.css">
</head>
<style>
    body{
        background-image: linear-gradient(to bottom, #821ED5, #6626DF);
    }
</style>
<body>
    分享啦
</body>

</html>
<script src="./js/jquery-1.6.2.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script>
    function shipei() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + \'px\';
    }
    shipei();
    window.onresize = shipei;
    //微信分享
    $.ajax({
        type: "post",
        // url: \'http://localhost:8081/syrjia/im/queryScan.action\',
        url:\'http://\'+window.location.host +\'/syrjia/im/queryScan.action\',//请求接口获取appId等信息
        data: {
            url: window.location.href //当前页面url地址,问号后的参数
        },
        success: function (data) {
            if (data.respCode && data.respCode == 1001) {
                console.log(data)
                // var shippingAddressId=isEmpty($location.search().shippingAddressId)?$scope.shippingAddressId:$location.search().shippingAddressId;
                wx.config({
                    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端openAlert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                    appId: data.data.appId, // 必填,公众号的唯一标识
                    timestamp: data.data.timestamp, // 必填,生成签名的时间戳
                    nonceStr: data.data.nonceStr, // 必填,生成签名的随机串
                    signature: data.data.signature, // 必填,签名,见附录1
                    jsApiList: [\'onMenuShareTimeline\', \'onMenuShareAppMessage\', \'onMenuShareQQ\',
                        \'onMenuShareWeibo\', \'onMenuShareQZone\', \'\'
                    ]
                    // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
                });
                wx.ready(function () {
                    // 微信分享的数据
                    var shareData = {
                        "imgUrl": \'http://mobile.syrjia.com/meeting_subject/lys/img/lys.png\', // 分享显示的缩略图地址
                        "link": \'http://mobile.syrjia.com/meeting_subject/lys/index.html\', // 分享地址
                        "desc": "专家为您解读,点击查看详情", // 分享描述
                        "title": \'这是title\', // 分享标题
                        success: function () {
                            //alert("分享成功");
                        }
                    };
                    var shareDataq = {
                        "imgUrl": \'http://mobile.syrjia.com/meeting_subject/lys/img/lys.png\', // 分享显示的缩略图地址
                        "link": \'http://mobile.syrjia.com/meeting_subject/lys/index.html\', // 分享地址
                        "title": \'这是title\', // 分享标题
                        success: function () {
                            //alert("分享成功");
                        }
                    };
                    wx.onMenuShareTimeline(shareDataq);
                    wx.onMenuShareAppMessage(shareData);
                    wx.onMenuShareQQ(shareData);
                    wx.onMenuShareWeibo(shareData);
                    wx.onMenuShareQZone(shareData);
                });
            }
        },
        error: function (data) {
            console.log(JSON.stringify(data));
            //alert("连接失败!");
        }
    });
</script>

 

分类:

技术点:

相关文章: