main_v006.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. //封面动画
  2. $('.cover').click(function(){
  3. $(this).hide();
  4. //$(this).find('.shouzhi').hide();
  5. //$(this).find('.tiger').addClass('in');
  6. })
  7. /*
  8. *选择通道
  9. *1:石油
  10. *2:四川
  11. *3:政法
  12. *4:家族
  13. */
  14. var turn_speed = 0.6; //扑克翻转速度
  15. var selectedTd = 0, //默认通道:未选择
  16. gameNum = 0, //步数
  17. big = false; //是否摸到大老虎
  18. function selectTd(){
  19. var td = $('.td');
  20. td.each(function(index){
  21. $(this).click(function(){
  22. if(selectedTd > 0){
  23. return;
  24. }else{
  25. selectedTd = $(this).attr('tdId');
  26. }
  27. $('.select_td').hide();
  28. })
  29. })
  30. }
  31. selectTd();
  32. //打老虎
  33. function hateTiger(){
  34. var item = $('.item');
  35. item.each(function(index){
  36. //选择正确
  37. function selectRight(_this){
  38. $(_this).parent().parent().find('.hd h2').html("赞!摸对了");
  39. TweenLite.to($(_this), turn_speed, {
  40. rotationY: 90,
  41. ease: Cubic.easeOut,
  42. onComplete: function() {
  43. $(_this).addClass('right');
  44. TweenLite.to($(_this), turn_speed, {
  45. rotationY: 0,
  46. ease: Cubic.easeOut
  47. });
  48. }
  49. });
  50. $(_this).parent().next('.ft').show();
  51. $(_this).siblings().each(function (i, elm) {
  52. setTimeout(function () {
  53. TweenLite.to($(elm), turn_speed, {
  54. opacity: 0,
  55. ease: Cubic.easeOut
  56. });
  57. }, 100 * i);
  58. });
  59. }
  60. $(this).click(function(){
  61. var self = this;
  62. if($(this).hasClass('right') || $(this).hasClass('caidan')){
  63. return;
  64. }
  65. gameNum++;
  66. $('.layout .hd strong').html(gameNum); //设置步数
  67. if($(this).attr('tdId') == selectedTd){
  68. selectRight(this);
  69. }else if($(this).attr('tdId') == 6){//彩蛋
  70. item.css({'z-index':1 });
  71. TweenLite.to($(self), turn_speed, {
  72. 'z-index': 100,
  73. rotationY: 90,
  74. ease: Cubic.easeOut,
  75. onComplete: function() {
  76. $(self).addClass('caidan');
  77. TweenLite.to($(self), turn_speed, {
  78. rotationY: 0,
  79. ease: Cubic.easeOut
  80. });
  81. }
  82. });
  83. }else if(selectedTd == 4 && $(this).attr('tdId') == 100){//周滨直达大老虎
  84. big = true;
  85. TweenLite.to($(self), turn_speed, {
  86. 'z-index': 100,
  87. rotationY: 90,
  88. ease: Cubic.easeOut,
  89. onComplete: function() {
  90. $(self).addClass('caidan');
  91. TweenLite.to($(self), turn_speed, {
  92. rotationY: 0,
  93. ease: Cubic.easeOut,
  94. onComplete: function () {
  95. setTimeout(function () {
  96. $('#layout_5 .hd strong').html(gameNum);
  97. $(".global").css({ "-webkit-transform": "translate3d(0px, -" + $(window).height() * 4 +"px, 0px)" });
  98. }, 2000);
  99. }
  100. });
  101. }
  102. });
  103. }else if(selectedTd == 1 && $(this).attr('tdId') == 7){//郭永祥兼属于石油系和四川系
  104. selectRight(this);
  105. }else if(selectedTd == 2 && $(this).attr('tdId') == 7){//郭永祥兼属于石油系和四川系
  106. $(this).find('.item_inner').addClass('item_sichuan');
  107. selectRight(this);
  108. }else{
  109. $(this).addClass('wrong');
  110. }
  111. })
  112. })
  113. $('.btn_close').click(function(){
  114. $('.caidan').addClass('wrong');
  115. $('.item').removeClass('caidan').css({'z-index':1 });
  116. event.stopPropagation();
  117. })
  118. }
  119. hateTiger()
  120. //摸大老虎屁股
  121. $('.dawang_box').click(function(){
  122. big = true;
  123. var self = this;
  124. if(gameNum<5){
  125. $('#layout_5 .hd').html('<div class="level level1">你是超级打虎英雄</div>');
  126. }else if(gameNum>4 && gameNum<11){
  127. $('#layout_5 .hd').html('<div class="level level2">你是打虎英雄</div>');
  128. }else if(gameNum>10 && gameNum<16){
  129. $('#layout_5 .hd').html('<div class="level level3">你是打虎能手</div>');
  130. }else{
  131. $('#layout_5 .hd').html('<div class="level level4">你只是打苍蝇高手</div>');
  132. }
  133. //设置翻大老虎牌动画,请往下添加
  134. TweenLite.to($(self), turn_speed, {
  135. 'z-index': 100,
  136. rotationY: 90,
  137. ease: Cubic.easeOut,
  138. onComplete: function() {
  139. $(self).addClass('clicked');
  140. TweenLite.to($(self), turn_speed, {
  141. rotationY: 0,
  142. ease: Cubic.easeOut
  143. });
  144. }
  145. });
  146. })
  147. //分享
  148. $('.shareBtn').click(function(){
  149. share();
  150. })
  151. //再玩一次
  152. $('#again').click(function(){
  153. var url = document.location.href;
  154. document.location.href = url;
  155. })
  156. function judgeStage(){
  157. var stage = 'other';
  158. if( typeof( TencentNews )!='undefined' ){
  159. if( typeof( TencentNews.showLoginWithType )!='undefined' ){
  160. stage = 'android';
  161. }else if( typeof(TencentNews.showNativeLogin)!='undefined' ){
  162. stage = 'ios';
  163. }
  164. }else if( navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger" ){
  165. stage = 'weixin';
  166. }
  167. return stage;
  168. }
  169. function showWeixinLayer(){
  170. $('#wixintip').css({display:'block'});
  171. $('#wixintip').click(function(){
  172. $('#wixintip').css({display:'none'});
  173. })
  174. }
  175. function share(){
  176. document.title = '我用了'+ gameNum +'步,摸到了大老虎的屁股,你也来摸摸!_小游戏网';
  177. var stage = judgeStage();
  178. var _title= document.title;
  179. var _des = "选择一种花色的老虎,谁先摸到大老虎,谁最厉害。";
  180. var _pic = "http://game.bkeke.com/lhpg/icon.jpg";
  181. var _url = document.location.href;
  182. if( stage == 'android' || stage == 'ios' ){
  183. if(window.TencentNews && window.TencentNews.showShareMenu){
  184. window.TencentNews.showShareMenu(_url,_title,_des,_pic,"news_news_wc");
  185. }else{
  186. window.TencentNews.shareFromWebView(_title, _des, _pic);
  187. }
  188. }else if( stage == 'weixin' ){
  189. showWeixinLayer();
  190. }else{
  191. window.location = "http://game.bkeke.com/index.html?c=share&a=index&url=_url&title=" + _title + "&pic=" + _pic + "&line1=";
  192. }
  193. }
  194. var onBridgeReady = function() {
  195. // 分享到朋友圈;
  196. WeixinJSBridge.on('menu:share:timeline', function(argv) {
  197. var wxTitle = "",
  198. wxDesc = '选择一种花色的老虎,谁先摸到大老虎,谁最厉害。',
  199. _imgurl = 'http://game.bkeke.com/lhpg/icon.jpg',
  200. linkUrl = document.location.href;
  201. if (big && gameNum >= 3) {
  202. wxTitle = '我用了'+ gameNum +'步,摸到了大老虎的屁股,你也来摸摸!_小游戏网';
  203. } else {
  204. wxTitle = document.title;
  205. }
  206. WeixinJSBridge.invoke('shareTimeline', {
  207. "img_url": _imgurl,
  208. "img_width": "120",
  209. "img_height": "120",
  210. "link": linkUrl,
  211. "desc": wxDesc,
  212. "title": wxTitle
  213. }, function() {});
  214. })
  215. WeixinJSBridge.on('menu:share:appmessage', function(argv) {
  216. var wxTitle = "",
  217. wxDesc = '选择一种花色的老虎,谁先摸到大老虎,谁最厉害。',
  218. _imgurl = 'http://game.bkeke.com/lhpg/icon.jpg',
  219. linkUrl = document.location.href;
  220. if (big && gameNum >= 3) {
  221. wxTitle = '我用了'+ gameNum +'步,摸到了大老虎的屁股,你也来摸摸!_小游戏网';
  222. } else {
  223. wxTitle = document.title;
  224. }
  225. WeixinJSBridge.invoke('sendAppMessage', {
  226. "img_url": _imgurl,
  227. "link": linkUrl,
  228. "desc": wxDesc,
  229. "title": wxTitle
  230. }, function() {})
  231. })
  232. WeixinJSBridge.on('menu:share:weibo', function(argv) {
  233. var wxTitle = "",
  234. wxDesc = '选择一种花色的老虎,谁先摸到大老虎,谁最厉害。',
  235. _imgurl = 'http://game.bkeke.com/lhpg/icon.jpg',
  236. linkUrl = document.location.href;
  237. if (big && gameNum >= 3) {
  238. wxTitle = '我用了'+ gameNum +'步,摸到了大老虎的屁股,你也来摸摸!_小游戏网';
  239. } else {
  240. wxTitle = document.title;
  241. }
  242. WeixinJSBridge.invoke('shareWeibo', {
  243. "desc": wxDesc,
  244. "url": linkUrl,
  245. }, function(res) {});
  246. })
  247. }
  248. $(function(){
  249. if (document.addEventListener) {
  250. document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  251. } else if (document.attachEvent) {
  252. document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  253. document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  254. }
  255. })
  256. /* ua */
  257. var UA = function(){
  258. var userAgent = navigator.userAgent.toLowerCase();
  259. return {
  260. ipad: /ipad/.test(userAgent),
  261. iphone: /iphone/.test(userAgent),
  262. android: /android/.test(userAgent),
  263. qqnews: /qqnews/.test(userAgent),
  264. weixin: /micromessenger/.test(userAgent)
  265. };
  266. }
  267. /* page翻页*/
  268. var Layout = {
  269. page: function (i, _h){
  270. $(".global").css({ "-webkit-transform": "translate3d(0px, -" + _h * i +"px, 0px)" });
  271. $(".layout").removeClass("animate");
  272. $("#layout_" + (i + 1)).addClass("animate");
  273. },
  274. swipe: function(_h, _len){
  275. var _this = this;
  276. $(".layout").each(function(index1, obj){
  277. $(obj).find('.ft').on("swipeUp", function(){
  278. index1 = index1 < (_len - 1) ? index1 : -1;
  279. _this.page(index1 + 1, _h);
  280. })
  281. });
  282. },
  283. init: function(){
  284. var _this = this,
  285. _w = $(window).width(),
  286. _h = $(window).height(),
  287. _len = $(".layout").length;
  288. var ua = UA();
  289. //console.log(ua);
  290. if(ua.iphone && ua.qqnews){
  291. _h = _h - 44;
  292. }
  293. $(".swipe_tip").addClass("fadeOutUp");
  294. $(".global").width( _w ).height( _h * _len ).addClass("ease");
  295. $(".screen").width( _w ).height( _h * _len );
  296. $(".layout").width( _w ).height( _h );
  297. //$(".iscrll").height( _h - 140);
  298. _this.page(0, _h);
  299. _this.swipe(_h, _len);
  300. }
  301. }
  302. Layout.init();/* |xGv00|531c7b8e2059bc8b04fc838c3b70dd25 */