美文网首页
微信网页二次分享缩略图不显示和简介遇到的坑

微信网页二次分享缩略图不显示和简介遇到的坑

作者: _菩提本无树_ | 来源:发表于2019-05-31 15:51 被阅读0次

这两天在写网页分享遇到了一个神奇的问题,就是二次分享在iOS中可以正常展示,但是在安卓中缩略图不能正常展示的,展示的是万恶的曲别针!话不多说直接说自己的想法.

----看看你的图片链接是http还是https跟你的网页是否一致了!!!

就是因为这个把我坑了好大一会.下面直接上代码!

  • js库用的是1.0.0的

    <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    
  • 实现代码

      <script>
      $(function(){
          var Api = "";
          var title = "六一免费送";
          var desc3E = "简介";
          var curUrl = location.href.split('#')[0];
          var linkUrl = curUrl;
          //就是这个位置
          var imageUrl ="https://****/img/launcher.png"
          var _this = this;
          $.ajax({
              url:'https://****/wechat/getShareInfo',
              data:{
                  url : curUrl
              },
              success:function(res){
                  _this.configPlist(res);
              }
    
          })
    
          this.configPlist = function(res){
              var _this = this;
              var appId = res["data"].appId;
              var nonceStr = res["data"].nonceStr;  
              var jsapi_ticket = res["data"].jsapi_ticket;  
              var timestamp = res["data"].timestamp;  
              var signature = res["data"].signature;  
              wx.config({
                  debug:false,
                  appId:res["data"].appId,
                  timestamp:res["data"].timestamp,
                  signature:res["data"].signature,
                  nonceStr:res["data"].nonceStr,
                  jsApiList:[
                      "onMenuShareAppMessage", 
                      "onMenuShareTimeline",
                      "hideMenuItems"
                  ]
              })
              wx.ready(function(){
                  _this.doHideMenuItems();
                  _this.doOnMenuShareAppMessage();
                  _this.doOnMenuShareTimeline();
              })
              wx.error(function(res) {  
                  alert('error');  
              });  
          
          }
          this.doHideMenuItems = function(){
              wx.hideMenuItems({
                  menuList: [
                      'menuItem:openWithSafari',
                      'menuItem:share:email',
                      'menuItem:openWithQQBrowser',
                      'menuItem:favorite',
                      'menuItem:share:weiboApp',
                      'menuItem:share:qq',
                      'menuItem:share:QZone',
                      ],
              });
          }
          this.doOnMenuShareAppMessage = function(){
              wx.onMenuShareAppMessage({
                  // 分享给朋友
                  title : title,  
                  desc : desc3E,    
                  link : linkUrl, 
                  imgUrl :imageUrl,  
              })
          }
          this.doOnMenuShareTimeline = function(){
              wx.onMenuShareTimeline({
                  title : title,  
                  link : linkUrl, 
                  imgUrl : imageUrl,
              })
          }
          this.doOnMenuShareQQ = function(){
              wx.onMenuShareQQ({
                  title: title,    
                  desc: desc3E,     
                  link: linkUrl,    
                  imgUrl:imageUrl 
              });
          }
          this.doOnMenuShareQZone = function(){
              wx.onMenuShareQZone({
                  title: title,    
                  desc: desc3E,     
                  link: linkUrl,    
                  imgUrl:imageUrl 
              })
          }
      })
      </script>
    

->共同学习一起进步😁

相关文章

网友评论

      本文标题:微信网页二次分享缩略图不显示和简介遇到的坑

      本文链接:https://www.haomeiwen.com/subject/udcgtctx.html