index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. //广告弹出层
  2. //点击关闭
  3. $('.adpop').hover(function () {
  4. $(this).find('.closed').stop(true, true).fadeIn('normal');
  5. }, function () {
  6. $(this).find('.closed').stop(true, true).fadeOut('normal');
  7. });
  8. $('.adpop .closed').click(function () {
  9. $(this).parents('.adpop').hide();
  10. });
  11. $(document).ready(function () {
  12. setTimeout(function () {
  13. $('.adpop').fadeOut(1000);
  14. }, 5000);
  15. });
  16. // 鼠标滑过不消失
  17. $('.adpop').hover(function () {
  18. if ($(".adpop").css("opacity") == 1) {
  19. $('.adpop').stop(true, false).fadeOut(3000, 1);
  20. }
  21. }, function () {
  22. $('.adpop').stop(true, false).fadeOut(3000);
  23. });
  24. //今日不再显示
  25. function closeToday() {
  26. if ($('#box').is(':checked')) {
  27. //当前日期
  28. var curDate = new Date();
  29. //当前时间戳
  30. var curTamp = curDate.getTime();
  31. //当日凌晨的时间戳,减去一毫秒是为了防止后续得到的时间不会达到00:00:00的状态
  32. var curWeeHours = new Date(curDate.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g, '')).getTime() - 1;
  33. //当日已经过去的时间(毫秒)
  34. var passedTamp = curTamp - curWeeHours;
  35. //当日剩余时间
  36. var leftTamp = 24 * 60 * 60 * 1000 - passedTamp;
  37. var leftTime = new Date();
  38. leftTime.setTime(leftTamp + curTamp);
  39. // 设置cookie
  40. document.cookie = 'loginCount=1;expires=' + leftTime.toGMTString() + ';path=/';
  41. // $("#advert_laye").css("display", "none")
  42. }
  43. }
  44. $(document).ready(function () {
  45. var isClosed = /(^|;| )loginCount=1/.test(document.cookie); //判定cookie是否存在
  46. if (!isClosed) {
  47. $("#advert_laye").css("display", "block")
  48. } else {
  49. $("#advert_laye").css("display", "none")
  50. }
  51. });
  52. // 推荐移入效果
  53. $(".warp_advpic").on("mouseenter mouseleave", function (e) {
  54. var $bg = $(this).find('.adv_txt ');
  55. var w = this.offsetWidth; //获取元素宽度
  56. var h = this.offsetHeight; //获取元素高度
  57. var toTop = this.getBoundingClientRect().top + document.body.scrollTop; //兼容滚动条
  58. var x = e.pageX - this.getBoundingClientRect().left - w / 2; //获取当前鼠标的x轴位置(相对于这个li的中心点)
  59. var y = e.pageY - toTop - h / 2; ////获取当前鼠标的y轴位置(相对于这个li的中心点)
  60. var direction = Math.round((((Math.atan2(y, x) * 180 / Math.PI) + 180) / 90) + 3) % 4; //direction的值为“0,1,2,3”分别对应着“上,右,下,左”
  61. var eventType = e.type;
  62. var res = Math.atan2(y, x) / (Math.PI / 180) + 180;
  63. var dirName = new Array('上方', '右侧', '下方', '左侧');
  64. if (eventType == 'mouseenter') {
  65. // $('.advhide').text(dirName[direction] + '进入');
  66. animationIn(direction, $bg);
  67. } else {
  68. // $('.advhide').text(dirName[direction] + '离开');
  69. animationOut(direction, $bg);
  70. }
  71. });
  72. function animationIn(direction, ele) {
  73. switch (direction) {
  74. case 0:
  75. ele.css({
  76. left: 0,
  77. top: '-201%'
  78. }).stop(true, false).animate({
  79. top: 0
  80. }, 300);
  81. break;
  82. case 1:
  83. ele.css({
  84. left: '100%',
  85. top: 0
  86. }).stop(true, false).animate({
  87. left: 0
  88. }, 300);
  89. break;
  90. case 2:
  91. ele.css({
  92. left: 0,
  93. top: '201%'
  94. }).stop(true, false).animate({
  95. top: 0
  96. }, 300);
  97. break;
  98. case 3:
  99. ele.css({
  100. left: '-201%',
  101. top: 0
  102. }).stop(true, false).animate({
  103. left: 0
  104. }, 300);
  105. break;
  106. }
  107. }
  108. function animationOut(direction, ele) {
  109. switch (direction) {
  110. case 0:
  111. ele.stop(true, false).animate({
  112. top: '-201%'
  113. }, 300);
  114. break;
  115. case 1:
  116. ele.stop(true, false).animate({
  117. left: '201%'
  118. }, 300);
  119. break;
  120. case 2:
  121. ele.stop(true, false).animate({
  122. top: '201%'
  123. }, 300);
  124. break;
  125. case 3:
  126. ele.stop(true, false).animate({
  127. left: '-201%'
  128. }, 300);
  129. break;
  130. }
  131. }
  132. // 图标平移
  133. $(function () {
  134. $('.appraisal>h4>div').hover(function () {
  135. $('.appraisal>h4>div>img').stop(true, false).animate({
  136. 'right': '35px'
  137. })
  138. $('.appraisal>h4>div span').stop(true, false).animate({
  139. 'right': '0px'
  140. })
  141. }, function () {
  142. $('.appraisal>h4>div>img').stop(true, false).animate({
  143. 'right': '0px'
  144. })
  145. $('.appraisal>h4>div span').stop(true, false).animate({
  146. 'right': '-35px'
  147. })
  148. });
  149. $('.strategy>h4>div').hover(function () {
  150. $('.strategy>h4>div>img').stop(true, false).animate({
  151. 'right': '35px'
  152. })
  153. $('.strategy>h4>div span').stop(true, false).animate({
  154. 'right': '0px'
  155. })
  156. }, function () {
  157. $('.strategy>h4>div>img').stop(true, false).animate({
  158. 'right': '0px'
  159. })
  160. $('.strategy>h4>div span').stop(true, false).animate({
  161. 'right': '-35px'
  162. })
  163. });
  164. $('.rank>h4>div').hover(function () {
  165. $('.rank>h4>div>img').stop(true, false).animate({
  166. 'right': '35px'
  167. })
  168. $('.rank>h4>div span').stop(true, false).animate({
  169. 'right': '0px'
  170. })
  171. }, function () {
  172. $('.rank>h4>div>img').stop(true, false).animate({
  173. 'right': '0px'
  174. })
  175. $('.rank>h4>div span').stop(true, false).animate({
  176. 'right': '-35px'
  177. })
  178. });
  179. $('.classify>h4>div').hover(function () {
  180. $('.classify>h4>div>img').stop(true, false).animate({
  181. 'right': '35px'
  182. })
  183. $('.classify>h4>div span').stop(true, false).animate({
  184. 'right': '0px'
  185. })
  186. }, function () {
  187. $('.classify>h4>div>img').stop(true, false).animate({
  188. 'right': '0px'
  189. })
  190. $('.classify>h4>div span').stop(true, false).animate({
  191. 'right': '-35px'
  192. })
  193. });
  194. })
  195. // 开服开测
  196. $(function () {
  197. var $open_service_tab = $(".open_service_title span");
  198. var $open_service_contain = $('.content_list');
  199. var index = 0;
  200. $open_service_tab.hover(function () {
  201. $($open_service_tab[index]).removeClass('active');
  202. $($open_service_contain[index]).removeClass('show');
  203. index = $(this).index();
  204. $(this).addClass('active');
  205. $($open_service_contain[index]).addClass('show');
  206. });
  207. });
  208. // 游戏分类
  209. sth2('.classify_title>p', '.classify_content>ul');//礼包发号
  210. function sth2(hvObj, obj) {
  211. $(hvObj).hover(function () {
  212. var ind = $(this).index();
  213. $(this).addClass('active').siblings().removeClass('active');
  214. if ('/static/images/icon/150-150.png' == $(obj).eq(ind).find('img:first').attr('src')) {
  215. $this = $(obj).eq(ind).find('img').each(function () {
  216. $(this).attr('src', $(this).attr('lazy-src'));
  217. });
  218. }
  219. $(obj).eq(ind).show().siblings().hide();
  220. });
  221. }
  222. // 手游排行控件显示隐藏
  223. $(function () {
  224. $('.rank_list>div').eq(0).find('.big').show()
  225. $('.rank_list>div').eq(0).find('.small').hide()
  226. $('.rank_list').hover(function () {
  227. $('.rank_list>div').hover(function () {
  228. $(this).find('.big').show().parent().siblings().find('.big').hide();
  229. $(this).find('.small').hide().parent().siblings().find('.small').show();
  230. });
  231. });
  232. })
  233. // 最下方两张图片
  234. $(function () {
  235. $('.tail_pic_one').hover(function () {
  236. $('.tail_pic_one a div').stop(true, false).animate({
  237. bottom: 0
  238. })
  239. }, function () {
  240. $('.tail_pic_one a div').stop(true, false).animate({
  241. bottom: '-28px'
  242. })
  243. });
  244. $('.tail_pic_two').hover(function () {
  245. $('.tail_pic_two a div').stop(true, false).animate({
  246. bottom: 0
  247. })
  248. }, function () {
  249. $('.tail_pic_two a div').stop(true, false).animate({
  250. bottom: '-28px'
  251. })
  252. })
  253. })
  254. // input placeholder ie兼容
  255. if (!('placeholder' in document.createElement('input'))) {
  256. $('input[placeholder],textarea[placeholder]').each(function () {
  257. var that = $(this),
  258. text = that.attr('placeholder');
  259. // console.log(text);
  260. if (that.val() === "") {
  261. that.val(text).addClass('placeholder');
  262. that.css("color", "#757575")
  263. }
  264. that.focus(function () {
  265. if (that.val() === text) {
  266. that.val("").removeClass('placeholder');
  267. }
  268. }).blur(function () {
  269. if (that.val() === "") {
  270. that.val(text).addClass('placeholder');
  271. that.css("color", "#757575")
  272. }
  273. })
  274. });
  275. }
  276. // 轮番图
  277. layui.use('carousel', function () {
  278. var carousel = layui.carousel;
  279. //建造实例
  280. carousel.render({
  281. elem: '#test1'
  282. , width: '100%'
  283. , height: '486px'
  284. , arrow: 'hover'
  285. , interval: "5000"
  286. , trigger: 'hover'
  287. });
  288. });
  289. // url生成二维码
  290. var qrcode = new QRCode(document.getElementById("qrcode"), {
  291. width: 100,
  292. height: 100,
  293. correctLevel: 0
  294. });
  295. $(".download").click(function () {
  296. var p_text = $(this).find("#text-1").text();
  297. var p_title = $(this).find("#text-2").text();
  298. var p_page = $(this).find("#download-page").text();
  299. qrcode.makeCode(p_page);
  300. $('.az_hover a').attr('href', p_text);
  301. $('.download_popup p').html(p_title);
  302. });
  303. $(function () {
  304. //加载 开服开测模板
  305. $("#J_serverinfo").load('/Layout/serverinfo');
  306. $("#J_rank_list").load('/Layout/gameRankList');
  307. $("#J_recommend_gift").load('/Layout/recommendGiftList');
  308. });
  309. // 头条新闻