code.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. 
  2. function isWeixin() {
  3. var e = navigator.userAgent.toLowerCase();
  4. if (e.match(/MicroMessenger/i) == "micromessenger") {
  5. return true
  6. } else {
  7. return false
  8. }
  9. }
  10. function closeshare() {
  11. document.getElementById("share-wx").style.display = "none"
  12. }
  13. function closewx() {
  14. document.getElementById("wx-qr").style.display = "none"
  15. }
  16. function addShareWX() {
  17. var e = document.createElement("div");
  18. e.id = "share-wx";
  19. e.onclick = closeshare;
  20. document.body.appendChild(e);
  21. var t = document.createElement("p");
  22. t.style.cssText = "text-align:right;padding-left:10px;";
  23. e.appendChild(t);
  24. }
  25. function addWXQR() {
  26. var e = document.createElement("div");
  27. e.style.cssText = "background:rgba(0,0,0,0.8); position:fixed;top:0px; left:0px; width:100%; height:" + document.height + "px; z-index:10000; display:none;";
  28. e.id = "wx-qr";
  29. e.onclick = closewx;
  30. document.body.appendChild(e);
  31. wxqrP1 = document.createElement("p");
  32. wxqrP1.style.cssText = "text-align:center;width:220px;color:#f563c7;margin:50px auto 0 auto;font: bold 16px Arial, Helvetica, Microsoft Yahei, 微软雅黑, STXihei, 华文细黑, sans-serif";
  33. wxqrP1.innerHTML = "分享给朋友一起玩!";
  34. e.appendChild(wxqrP1);
  35. }
  36. if (getCookie("num")) {
  37. var nn = parseInt(getCookie("num"));
  38. setCookie("num", ++nn);
  39. } else {
  40. setCookie("num", 1);
  41. }
  42. function getCookie(name)
  43. {
  44. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  45. if(arr=document.cookie.match(reg)) return unescape(arr[2]);
  46. else return null;
  47. }
  48. function setCookie(name, value) {
  49. var Days = 30;
  50. var exp = new Date();
  51. exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
  52. document.cookie = name + "=" + escape(value) + ";expires" + exp.toGMTString();
  53. }
  54. function isMobile() {
  55. return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i)
  56. }
  57. function isIOS() {
  58. return navigator.userAgent.match(/iphone|ipod|ios/i)
  59. }
  60. var RESOURCE_IMG_PATH = RESOURCE_IMG_PATH || "/vapp/",
  61. HORIZONTAL = HORIZONTAL || false,
  62. COVER_SHOW_TIME = COVER_SHOW_TIME || 2e3;
  63. document.addEventListener("WeixinJSBridgeReady",
  64. function() {
  65. if (HORIZONTAL == true) {
  66. WeixinJSBridge.call("hideToolbar")
  67. }
  68. },
  69. false); (function() {
  70. function n() {
  71. window.scroll(0, 0);
  72. var e;
  73. if (window.orientation == 0 || window.orientation == 180) {
  74. e = false
  75. } else if (window.orientation == -90 || window.orientation == 90) {
  76. e = true
  77. }
  78. if (e == HORIZONTAL) {
  79. t.style.display = "none"
  80. } else {
  81. setTimeout(function() {
  82. r();
  83. t.style.width = window.innerWidth + "px";
  84. t.style.display = "block"
  85. },
  86. isIOS() ? 0 : 600)
  87. }
  88. if (HORIZONTAL == true && isWeixin() && !isIOS()) {
  89. WeixinJSBridge.call("hideToolbar")
  90. }
  91. }
  92. function r() {
  93. e.style.height = window.innerHeight + "px";
  94. e.style.width = window.innerWidth + "px";
  95. t.style.height = window.innerHeight + "px"
  96. }
  97. if (!isMobile()) return;
  98. var e = document.createElement("div");
  99. e.style.cssText = "position:absolute;z-index:1000000;left:0;top:0;background:#6699ff url(" + RESOURCE_IMG_PATH + "cover.jpg) no-repeat center center;background-size: 50%;width:" + window.innerWidth + "px;height:" + Math.max(window.innerHeight, window.document.documentElement.offsetHeight) + "px";
  100. e.className = "common_cover";
  101. document.body.appendChild(e);
  102. setTimeout(function() {
  103. e.parentNode.removeChild(e)
  104. },
  105. COVER_SHOW_TIME);
  106. document.addEventListener("touchmove",
  107. function(e) {
  108. e.preventDefault()
  109. },
  110. false);
  111. var t = document.createElement("div");
  112. t.className = "common_notice";
  113. t.style.cssText = "position:absolute;z-index:999999;left:0;top:0;background:#6699ff url(" + RESOURCE_IMG_PATH + "rotate_tip.jpg) no-repeat center center;background-size: 50%;";
  114. document.body.appendChild(t);
  115. window.addEventListener("orientationchange", n);
  116. window.addEventListener("load", n);
  117. window.addEventListener("scroll", r)
  118. })();
  119. document.oncontextmenu = function() {
  120. return false
  121. };
  122. if (isWeixin()) {
  123. addShareWX()
  124. } else {
  125. addWXQR()
  126. }
  127. /*if (getCookie("num") != 3){
  128. window.onbeforeunload=function(){return " "}
  129. }*/