game_base.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. if (void 0 == APP_BASE_URL) var APP_BASE_URL = "http://game.ikongzhong.cn/";
  2. if (void 0 == GAME_LIST_URL) var GAME_LIST_URL = "http://game.ikongzhong.cn/";
  3. if (void 0 == FOLLOW_URL) var FOLLOW_URL = "http://game.ikongzhong.cn/";
  4. var BASE_RES_DIR = "../",
  5. RES_DIR = "",
  6. APP_DEPLOYMENT = "WEB",
  7. USE_NATIVE_SOUND = !1,
  8. USE_NATIVE_SHARE = !1,
  9. IS_IOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? !0 : !1,
  10. IS_ANDROID = -1 < navigator.userAgent.indexOf("Android"),
  11. IS_NATIVE_ANDROID = IS_ANDROID && -1 < navigator.userAgent.indexOf("Version"),
  12. IS_REFFER = /referrer/.test(location.search) ? !0 : !1,
  13. SHOW_LLAMA = !0,
  14. SHOW_COPYRIGHT = !1,
  15. IN_WEIXIN = !1;
  16. 0 <= document.URL.indexOf("file://") && (IS_ANDROID || IS_IOS) && (APP_DEPLOYMENT = "APP", USE_NATIVE_SOUND = USE_NATIVE_SHARE = !0, APP_BASE_URL = "http://game.ikongzhong.cn/");
  17. document.addEventListener("WeixinJSBridgeReady", function () {
  18. IN_WEIXIN = !0;
  19. WeixinJSBridge.call("showOptionMenu");
  20. WeixinJSBridge.call("hideToolbar")
  21. });
  22. var PID = 0,
  23. USERNAME = "",
  24. IS_SUB = !1,
  25. GAME_URL = APP_BASE_URL + "game/" + GID,
  26. BEST_URL = APP_BASE_URL + "best/" + GID,
  27. UPLOAD_URL = APP_BASE_URL + "upload/" + GID,
  28. LB_URL = APP_BASE_URL + "lb/" + GID,
  29. ACTION_URL = APP_BASE_URL + "actionlog",
  30. best = -1E4,
  31. score = 0,
  32. record_flag = !1,
  33. logFlag = !1,
  34. keyStorage = "best:" + GID + ":" + PID;
  35. var mebtnopenurl = "http://mp.weixin.qq.com/s?__biz=MzI4MjA2MjE0MQ==&mid=246005295&idx=1&sn=490f8141976d607ba079d48f52a3fcd7#rd";
  36. window.shareData = {
  37. "imgUrl": "http://game.ikongzhong.cn/icon/qbllk.png",
  38. "timeLineLink": "http://game.ikongzhong.cn/games/qbllk/",
  39. "tTitle": "奇葩连连看-空中传媒",
  40. "tContent": "要你命的奇葩大合集,玩完这款游戏,我都快变成奇葩了。"
  41. };
  42. document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
  43. WeixinJSBridge.on('menu:share:appmessage', function (argv) {
  44. WeixinJSBridge.invoke('sendAppMessage', {
  45. "img_url": window.shareData.imgUrl,
  46. "link": window.shareData.timeLineLink,
  47. "desc": window.shareData.tContent,
  48. "title": score == 0 ? window.shareData.tTitle : "奇葩连连看,连死了" + Math.abs(score) + "对奇葩,获得奇葩杀手称号,不服来挑一个!"
  49. }, function (res) {
  50. document.location.href = mebtnopenurl;
  51. })
  52. });
  53. WeixinJSBridge.on('menu:share:timeline', function (argv) {
  54. WeixinJSBridge.invoke('shareTimeline', {
  55. "img_url": window.shareData.imgUrl,
  56. "img_width": "640",
  57. "img_height": "640",
  58. "link": window.shareData.timeLineLink,
  59. "desc": window.shareData.tContent,
  60. "title": score == 0 ? window.shareData.tTitle : "奇葩连连看,连死了" + Math.abs(score) + "对奇葩,获得奇葩杀手称号,不服来挑一个!"
  61. }, function (res) {
  62. document.location.href = mebtnopenurl;
  63. });
  64. });
  65. }, false);
  66. function initBest() {
  67. best = gjStorage.get(keyStorage) || -1E4
  68. }
  69. function cacheBest(a) {
  70. a > best && (best = a, gjStorage.set(keyStorage, best))
  71. }
  72. function onNewScore() {
  73. return gjQipa.newscore_wxoauth(score)
  74. }
  75. function share(a) {
  76. IS_TOUCH && a.nativeEvent instanceof MouseEvent || share()
  77. }
  78. function share() {
  79. alert("请点击右上角按钮分享成绩到朋友圈哦!");
  80. //if (USE_NATIVE_SHARE) window.open("qipa://share/" + GID + "/" + score + "/" + best);
  81. //else {
  82. // var a = "undefined" != typeof USERNAME ? "share.html?name=" + encodeURIComponent(USERNAME) + "&score=" + score + "&best=" + best + "&pid=" + PID : SHARE_URL.replace("/" + GID + "/0/0", "/" + GID + "/" + score + "/" + best);
  83. // window.open(a, "share")
  84. //}
  85. }
  86. function showTop(a) {
  87. IS_TOUCH && a.nativeEvent instanceof MouseEvent || showTop()
  88. }
  89. function showTop() {
  90. //showPopup(LB_URL)
  91. }
  92. $(function () {
  93. $("#lbFrame").hide();
  94. $(".closeIframe").click(function () {
  95. hidePopup()
  96. })
  97. });
  98. function showPopup(a) {
  99. var b = document.body.scrollWidth,
  100. c = document.body.scrollHeight;
  101. $("#lbFrame").css({
  102. width: b,
  103. height: c
  104. }).attr("src", a).fadeIn();
  105. $(".closeIframe").show()
  106. }
  107. function hidePopup() {
  108. $("#lbFrame").fadeOut();
  109. $(".closeIframe").fadeOut();
  110. "function" == typeof onPopupClose && onPopupClose()
  111. }
  112. function parseSearchArgs() {
  113. for (var a = location.search, b = /(\w+)=([^&]*)/g, c, d = {}; c = b.exec(a) ;) d[c[1]] = c[2];
  114. return d
  115. }
  116. function sendSearchArgs() {
  117. "APP" != APP_DEPLOYMENT && "undefined" != typeof GAME_URL && $.getJSON(getLoadGameDataUrl(!0), function (a) {
  118. _loadGameData(a);
  119. initBest()
  120. })
  121. }
  122. function getLoadGameDataUrl(a) {
  123. var b = location.search;
  124. 0 == b.length && (b = "?");
  125. var c = b.charAt(b.length - 1);
  126. "?" != c && "&" != c && (b += "&");
  127. return GAME_URL + (b + ("callback=" + (a ? "?" : "_loadGameData")))
  128. }
  129. function _loadGameData(a) {
  130. IS_SUB = a.sub;
  131. PID = a.pid;
  132. USERNAME = a.name
  133. } (function (a, b) {
  134. a.get = function (a) {
  135. try {
  136. a in localStorage && ($.cookie(a, localStorage[a], {
  137. expires: 60
  138. }), localStorage.removeItem(a))
  139. } catch (b) { }
  140. return $.cookie(a)
  141. };
  142. a.set = function (a, b) {
  143. $.cookie(a, b, {
  144. expires: 60
  145. });
  146. return !0
  147. }
  148. })(window.gjStorage = window.gjStorage || {});
  149. (function (a, b) {
  150. a.newscore_wxoauth = function (a) {
  151. var b = APP_BASE_URL + "wxoauth/newscore/" + GID;
  152. a > best && (record_flag = !0, cacheBest(a));
  153. a <= SCORE_LIMIT || (b += "?" + $.param({
  154. score: a,
  155. return_url: location.origin + location.pathname
  156. }), console.log(b), $.getJSON(b + "&callback=?").done(function (a) {
  157. "wxoauth_needed" == a.error && !0 == window.confirm("需要名字才能上传高分,请授权微信读取您的名字和头像。") && window.open(b, "_parent")
  158. }))
  159. };
  160. a.onGameInit = function () { };
  161. a.onGameStarted = function () { };
  162. a.onGameOver = function () { }
  163. })(window.gjQipa = window.gjQipa || {});