s: function(data) { wxdata = data; } }); //微信配置 var stitle = document.title; var sdesc = $("#rwb_zw p").eq(0).text() || $('meta[name="description"]').attr("content"); var slink = wxslink; var simgUrl = $("#rwb_zw img").eq(0).attr("src") || ""; if (simgUrl !== "") { getImgAbsPath(); } simgUrl || (simgUrl = "/images/fx_logo.jpg"); function getImgAbsPath() { var curPath = window.document.location.href; //获取主机地址之后的目录,如: myproj/view/my.jsp var pathName = window.document.location.pathname; var pos = curPath.indexOf(pathName); //获取主机地址,如: http://localhost var localhostPath = curPath.substring(0, pos); //获取带"/"的项目名,如:/myproj var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); //得到了 http://localhost/myproj var realPath = localhostPath + projectName; simgUrl = simgUrl.replace('../../', ''); simgUrl = realPath + '/' + simgUrl; console.log(simgUrl) } wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: wxdata.AppID, // 必填,公众号的唯一标识 timestamp: wxdata.timestamp, // 必填,生成签名的时间戳 nonceStr: wxdata.nonceStr, // 必填,生成签名的随机串 signature: wxdata.signature, // 必填,签名,见附录1 jsApiList: [ 'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'showAllNonBaseMenuItem',