当前位置:网站首页>How to customize sharing links in wechat for H5 web pages

How to customize sharing links in wechat for H5 web pages

2022-06-24 10:16:00 Ma Xiaotiao coding

1. introduce js file

<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript"></script>

2. Call the interface to receive the following data :

<!--  Sharing features  -->
<script>
    $.ajax({
    
        url: "/public/index.php/index/index/jsconfig.html",
        dataType: 'JSON',
        data: {
    
            url:window.location.href
         },
        type: 'POST',
        success: function(res) {
    
             console.log(' Print res',res)
              wx.config({
    
                   debug: false, //  Turn on debugging mode , Call all api The return value of will be on the client side alert come out , To see the parameters passed in , Can be in pc End open , The parameter information will go through log play , Only in pc Only when the end is printed .
                   appId: res.msg.appId, //  Required , The only sign of official account number 
                   timestamp:res.msg.timestamp, //  Required , Generate signature timestamp 
                   nonceStr: res.msg.nonceStr, //  Required , Generate a random string of signatures 
                   signature: res.msg.signature,//  Required , Signature , See appendix 1
                   jsApiList: res.msg.jsApiList //  Required , Required JS Interface list , all JS See Appendix... For the list of interfaces 2
             });
          },

          error: function(retrunData) {
    

		   });

</script>

Project operation :
In a h5 In the developed official account project , When sharing, the first image of the page is displayed by default as the cover image of the sharing link , Can't customize pictures to share with friends , The solution here is :
Add one at the top of each page logo chart , And set the width to 0, Just to keep it from showing . It only works when sharing .

<img src="__IMG__/mylogo.jpg" style="width:0 ;" >

 Insert picture description here

原网站

版权声明
本文为[Ma Xiaotiao coding]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240915341919.html