Notes on using wx.onMenuShareTimeline
During the development and testing process, I found that using wx.onMenuShareTimeline has no effect, and the pictures, titles and links I defined are not displayed. After debugging, I found the following reasons:
1. The image size must be greater than 300pix to be displayed
2. This method must be config successfully before it can be called in wx.ready. I put it directly into $(function(){}) to execute, and practice proves that it is not possible.
wx.config({ debug: true, // Turn on debug mode, the return values of all APIs called will be alerted on the client. To view the passed parameters, you can open them on the PC side, the parameter information will be printed through the log and will only be printed on the PC side. appId: '{$appid}', // Required, the unique identifier of the official account timestamp: "{$signPackage.timestamp}", // Required, generate the signature timestamp nonceStr: '{$signPackage.nonceStr}', // Required, generate the signature random string signature: '{$signPackage.signature}', // Required, see Appendix 1 jsApiList: [ 'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo' ] // Required, the list of JS interfaces that need to be used, see Appendix 2 }); wx.ready(function () { wx.onMenuShareTimeline({ title: '--{$info.name}', // Share title link: '{$url}__URL__/index?pid={$pid}&puid={$uid}', // Share link, convert the currently logged-in user to puid to facilitate the development of offline imgUrl: '{$url}__PUBLIC__/Uploads/{$goodsvo.image}', // Sharing icon success: function () { // The callback function executed after the user confirms the sharing ('Shared Success'); }, cancel: function () { // The callback function executed after the user cancels the sharing} }); wx.error(function(res){ // The error function executed after the config information fails to verify. If the signature expires, the verification fails. For specific error messages, you can open the debug mode of config, or view it in the returned res parameter. For SPAs, you can update the signature here. alert("errorMSG:"+res); }); });Through this article, I hope it can help friends who encounter the same situation. Thank you for your support to this site!