gameapi_3366.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. function home_3366()
  2. {
  3. //alert("home_3366");
  4. try{parent.moregame();}catch(e){}
  5. }
  6. function more_3366()
  7. {
  8. home_3366="http://yx8.com/";
  9. }
  10. var t;
  11. var MyScore;
  12. function hideShare_3366()
  13. {
  14. clearTimeout(t)
  15. document.body.removeChild(document.getElementById('share_3366'));
  16. }
  17. function submit_3366(score)
  18. {
  19. //提交
  20. MyScore = score;
  21. var cachekey = 'RecentPlaykey';
  22. var str = getCookie(cachekey);
  23. var ary = [];
  24. str ? ary = str.split('|') : '';
  25. for(var i = 0, len = ary.length; i < len; i++)
  26. {
  27. var g = ary[i].split(',');
  28. if(Number(g[0]) == gameOption.gameid){
  29. if(g.length > 2){
  30. if((Number(g[2]) < score && gameOption.scorecmp == 2)|| (Number(g[2]) > score && gameOption.scorecmp == 1)){
  31. g[2] = score;
  32. ary[i] = g.join(',');
  33. }
  34. }else{
  35. ary[i]+=","+score;
  36. }
  37. break;
  38. }
  39. }
  40. setCookie(cachekey,ary.join('|'), 365);
  41. }
  42. function share_3366()
  43. {
  44. //分享到微信
  45. var str =MyScore;
  46. try{parent.__4399finishgame(str);}catch(e){}
  47. //alert("game over"+str);
  48. t = setTimeout(hideShare_3366, 3000);
  49. }
  50. function getCookie(c_name)
  51. {
  52. if (document.cookie.length>0)
  53. {
  54. var c_start=document.cookie.indexOf(c_name + "=")
  55. if (c_start!=-1)
  56. {
  57. c_start=c_start + c_name.length+1
  58. c_end=document.cookie.indexOf(";",c_start)
  59. if (c_end==-1) c_end=document.cookie.length
  60. return unescape(document.cookie.substring(c_start,c_end))
  61. }
  62. }
  63. return ""
  64. }
  65. function setCookie(c_name,value,expiredays)
  66. {
  67. var exdate=new Date()
  68. exdate.setDate(exdate.getDate()+expiredays);
  69. document.cookie = "http://h.7k7k.com/";
  70. }
  71. (function()
  72. {
  73. var gameid = gameOption.gameid;
  74. var serverId = gameid % 5 === 0 ? '' : gameid % 5;
  75. var imgurl = '';
  76. if(location.host == 'mt.3366.com')
  77. {
  78. imgurl = 'http://mt.3366.com/fileupload/h5games/iconfile/' + gameid % 100 + '/' + gameid + '.jpg';
  79. }
  80. else
  81. {
  82. imgurl = 'http://img' + serverId + '.3366img.com/fileupload/h5games/iconfile/' + gameid % 100 + '/' + gameid + '.jpg';
  83. }
  84. if(!window.shareData)
  85. {
  86. window.shareData =
  87. {
  88. "tContent": document.title,
  89. "tTitle": document.title
  90. }
  91. }
  92. function weixinShare()
  93. {
  94. var link = window.location.href
  95. if(window.shareData.tLink)
  96. {
  97. link = window.location.href;
  98. }
  99. WeixinJSBridge.on('menu:share:appmessage', function(argv) {
  100. WeixinJSBridge.invoke('sendAppMessage', {
  101. "img_url": imgurl,
  102. "link": link,
  103. "desc": window.shareData.tContent,
  104. "title": window.shareData.tTitle
  105. }, function(res) {
  106. if(typeof(pgvSendClick) == 'function'){
  107. pgvSendClick({hottag: '3366h5.wechat.gameshare.'+gameOption.gameid});
  108. }
  109. if(typeof (onShare_3366)== "function" )
  110. {
  111. onShare_3366(res);
  112. }
  113. });
  114. });
  115. WeixinJSBridge.on('menu:share:timeline', function(argv) {
  116. WeixinJSBridge.invoke('shareTimeline', {
  117. "img_url": imgurl,
  118. "img_width": "640",
  119. "img_height": "640",
  120. "link": link,
  121. "desc": window.shareData.tContent,
  122. "title": window.shareData.tTitle
  123. }, function(res) {
  124. if(typeof(pgvSendClick) == 'function'){
  125. pgvSendClick({hottag: '3366h5.wechat.gameshare.'+gameOption.gameid});
  126. }
  127. if(typeof (onShare_3366)== "function")
  128. {
  129. onShare_3366(res);
  130. }
  131. });
  132. });
  133. }
  134. if(typeof WeixinJSBridge != 'undefined')
  135. {
  136. weixinShare();
  137. }
  138. else
  139. {
  140. document.addEventListener('WeixinJSBridgeReady', function onBridgeReady()
  141. {
  142. weixinShare();
  143. }, false);
  144. }
  145. function getScript(url)
  146. {
  147. var s = document.createElement('script');
  148. s.src = url;
  149. document.body.appendChild(s);
  150. }
  151. //玩家玩过上报
  152. getScript('');
  153. //设置我玩过的
  154. function setRecentPlay(gameid)
  155. {
  156. var MAX_GAMES = 8;
  157. var cachekey = 'RecentPlaykey';
  158. var str = getCookie(cachekey);
  159. var ary = [];
  160. str ? ary = str.split('|') : '';
  161. var v = gameid+','+new Date().getTime();
  162. for(var i = 0, len = ary.length; i < len; i++)
  163. {
  164. var g = ary[i].split(',');
  165. if(Number(g[0]) == gameid){
  166. ary.splice(i,1);
  167. if(g.length > 2){
  168. v += ","+ g[2];
  169. }
  170. break;
  171. }
  172. }
  173. ary.unshift(v);
  174. if(ary.length > MAX_GAMES)
  175. {
  176. ary = ary.slice(0,MAX_GAMES);
  177. }
  178. setCookie(cachekey,ary.join('|'), 365);
  179. }
  180. setRecentPlay(gameid);
  181. //pv统计
  182. var head = document.body;
  183. var script = document.createElement("script");
  184. script.type = "text/javascript";
  185. script.onload=function(){
  186. if(typeof(pgvMain) == 'function')
  187. {
  188. pgvMain({virtualDomain:'h.7k7k.com'});
  189. }
  190. var c_start = window.location.href.indexOf("clicktag");
  191. if(typeof(pgvSendClick) == 'function' && c_start != -1)
  192. {
  193. c_start=c_start + 9;
  194. c_end=window.location.href.indexOf("&",c_start);
  195. if (c_end==-1) c_end=str.length;
  196. var tag = window.location.href.substring(c_start,c_end);
  197. pgvSendClick({hottag: tag});
  198. }
  199. if(location.search.indexOf("from=timeline") > -1){//朋友圈
  200. pgvSendClick({hottag: 'from wechat.cshareentry.'+gameOption.gameid});
  201. }
  202. if(location.search.indexOf("from=singlemessage") > -1){//好友
  203. pgvSendClick({hottag: 'from wechat.shareentry.'+gameOption.gameid});
  204. }
  205. if(gameOption.gamename == '看你控制力有多强' || gameOption.gamename == '能过河就算你狠')
  206. {
  207. $(document).delegate('.app-fixedad','click',function(e)
  208. {
  209. pgvSendClick({hottag: '3366h5.h5game.wechatad.'+gameOption.gameid});
  210. setTimeout(function()
  211. {
  212. location.href = 'http://mp.weixin.qq.com/s?__biz=MjM5MDAzMDIwMA==&mid=201146106&idx=1&sn=bf58e73067e22baf0b1c381dfc52b707#rd';
  213. },500);
  214. e.preventDefault();
  215. });
  216. }
  217. };
  218. script.src = "";
  219. head.appendChild(script);
  220. if(gameOption.gamename == '看你控制力有多强' || gameOption.gamename == '能过河就算你狠')
  221. {
  222. try
  223. {
  224. $(document).ready(function()
  225. {
  226. $(document.body).append('<div class="app-fixedad"><a href="#"><i class="logo"></i><span class="btn">关注</span><p class="wording">游戏精彩,不用下载!</p></a></div>');
  227. });
  228. }catch(_){}
  229. }
  230. })();