zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    [de2_tv] PAL制TV_VGA
    【转】NiosII中SDRAM相移计算
    VGA controller的代码分析
    TIOBE 2012年2月编程语言排行榜:C#力压C++
    ZendFramework入门2 使用布局
    转载 20个数据库设计最佳实践
    转载 20个很有用的CSS图形和图表技术和教程
    转载 10款实用的Ajax/JavaScript编码工具推荐
    转载 打造优秀Web设计的10项原则
    2012年1月编程语言排行榜:ObjectiveC成为年度语言
  • 原文地址:https://www.cnblogs.com/fkcqwq/p/13151251.html
Copyright © 2011-2022 走看看