function getRootPath() { //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8080 var localhostPath = curWwwPath.substring(0, pos); //获取带"/"的项目名,如:/ems var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPath + projectName); } !function() { var e = { title:"来抖音,放肆刷;", desc: (window.location.href.indexOf('fes=jh3')>0 ? '头条系9GB免流量畅玩不断!' : '头条系10GB免流量畅玩不断!'), link: window.location.href, imgUrl: "http://800.wo.cn/orderchannel/hd/Dy/images/banner1.png" }; $.ajax({ url: getRootPath() + "-s1api" + '/jssdk/init', data: "url=" + encodeURIComponent(window.location.href), type: "get", dataType: "json", success: function(n) { wx.config({ debug: !1, appId: n.appId, timestamp: n.timestamp, nonceStr: n.nonceStr, signature: n.signature, jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage"] }), wx.ready(function() { wx.checkJsApi({ jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"], success: function(e) {} }), wx.onMenuShareTimeline({ title: e.title, link: e.link, imgUrl: e.imgUrl, success: function() {}, cancel: function() {} }), wx.onMenuShareAppMessage({ title: e.title, desc: e.desc, link: e.link, imgUrl: e.imgUrl, type: "link", dataUrl: "", success: function() {}, cancel: function() {} }), wx.hideMenuItems({ menuList: ["menuItem:copyUrl"] }) }) } }) } ();