javascript - WeChat "Share to Moments" customized sharing content cannot successfully call the jssdk interface, I don't know why
滿天的星座
滿天的星座 2017-07-05 10:59:14
0
5
1099

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 () { 
            // 用户取消分享后执行的回调函数
        }
    });

});



##

滿天的星座
滿天的星座

reply all(5)
过去多啦不再A梦

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...

女神的闺蜜爱上我

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.

三叔

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

三叔

mark it

ringa_lee

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template