/** * wx sdk * @param {*} title * @param {*} desc */ function wxShare(title, desc) { var url = window.location.href; $.ajax({ type: 'post', url: '/WeChat/getConfig', // contentType: false, data: { url: url }, async: true, dataType: 'json', success: function (res) { // console.log(res); var data = res.data; wx.config({ debug: false, appId: data.appId, timestamp: data.timestamp, nonceStr: data.nonceStr, signature: data.signature, jsApiList:[ 'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'updateAppMessageShareData', 'updateTimelineShareData' ], }) } }) // sdk 鏉冮檺楠岃瘉閰嶇疆鎴愬姛鍥炶皟 wx.ready(function() { var icon = window.location.origin + "/images/favicon.png"; // console.log("icon", icon); wx.updateAppMessageShareData({ title: title, desc: desc, link: url, imgUrl: icon, success: function () { // } }) wx.updateTimelineShareData({ title: title, link: url, imgUrl: icon, success: function () { // } }) }) // sdk 鏉冮檺楠岃瘉閰嶇疆澶辫触鍥炶皟 wx.error(function(res) { // console.log('wx.error', res); }); }