wechat.min.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function getRootPath() {
  2. //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
  3. var curWwwPath = window.document.location.href;
  4. //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
  5. var pathName = window.document.location.pathname;
  6. var pos = curWwwPath.indexOf(pathName);
  7. //获取主机地址,如: http://localhost:8080
  8. var localhostPath = curWwwPath.substring(0, pos);
  9. //获取带"/"的项目名,如:/ems
  10. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  11. return (localhostPath + projectName);
  12. }
  13. !function() {
  14. var e = {
  15. title:"来抖音,放肆刷;",
  16. desc: (window.location.href.indexOf('fes=jh3')>0 ? '头条系9GB免流量畅玩不断!' : '头条系10GB免流量畅玩不断!'),
  17. link: window.location.href,
  18. imgUrl: "http://800.wo.cn/orderchannel/hd/Dy/images/banner1.png"
  19. };
  20. $.ajax({
  21. url: getRootPath() + "-s1api" + '/jssdk/init',
  22. data: "url=" + encodeURIComponent(window.location.href),
  23. type: "get",
  24. dataType: "json",
  25. success: function(n) {
  26. wx.config({
  27. debug: !1,
  28. appId: n.appId,
  29. timestamp: n.timestamp,
  30. nonceStr: n.nonceStr,
  31. signature: n.signature,
  32. jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage"]
  33. }),
  34. wx.ready(function() {
  35. wx.checkJsApi({
  36. jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"],
  37. success: function(e) {}
  38. }),
  39. wx.onMenuShareTimeline({
  40. title: e.title,
  41. link: e.link,
  42. imgUrl: e.imgUrl,
  43. success: function() {},
  44. cancel: function() {}
  45. }),
  46. wx.onMenuShareAppMessage({
  47. title: e.title,
  48. desc: e.desc,
  49. link: e.link,
  50. imgUrl: e.imgUrl,
  51. type: "link",
  52. dataUrl: "",
  53. success: function() {},
  54. cancel: function() {}
  55. }),
  56. wx.hideMenuItems({
  57. menuList: ["menuItem:copyUrl"]
  58. })
  59. })
  60. }
  61. })
  62. } ();