分享微信链接自定义标题前端(基于asp测试版)

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"  content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<script src="./js/jquery-2.1.1.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <title>TEST</title>
</head>
    <body><p>每一件事都行!</p>
        <button onclick="ajaxConfig()">测试结果</button>     
    </body>
<script  type="text/javascript">
    function ajaxConfig(){
        let url1 = "https://api.douban.com/v2/book/isbn/"+ 9787040332612
        var url=window.location.href.split(‘#‘)[0];  
        url = url.replace(/&/g, ‘%26‘);
        let url_config = "http://118.25.3.240:8060/getUrl?url="+url
        $.ajax({
            type: "GET",
            url: url_config,
            dataType: "JSON",
            processData: false,
            success: function (obj) {
                console.log(obj)
                wx.config({
                    debug: true,
                    appId: obj.appId,
                    timestamp: obj.timestamp,
                    nonceStr: obj.nonceStr,
                    signature: obj.signature,
                    jsApiList: [
                        ‘onMenuShareAppMessage‘
                    ]
                });
                wx.checkJsApi({

                       jsApiList: [‘onMenuShareTimeline‘,‘onMenuShareAppMessage‘], // 需要检测的JS接口列表,所有JS接口列表见附录2,

                       success: function(res) {

                        }

                       });
                wx.ready(function () {
                    wx.onMenuShareAppMessage({
                        title: ‘你好‘, // 分享标题
                        desc: "每一件事,你好", // 分享描述
                        link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                        imgUrl: ‘‘, // 分享图标
                        trigger: function (res) {
                            alert(‘用户点击发送给朋友‘);
                        },
                        success: function (res) {
                            alert(‘已分享‘);
                        },
                        cancel: function (res) {
                            alert(‘已取消‘);
                        },
                        fail: function (res) {
                            alert(JSON.stringify(res));
                        }
                        
                    });
                              
            });     
           
              },
               error: function(e){
                console.log("error")
             }
               
                 });
        }
    
</script>



分享微信链接自定义标题前端(基于asp测试版)

上一篇:个人信息——头像更换(拍照或相册上传)~ 微信小程序


下一篇:微信网页授权获取用户openid及用户信息