common.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. windowWidth=0,windowHeight=0,windowWidthScale=1,windowHeightScale=1;
  2. skySize={width:640,height:28800,acWidth:640,acHeight:28800};
  3. var startObj=null;
  4. var gameObj=null;
  5. var gameEndObj=null;
  6. var weixinUser=null;
  7. var tapEvent="touchstart click";
  8. var gameType="";
  9. var couponsData=[
  10. ];
  11. $(function(){
  12. if(getQueryString("gametype")){
  13. gameType=getQueryString("gametype");
  14. }
  15. windowInit();
  16. document.body.addEventListener('touchmove',function(e){
  17. e.stopPropagation();
  18. e.preventDefault();
  19. });
  20. filesLoad();
  21. _smq.push(['custom', '杜杜足球赛', '游戏页面', '开始加载', ,1]);
  22. if(getQueryString("id")){
  23. $("#selecttype").hide();
  24. }
  25. $("#selecttype>.t2,#selecttype>.t3").bind(tapEvent,function(e){
  26. if($(this).hasClass("t2")){
  27. gameType="click";
  28. $(".start .speedup .txt").removeClass("txt-y");
  29. _smq.push(['custom', '杜杜足球赛', '游戏页面', 'G点戳戳']);
  30. _gaq.push(['_trackEvent', '杜杜足球赛', '游戏页面', 'G点戳戳']);
  31. }else{
  32. gameType="shake";
  33. $(".start .speedup .txt").addClass("txt-y");
  34. _smq.push(['custom', '杜杜足球赛', '游戏页面', 'high抖抖']);
  35. _gaq.push(['_trackEvent', '杜杜足球赛', '游戏页面', 'high抖抖']);
  36. }
  37. $("#selecttype").hide();
  38. if(!isLoaded){
  39. $(".start .loading").show();
  40. }else{
  41. showStart();
  42. }
  43. });
  44. var isLoaded=false;
  45. function filesLoad(){
  46. var loadingTxt=$("#loading .ft");
  47. var queue = new createjs.LoadQueue();
  48. queue.installPlugin(createjs.Sound);
  49. queue.on("complete", handleComplete, this);
  50. queue.on("progress", handleProgress, this);
  51. //queue.loadFile({id:"sound", src:"mp3/1.mp3"});
  52. queue.loadManifest([
  53. {id:"sound", src:"mp3/2.mp3"},
  54. {id: "footballshadow", src:"images/footballshadow.png"},
  55. {id: "prose", src:"images/prose.png"},
  56. {id: "shareico", src:"images/shareico.png"},
  57. {id: "football", src:"images/football.png"},
  58. {id: "startbg", src:"images/start/bg.jpg"},
  59. {id: "start-txt-1", src:"images/start/start-txt-1.png"},
  60. {id: "start-txt-2", src:"images/start/start-txt-2.png"},
  61. {id: "zha", src:"images/start/zha.png"},
  62. {id: "logo", src:"images/start/logo.png"},
  63. {id: "img", src:"images/start/img.png"},
  64. {id: "halo-1", src:"images/start/halo-1.png"},
  65. {id: "halo-2", src:"images/start/halo-2.png"},
  66. {id: "halo-3", src:"images/start/halo-3.png"},
  67. {id: "halo-4", src:"images/start/halo-4.png"},
  68. {id: "hand", src:"images/start/hand.png"},
  69. {id: "speed-nbg", src:"images/start/speed/nbg.png"},
  70. {id: "speed-nhand", src:"images/start/speed/nhand.png"},
  71. {id: "speed-ntxt", src:"images/start/speed/ntxt.png"},
  72. {id: "flightbg", src:"images/gaming/bg.jpg"},
  73. {id: "cjb", src:"images/gaming/1.png"},
  74. {id: "gaming-football", src:"images/gaming/football.png"},
  75. {id: "gaming-huo", src:"images/gaming/huo.png"},
  76. {id: "gaming-superman", src:"images/gaming/superman.png"},
  77. {id: "gaming-tao", src:"images/gaming/tao.png"},
  78. {id: "gaming-wate-g", src:"images/gaming/wate-g.png"},
  79. {id: "gaming-wate-g-1", src:"images/gaming/wate-g-1.png"},
  80. {id: "gaming-wate-g-2", src:"images/gaming/wate-g-2.png"},
  81. {id: "gend-b-3", src:"images/gameend/b-3.png"},
  82. {id: "gend-c1", src:"images/gameend/c1.png"},
  83. {id: "gend-c2", src:"images/gameend/c2.png"},
  84. {id: "gend-h", src:"images/gameend/h.png"},
  85. {id: "gend-t-0", src:"images/gameend/t-0.png"},
  86. {id: "gend-t-1", src:"images/gameend/t-1.png"},
  87. {id: "gend-t-2", src:"images/gameend/t-2.png"},
  88. {id: "gend-t-3", src:"images/gameend/t-3.png"},
  89. {id: "gend-t-s", src:"images/gameend/t-s.png"},
  90. {id: "gend-y-1", src:"images/gameend/y/1.png"},
  91. {id: "gend-y-2", src:"images/gameend/y/2.png"},
  92. {id: "gend-y-3", src:"images/gameend/y/3.png"},
  93. {id: "gend-y-4", src:"images/gameend/y/4.png"},
  94. {id: "gend-y-5", src:"images/gameend/y/5.png"},
  95. {id: "gend-y-6", src:"images/gameend/y/6.png"},
  96. {id: "grand-b1", src:"images/rand/b1.png"},
  97. {id: "grand-b2", src:"images/rand/b2.png"},
  98. {id: "grand-line", src:"images/rand/line.png"},
  99. {id: "grand-listshadow", src:"images/rand/listshadow.png"},
  100. {id: "grand-title", src:"images/rand/title.png"}
  101. ]);
  102. function handleComplete() {
  103. if(isLoaded){return;}
  104. isLoaded=true;
  105. //var flightbg = $(queue.getResult("flightbg"));
  106. //flightbg.css({width:skySize.acWidth,height:skySize.acHeight });
  107. //flightbg.addClass("bg");
  108. //flightbg.appendTo(".gaming .sky");
  109. $(".gaming .sky").css({width:skySize.acWidth,height:skySize.acHeight,backgroundImage:"url("+queue.getResult("flightbg").src+")"});
  110. loadingTxt.text("100%");
  111. startObj=start();
  112. gameObj=game();
  113. gameEndObj=gend();
  114. gameRandObj=grand();
  115. $(".start .loading").hide();
  116. if(gameType!=""||getQueryString("id")){//已选择游戏方式
  117. showStart();
  118. }
  119. _smq.push(['custom', '杜杜足球赛', '游戏页面', '加载完成', ,1]);
  120. }
  121. function handleProgress(a,b,c){
  122. loadingTxt.text((parseInt(a.currentTarget._numItemsLoaded/a.currentTarget._numItems*100,10).toFixed(0))+"%");
  123. }
  124. }
  125. function showStart(){
  126. if(getQueryString("id")){
  127. gameRandObj.show({id:getQueryString("id")});
  128. if(!document.all){
  129. history.pushState(null, null, url);
  130. }
  131. else{
  132. window.location.href="#12";
  133. }
  134. }else{
  135. startObj.startInit();
  136. }
  137. }
  138. });
  139. function start(){
  140. var football=$(".start .football");
  141. //足球光环动画
  142. var haloDom=$(".start .halo");
  143. var haloNum=1;
  144. var haloIsPlay=true;
  145. function haloPlay(){
  146. haloNum++;
  147. if(haloNum>4){
  148. haloNum=1;
  149. }
  150. setTimeout(function(){
  151. haloDom.attr("class","P_layer halo halo-"+haloNum);
  152. if(haloIsPlay){
  153. haloPlay();
  154. }
  155. },400);
  156. };
  157. //力度条
  158. /*var prosess=$(".start .prosess>div");
  159. var prosessSize=0;
  160. var prosessStep=1;
  161. var prosessIsPlay=true;
  162. function prosessPlay(){
  163. if(prosessSize==0){
  164. prosessStep=1;
  165. }else if(prosessSize==100){
  166. prosessStep=-1;
  167. }
  168. prosessSize+=prosessStep;
  169. setTimeout(function(){
  170. prosess.width(prosessSize+"%");
  171. if(prosessIsPlay){
  172. prosessPlay();
  173. }
  174. },10);
  175. }
  176. function getProsessSize(){
  177. return prosessSize;
  178. }*/
  179. //标题入场动画监听
  180. function startInit(){
  181. clickNumSize=0;
  182. clickNum=0;
  183. haloIsPlay=true;
  184. haloNum=1;
  185. haloPlay();
  186. clickNumStatus=false;
  187. /*prosessIsPlay=true;
  188. prosessSize=0;
  189. prosessStep=1;
  190. prosessPlay();*/
  191. speedupProsess.width(0);
  192. //活动标题入场动画
  193. $(".start .box .logo,.start .box .logo-amazon").show();
  194. $(".start .halo,.start .football,.start .tip,.start .hand").fadeIn(300);
  195. football.unbind(tapEvent).one(tapEvent,function(e){
  196. audioobj.play();
  197. autioIsPlay();
  198. //startReady();
  199. haloNum=0;
  200. haloDom.attr("class","P_layer halo");
  201. football.unbind(tapEvent);
  202. _smq.push(['custom', '杜杜足球赛', '游戏页面', '开始']);
  203. _gaq.push(['_trackEvent', '杜杜足球赛', '游戏页面', '开始']);
  204. });
  205. gameObj.gameInit();
  206. }
  207. var SHAKE_THRESHOLD = 600;
  208. var last_update = 0;
  209. var x, y, z, last_x, last_y, last_z;
  210. function deviceMotionHandler(eventData) {
  211. var acceleration =eventData.accelerationIncludingGravity;
  212. var curTime = new Date().getTime();
  213. if ((curTime - last_update)> 100) {
  214. var diffTime = curTime -last_update;
  215. last_update = curTime;
  216. x = acceleration.x;
  217. y = acceleration.y;
  218. z = acceleration.z;
  219. var speed = Math.abs(x +y + z - last_x - last_y - last_z) / diffTime * 10000;
  220. if (speed > SHAKE_THRESHOLD) {
  221. if(clickNum<clickNumCount){
  222. clickNum++;
  223. }
  224. haloNum++;
  225. if(haloNum>4){
  226. haloNum=1;
  227. }
  228. clickNumSize=clickNum/clickNumCount*100;
  229. speedupProsess.width(clickNumSize+"%");
  230. haloDom.attr("class","P_layer halo halo-"+haloNum);
  231. }
  232. last_x = x;
  233. last_y = y;
  234. last_z = z;
  235. }
  236. }
  237. function startReplay(){
  238. footballEventCount=0;
  239. //$(".start").css({transition:"none"}).removeClass("start-go");
  240. $(".start").show();
  241. //$(".start .halo,.start .tip,.start .hand").show();
  242. football.css({
  243. left:"50%",
  244. bottom:19,
  245. marginLeft:-91,
  246. width:183,
  247. height:186,
  248. transition:"none"
  249. });
  250. $(".start .speedup,.start .speedup .txt-s div").hide();
  251. $(".start .cbox .tip,.start .cbox .hand,.start .cbox .halo,.start .cbox .football").hide();
  252. $("#selecttype").show();
  253. //startInit();
  254. }
  255. //足球进门监听-游戏开始
  256. var footballEventCount=0;
  257. $(".start .football").get(0).addEventListener('webkitTransitionEnd', function (e) {
  258. footballEventCount++;
  259. if(footballEventCount==4){
  260. $(".start").hide();
  261. $(".start .football,.start .box .logo,.start .box .logo-amazon").hide();
  262. gameObj.gameStart(clickNumSize);
  263. }
  264. });
  265. function startPlay(){
  266. footballEventCount=0;
  267. var footballBottom=($(window).height()-$(".footballtarget").position().top*windowWidthScale)/windowWidthScale;
  268. football.css({
  269. bottom:footballBottom,
  270. marginLeft:0,
  271. width:0,
  272. height:0,
  273. transition:"all 1s"
  274. });
  275. }
  276. function startReady(){
  277. haloIsPlay=false;
  278. $(".start .hand,.start .tip").hide();
  279. $(".start .speedup").show();
  280. countdownNum=5;
  281. countdownToStart(0);
  282. //startPlay();
  283. }
  284. var countdownNum=5;
  285. function countdownToStart(a){
  286. if(a==0){
  287. a++;
  288. setTimeout(function(){
  289. $(".start .speedup .txt-s .ready").show();
  290. setTimeout(function(){
  291. countdownToStart(1);
  292. },1000);
  293. },500);
  294. }else if(a==1){
  295. $(".start .speedup .txt-s .ready").hide();
  296. $(".start .speedup .txt-s .go").show();
  297. setTimeout(function(){
  298. countdownToStart(2);
  299. },1000);
  300. }else if(a==2){
  301. $(".start .speedup .txt-s .go").hide();
  302. $(".start .speedup .txt-s .num").show();
  303. countdownToStart();
  304. if(gameType=="click"){
  305. football.unbind(tapEvent).bind(tapEvent,function(e){
  306. if(clickNum<clickNumCount){
  307. clickNum++;
  308. }
  309. haloNum++;
  310. if(haloNum>4){
  311. haloNum=1;
  312. }
  313. clickNumSize=clickNum/clickNumCount*100;
  314. speedupProsess.width(clickNumSize+"%");
  315. haloDom.attr("class","P_layer halo halo-"+haloNum);
  316. });
  317. }else{
  318. //摇一摇
  319. window.addEventListener('devicemotion',deviceMotionHandler, false);
  320. }
  321. }else{
  322. if(countdownNum<0){
  323. if(gameType=="click"){
  324. football.unbind(tapEvent);
  325. }else{
  326. //摇一摇
  327. window.removeEventListener('devicemotion',deviceMotionHandler, false);
  328. }
  329. $(".start .halo").hide();
  330. $(".start .speedup").fadeOut(500);
  331. startPlay();
  332. }else{
  333. $(".start .speedup .txt-s>.num").text(countdownNum);
  334. setTimeout(function(){
  335. countdownToStart();
  336. },1000);
  337. countdownNum--;
  338. }
  339. }
  340. }
  341. var clickNumSize=0;
  342. var clickNumCount=200;
  343. var clickNum=0;
  344. var clickNumStatus=false;
  345. var speedupProsess=$(".start .speedup .prosess1 .b span");
  346. var audioobj=$("audio").get(0);
  347. function autioIsPlay(){
  348. footballClickStatus=true;
  349. if(audioobj.currentTime>0){
  350. startReady();
  351. }else{
  352. setTimeout(function(){
  353. autioIsPlay();
  354. },50);
  355. }
  356. }
  357. var footballClickStatus=false;
  358. /*football.bind("touchstart",function(e){
  359. if(footballClickStatus){return false;}
  360. if(haloIsPlay){
  361. //createjs.Sound.play("sound");
  362. audioobj.play();
  363. autioIsPlay();
  364. //startReady();
  365. haloNum=0;
  366. haloDom.attr("class","P_layer halo");
  367. _smq.push(['custom', '杜杜足球赛', '游戏页面', '开始']);
  368. _gaq.push(['_trackEvent', '杜杜足球赛', '游戏页面', '开始']);
  369. }else if(clickNumStatus){
  370. clickNum++;
  371. haloNum++;
  372. if(haloNum>4){
  373. haloNum=1;
  374. }
  375. clickNumSize=clickNum/clickNumCount*100;
  376. speedupProsess.width(clickNumSize+"%");
  377. haloDom.attr("class","P_layer halo halo-"+haloNum);
  378. }
  379. });*/
  380. return {
  381. football:football,
  382. //getProsessSize:getProsessSize,
  383. startInit:startInit,
  384. startPlay:startPlay,
  385. startReplay:startReplay
  386. }
  387. }
  388. function game(){
  389. var sky=$(".gaming .sky");
  390. var highSize=0;//目标高度
  391. function gameInit(){
  392. sky.removeClass("sky-go-0").css({transform:"translate(0,-"+(skySize.acHeight-windowHeight)+"px)"});
  393. }
  394. function gameReplay(){
  395. $(".gaming").removeClass("gamingshow");
  396. $(".gaming .football .txt,.gaming .football .shock,.gaming .football .shock-1,.gaming .football .shock-2,.gaming .football .ball-1,.gaming .football .ball-2,.gaming .football .ball-3").hide();
  397. $(".gaming .superman").removeClass("supermanshow");
  398. $(".gaming .football").show().css({transform:"translate(0,"+windowHeight+"px)"});
  399. $(".gaming .football .ball").removeClass("ball-end");
  400. $(".gaming .footballflightnum").removeClass("footballflightnum-end");
  401. timing.text(0);
  402. highSize=0;
  403. timingNum=0;
  404. gameInit();
  405. }
  406. function gameStart(prosessSize){
  407. $(".gaming").addClass("gamingshow");
  408. //$(".gaming .pagelock").show();
  409. $(".gaming .football").show().css({transform:"translate(0,"+(windowHeight*0.3/windowWidthScale)+"px)"});
  410. $(".gaming .football .ball").show();
  411. //游戏开始转场监听
  412. //setTimeout(function(){
  413. //$(".gaming .pagelock .speedup").show();
  414. haloNum=1;
  415. haloIsPlay=true;
  416. //haloPlay();
  417. gameGo(prosessSize);
  418. //},1200);
  419. }
  420. //开始
  421. function gameGo(prosessSize){
  422. $(".gaming .pagelock,.gaming .pagelock .speedup").hide();
  423. $(".gaming .superman").addClass("supermanshow");
  424. var pscale=prosessSize/100;
  425. pscale=pscale>1?1:pscale;
  426. highSize=(29000*pscale+randomBetween1(0,999,true)).toFixed(0);
  427. highSize=randomBetween1(highSize*0.8,highSize,true);
  428. var high=skySize.acHeight/2-skySize.acHeight/2*pscale;
  429. //var flightTime=pscale*10+10;
  430. $(".gaming .footballflightnum,.gaming .football .shock").show();
  431. sky.addClass("sky-go-0");
  432. setTimeout(function(){
  433. sky.css({transform:"translate(0,-"+high+"px)"/*,"-webkit-transition-delay":flightTime+"s"*/});
  434. },50);
  435. timingStep=parseInt(highSize/9/20);
  436. timingIsPlay=true;
  437. timingPlay();
  438. /*$(".gaming .football .ball").hide();
  439. $(".gaming .football .ball-1").show();*/
  440. //冲击波
  441. setTimeout(function(){
  442. $(".gaming .football .shock").hide();
  443. $(".gaming .football .shock-1").show();
  444. /*$(".gaming .football .ball-1").hide();
  445. $(".gaming .football .ball-2").show();*/
  446. setTimeout(function(){
  447. $(".gaming .football .shock-1").hide();
  448. $(".gaming .football .shock-2").show();
  449. /*$(".gaming .football .ball-2").hide();
  450. $(".gaming .football .ball-3").show();*/
  451. },3000);
  452. },3000);
  453. }
  454. sky.get(0).addEventListener('webkitTransitionEnd', function () {
  455. //alert("fd");
  456. $(".gaming .football").css({transform:"scaleX(0.9) translate(0,"+(windowHeight*0.1/windowWidthScale)+"px)"});
  457. $(".gaming .football .ball").addClass("ball-end");
  458. $(".gaming .footballflightnum").addClass("footballflightnum-end");
  459. timingIsPlay=false;
  460. timing.text(highSize);
  461. //
  462. setTimeout(function(){
  463. gameEndObj.show(highSize);
  464. $(".gaming .footballflightnum").hide();
  465. $(".gaming .football,.gaming .football .ball").hide();
  466. dp_submitScore(highSize);
  467. },2500);
  468. });
  469. var timing=$(".gaming .footballflightnum .num");
  470. var timingIsPlay=false;
  471. var timingNum=0;
  472. var timingStep=0;
  473. function timingPlay(){
  474. setTimeout(function(){
  475. if(timingIsPlay){
  476. timing.text(timingNum);
  477. timingNum+=timingStep;
  478. timingPlay();
  479. }else{
  480. timing.text(highSize);
  481. }
  482. },50);
  483. }
  484. function randomBetween1(c, a, d) {
  485. d = d ? d: false;
  486. var b = c + (Math.random() * (a + 2 - c));
  487. b = Math.min(b, a);
  488. return d ? parseInt(b,10) : b
  489. };
  490. return {
  491. gameInit:gameInit,
  492. gameStart:gameStart,
  493. gameReplay:gameReplay
  494. }
  495. }
  496. function getCoupons(distance){
  497. }
  498. var coupons=null;
  499. function gend(){
  500. var gend=$(".gend");
  501. var football=$(".gend .football");
  502. var yuan=$(".gend .yuan");
  503. var xh=$(".gend .xh");
  504. var t1=$(".gend .t1");
  505. var t2=$(".gend .t2");
  506. var t3=$(".gend .t3");
  507. var b1=$(".gend .b1");
  508. var b2=$(".gend .b2");
  509. var b3=$(".gend .b3");
  510. var c1=$(".gend .c1");
  511. var c2=$(".gend .c2");
  512. yuan.get(0).addEventListener("webkitAnimationEnd",function(e){
  513. t1.show();
  514. xh.show();
  515. setTimeout(function(){
  516. t2.show();
  517. },200);
  518. setTimeout(function(){
  519. t3.show();
  520. },400);
  521. });
  522. function gendClose(){
  523. gend.hide();
  524. xh.hide();
  525. football.hide();
  526. t1.hide();
  527. t2.hide();
  528. t3.hide();
  529. }
  530. c1.bind(tapEvent,function(e){
  531. if(coupons){
  532. _smq.push(['custom', '杜杜足球赛', '电商', (gameType=="click"?'G点戳戳':'high抖抖')+'-游戏结束-优惠券'+coupons.level]);
  533. _gaq.push(['_trackEvent', '杜杜足球赛', '电商', (gameType=="click"?'G点戳戳':'high抖抖')+'-游戏结束-优惠券'+coupons.level]);
  534. window.location.href=coupons.url;
  535. }
  536. e.preventDefault();
  537. });
  538. b3.bind(tapEvent,function(e){
  539. startObj.startReplay();
  540. gameObj.gameReplay();
  541. gameEndObj.gendClose();
  542. _smq.push(['custom', '杜杜足球赛', '游戏页面', '再来一发']);
  543. _gaq.push(['_trackEvent', '杜杜足球赛', '游戏页面', '再来一发']);
  544. });
  545. var distanceKM=0;
  546. function show(distance){
  547. setTimeout(function(){
  548. football.fadeIn(300);
  549. },1000);
  550. distanceKM=distance;
  551. //getCoupons(distance);
  552. /*var level=(distance/2900).toFixed(0);
  553. if(level<=5){
  554. coupons=couponsData[0];
  555. $(".gend .c1 a").attr("class","co-1");
  556. }else{
  557. coupons=couponsData[level-5];
  558. $(".gend .c1 a").attr("class","co-"+(level-5));
  559. }*/
  560. t2.find("b").text(distance+"km");
  561. gend.show();
  562. }
  563. return {
  564. show:show,
  565. gendClose:gendClose
  566. }
  567. }
  568. function grand(){
  569. var rand=$(".rand");
  570. var rb1=$(".rand .b1");
  571. var rb2=$(".rand .b2");
  572. rb1.bind(tapEvent,function(e){
  573. startObj.startReplay();
  574. gameObj.gameReplay();
  575. rand.hide();
  576. _smq.push(['custom', '杜杜足球赛', '排行榜', '再来一发']);
  577. _gaq.push(['_trackEvent', '杜杜足球赛', '排行榜', '再来一发']);
  578. });
  579. function show(data){
  580. rand.show();
  581. showData(data);
  582. }
  583. function showData(data){
  584. }
  585. function hide(){
  586. rand.show();
  587. }
  588. return {
  589. show:show,
  590. hide:hide
  591. }
  592. }
  593. $(window).resize(windowInit);
  594. function windowInit(){
  595. windowWidth=$(window).width();
  596. windowHeight=$(window).height();
  597. if(windowWidth>windowHeight){
  598. $(".sceentip").show().css({lineHeight:windowHeight+"px"});
  599. //return;
  600. }else{
  601. $(".sceentip").hide();
  602. }
  603. windowWidthScale=windowWidth/640;
  604. windowHeightScale=windowHeight/960;
  605. skySize.acWidth=windowWidth;
  606. skySize.acHeight=skySize.height*windowWidthScale;
  607. $(".zoom").css("zoom",windowWidthScale);
  608. $(".zoomh").css("zoom",windowHeightScale);
  609. $(".weixinbox>img").css({marginLeft:windowHeight/2*-1});
  610. }
  611. var browser={
  612. versions:function(){
  613. var u = navigator.userAgent, app = navigator.appVersion;
  614. return {//移动终端浏览器版本信息
  615. trident: u.indexOf('Trident') > -1, //IE内核
  616. presto: u.indexOf('Presto') > -1, //opera内核
  617. webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
  618. gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
  619. mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否为移动终端
  620. ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
  621. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
  622. iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
  623. iPad: u.indexOf('iPad') > -1, //是否iPad
  624. webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
  625. };
  626. }(),
  627. language:(navigator.browserLanguage || navigator.language).toLowerCase()
  628. }
  629. function is_weixn(){
  630. var ua = navigator.userAgent.toLowerCase();
  631. if(ua.match(/MicroMessenger/i)=="micromessenger") {
  632. return true;
  633. } else {
  634. return false;
  635. }
  636. }
  637. function randomBetween(c, a, d) {
  638. d = d ? d: false;
  639. var b = c + (Math.random() * (a + 2 - c));
  640. b = Math.min(b, a);
  641. return d ? parseInt(b,10) : b
  642. };
  643. function getQueryString(name) {
  644. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  645. var r = window.location.search.substr(1).match(reg);
  646. if (r != null) return unescape(r[2]); return null;
  647. }
  648. function showMsg(txt){
  649. var html=$('<div class="noweixinopen"><div class="box"><h3>提示!</h3><p>'+txt+'</p><div class="btns"><a href="#" class="btn">我知道了</a></div></div></div>').appendTo("body");
  650. html.find(".box").css({top:(windowHeight-html.find(".box").outerHeight())/2}).find(".btns>.btn").click(function(e){
  651. html.remove();
  652. e.preventDefault();
  653. });
  654. }
  655. function isPC(){
  656. var userAgentInfo = navigator.userAgent;
  657. var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
  658. var flag = true;
  659. for (var v = 0; v < Agents.length; v++) {
  660. if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
  661. }
  662. return flag;
  663. }