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>
复制代码

 

posted @   夏小夏吖  阅读(1115)  评论(1编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示