var phpdata; var url = window.location.href; $(function() { $.ajax({ url: "/cms/index/gettokens", type : "POST", data:{key:'tokens',url:url}, success: function(res){ if (res.code == 1){ phpdata = res.data wx.config({ debug: false, ticket: phpdata.ticket, appId: phpdata.appId, timestamp: phpdata.timestamp, nonceStr: phpdata.nonceStr, signature: phpdata.signature, jsApiList: [ 'updateAppMessageShareData', 'updateTimelineShareData' ] }); } } }); // alert("http://"+document.domain+"/static/modules/cms/wap/images/banner/banner2.jpg") var default_wximg = (typeof (wxthumb) != 'undefined' && wxthumb ) ? wxthumb:"/static/modules/cms/wap/images/logohanshang.jpg"; default_wximg = "http://"+document.domain+default_wximg; wx.ready(function () { // 在这里调用 API wx.updateAppMessageShareData({ title: wechartshar_title, // 分享标题 desc: wechartshar_desc, // 分享描述 link: window.location.href, // 分享链接 imgUrl: default_wximg, // 分享图标 success: function () { // 用户确认分享后执行的回调函数 }, cancel: function () { // 用户取消分享后执行的回调函数 } }); wx.updateTimelineShareData({ title: wechartshar_title, // 分享标题 link: window.location.href, // 分享链接 imgUrl: default_wximg, // 分享图标 success: function () { // 用户确认分享后执行的回调函数 }, cancel: function () { // 用户取消分享后执行的回调函数 } }); }); });