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>
<!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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM