search

Home  >  Q&A  >  body text

javascript - WeChat "Share to Moments" customized sharing content cannot successfully call the jssdk interface, I don't know why

WeChat "Share to Moments" customizes the jssdk interface for sharing content. For some reason, the result is not the set title description and picture.
√The official account has been certified.
√The js safe domain name in the function settings is the same as the domain name of the opened page.
√debug: true When turned on, there is no problem with the configuration.
√checkJsApi also pops up the support interface.

but! ! ! The results turned out to be incompatible! The result is that the title description and image are not set.
Who knows? ?

code show as below:

var wechat_img={$wechat_share}[0];
var wechat_title={$wechat_share}[1];
var wechat_desc={$wechat_share}[2];    
wx.config({
    debug: true,
    appId: {$signPackage}["appid"],
    timestamp: {$signPackage}["timestamp"]+'',
    nonceStr: {$signPackage}["nonceStr"],
    signature: {$signPackage}["signature"],
    jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage'                
    ]
});

wx.ready(function(){     
    wx.checkJsApi({
        jsApiList: ['onMenuShareTimeline'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
    });

    wx.onMenuShareTimeline({
        title: wechat_tile, // 分享标题
        link: {$signPackage}["url"], // 分享链接
        imgUrl: wechat_img, // 分享图标
        success: function () { 
            alert('thanks for share');
        },
        cancel: function () { 
            // 用户取消分享后执行的回调函数
        }
    });

    wx.onMenuShareAppMessage({
        title: wechat_tile, // 分享标题
        desc: wechat_desc, // 分享描述
        link: {$signPackage}["url"], // 分享链接
        imgUrl: wechat_img, // 分享图标
        type: '', // 分享类型,music、video或link,不填默认为link
        dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
        success: function () { 
            alert('thanks for share');
        },
        cancel: function () { 
            // 用户取消分享后执行的回调函数
        }
    });

});



##

滿天的星座滿天的星座2704 days ago1105

reply all(5)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-05 11:01:14

    The final solution to the problem is to use multiple different events to trigger wx.onMenuShareAppMessage.
    Every imaginable event is used, windows.onoad, document.ontouchstart...

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-05 11:01:14

    Is link also a safe domain name?

    My situation was similar to yours before, that is, the link was not a secure domain name set by the official account.

    reply
    0
  • 三叔

    三叔2017-07-05 11:01:14

    First check if there is any problem with the waiting time
    Directly adjust the share method in ready to see if it has any effect

    reply
    0
  • 三叔

    三叔2017-07-05 11:01:14

    mark it

    reply
    0
  • ringa_lee

    ringa_lee2017-07-05 11:01:14

    If you are testing now, the domain name must be registered

    reply
    0
  • Cancelreply