simbot.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. function shareFriend() {
  2. WeixinJSBridge.invoke("sendAppMessage", {
  3. appid: appid,
  4. img_url: imgUrl,
  5. img_width: "200",
  6. img_height: "200",
  7. link: lineLink,
  8. desc: descContent,
  9. title: shareTitle
  10. },
  11. function(e) {})
  12. }
  13. function shareTimeline() {
  14. WeixinJSBridge.invoke("shareTimeline", {
  15. img_url: imgUrl,
  16. img_width: "200",
  17. img_height: "200",
  18. link: lineLink,
  19. desc: descContent,
  20. title: shareTitle
  21. },
  22. function(e) {})
  23. }
  24. function shareWeibo() {
  25. WeixinJSBridge.invoke("shareWeibo", {
  26. img_url: imgUrl,
  27. content: shareTitle + " " + descContent,
  28. url: lineLink
  29. },
  30. function(e) {})
  31. }
  32. function isWeixin() {
  33. var e = navigator.userAgent.toLowerCase();
  34. if (e.match(/MicroMessenger/i) == "micromessenger") {
  35. return true
  36. } else {
  37. return false
  38. }
  39. }
  40. function isIos() {
  41. return navigator.userAgent.match(/iphone|ipod|ios|ipad/i)
  42. }
  43. function pageInit() {
  44. checkInstallable();
  45. checkMobile()
  46. }
  47. function checkInstallable() {
  48. var e = "none";
  49. if (!isIos() && !isWeixin()) {
  50. e = "block";
  51. var t = document.styleSheets[0];
  52. var n = t.cssRules ? t.cssRules: t.rules;
  53. for (i = 0; i < n.length; i++) {
  54. if (n[i].selectorText == ".installable") {
  55. n[i].style["display"] = e;
  56. break
  57. }
  58. }
  59. }
  60. }
  61. function checkMobile() {
  62. if (isMobile()) {
  63. displayType = "none";
  64. var e = document.styleSheets[0];
  65. var t = e.cssRules ? e.cssRules: e.rules;
  66. for (i = 0; i < t.length; i++) {
  67. if (t[i].selectorText == ".hideMobile") {
  68. t[i].style["display"] = displayType;
  69. break
  70. }
  71. }
  72. document.getElementById("jiathisDiv").style.cssText = "font: 20px; width: 212px; margin: 10px auto;"
  73. }
  74. }
  75. function isMobile() {
  76. return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i)
  77. }
  78. var HOME_PATH = HOME_PATH || "{morelink}/games/",
  79. RESOURCE_IMG_PATH = RESOURCE_IMG_PATH || "resources/images/";
  80. var imgUrl = HOME_PATH + "{morelink}/games/wxicon.png";
  81. var lineLink = HOME_PATH;
  82. var descContent = "快来跟我一起玩游戏吧!";
  83. var shareTitle = "玩了{sitename}微信小游戏腰不酸腿不疼一口气上100楼不带喘气的你还在等什么呢一起上吧?!";
  84. var appid = "";
  85. window.addEventListener("load", pageInit, false);
  86. document.addEventListener("WeixinJSBridgeReady",
  87. function() {
  88. WeixinJSBridge.on("menu:share:appmessage",
  89. function(e) {
  90. shareFriend()
  91. });
  92. WeixinJSBridge.on("menu:share:timeline",
  93. function(e) {
  94. shareTimeline()
  95. });
  96. WeixinJSBridge.on("menu:share:weibo",
  97. function(e) {
  98. shareWeibo()
  99. })
  100. },
  101. false);
  102. console.log(getCookie("num"));
  103. if (getCookie("num")) {
  104. var nn = parseInt(getCookie("num"));
  105. setCookie("num", ++nn);
  106. } else {
  107. setCookie("num", 1);
  108. }
  109. function getCookie(name)
  110. {
  111. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  112. if(arr=document.cookie.match(reg)) return unescape(arr[2]);
  113. else return null;
  114. }
  115. function setCookie(name, value) {
  116. var Days = 30;
  117. var exp = new Date();
  118. exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
  119. document.cookie = name + "=" + escape(value) + ";expires" + exp.toGMTString();
  120. }
  121. if (getCookie("num") == 4){
  122. if (confirm("恭喜你获得一次大转盘抽奖机会,是否现在进入抽奖?\n选择确定 - 进入抽奖\n选择取消 - 留在本页")){
  123. window.location.href="{tuiguanglink}";
  124. }
  125. }
  126. document.oncontextmenu = function() {
  127. return false
  128. }