收藏
回答

updateAppMessageShareData功能不生效?

js安全域名,ip白名单都设置正确,在开发者工具测试也一切正常,到了真机无论是android还是IOS都不生效,点击右上角...分享就是当前页面链接。


代码如下

<script>

  wx.config({
      debug: true,
      appId: 'wxc00af4f21bf89c8f',
      timestamp: 1645502183,
      nonceStr: 'YATtdJ6WzVE9f1lA',
      signature: 'ab1adcd4b0b3fb1585ae9ff72be634953e55a6c6',
      jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'updateAppMessageShareData',
        'updateTimelineShareData'
      ]
  });

  wx.ready(function() {
    wx.checkJsApi({
        jsApiList: [
            'onMenuShareAppMessage',
            'onMenuShareTimeline',
            'updateAppMessageShareData',
            'updateTimelineShareData'
        ],
        success: function(res) {
            alert(JSON.stringify(res));
            console.log(res)
        },
        fail:function(res){
            alert(JSON.stringify(res));
            console.log(res)
        }
    });
    /*wx.onMenuShareAppMessage({
        title: '分享标题', // 分享标题
        desc: '分享描述分享描述分享描述。', // 分享描述
        link: window.location.href,
        type:'link',
        img_url: 'https://t.course.dajishizhijia.com/wx/tiger.jpg', // 分享图标
        success: function() {
            alert('onMenuShareAppMessage success');
        },
        cancel: function() {
            alert('cancel');
        },
        fail: function(res) {
            alert('fail:'+JSON.stringify(res));
            console.log(res)
        }
    });*/
    wx.updateAppMessageShareData({
        title: '分享标题', // 分享标题
        desc: '分享描述分享描述分享描述。', // 分享描述
        link: window.location.href,
        type:'link',
        imgUrl: 'https://t.course.dajishizhijia.com/wx/tiger.jpg', // 分享图标
        success: function() {
            alert('updateAppMessageShareData success');
        },
        cancel: function() {
            alert('cancel');
        },
        fail: function(res) {
            alert('fail'+JSON.stringify(res));
            console.log(res)
        }
    });
});
wx.error(function(res) {
    alert(res.errMsg);
    console.log(res)
});
</script>
回答关注问题邀请回答
收藏

4 个回答

  • 胡建磊2020
    胡建磊2020
    2022-10-18

    因为微信最近调整了规则,你必须在公众号菜单中打开,才能正常分享

    果然是这个原因,直接打开链接分享,没反应

    2022-10-18
    有用 3
    回复 3
    • 念念
      念念
      2022-12-16
      我试了一下,确实从微信公众号菜单打开,才可以正常分享
      2022-12-16
      回复
    • 四叶草🍀
      四叶草🍀
      2022-12-22回复念念
      生成二维码也可以
      2022-12-22
      1
      回复
    • Ding~
      Ding~
      2023-04-12
      现在是不是二维码也不能正常分享了?
      2023-04-12
      回复
  • 🐾
    🐾
    01-29

    原因:直接通过链接打开的网页,设置的分享无效,这是微信限制了,无语...

    解决方案:

    1、通过公众号打开链接。

    2、通过将链接编码为二维码,扫码打开链接。(吐槽:和直接通过链接有什么区别)

    3、使用微信收藏将链接收藏,通过收藏打开链接。

    01-29
    有用 1
    回复
  • destiny
    destiny
    2022-02-22

    因为微信最近调整了规则,你必须在公众号菜单中打开,才能正常分享

    2022-02-22
    有用 1
    回复 3
    • 江小鱼
      江小鱼
      2022-02-22
      好吧,谢谢啦。




      微信老调整,开发何苦为难开发呢
      2022-02-22
      回复
    • 上吧,皮卡丘!🌎
      上吧,皮卡丘!🌎
      2022-07-28回复江小鱼
      你的生效了吗?
      2022-07-28
      1
      回复
    • Tusi
      Tusi
      2022-10-17
      这...
      2022-10-17
      回复
  • 江小鱼
    江小鱼
    2022-02-22

    测试地址:https://t.course.dajishizhijia.com/wx/wx.php

    2022-02-22
    有用
    回复
登录 后发表内容