| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- // 头部侧边菜单栏
- $(".menu").click(function() {
- if ($(".warp-sidebar").css("display") == 'none') {
- var scrollTop = $(window).scrollTop();
- $(".menu img").attr("src", "/static/images/mobile/icon/close.png")
- $(".warp-sidebar").css("display", "block");
- $("body").css("overflow","hidden");
- $("body").css("position","fixed");
- document.body.style.top=-1*scrollTop+"px";
- $('.sidebar').stop(true, false).animate({
- 'right': '0rem'
- }, 300)
- // $("body").on('touchmove',function (e){
- // e.preventDefault();
- // });
-
- } else {
- var top = $('body').offset().top;
- top = -top
- $(".menu img").attr("src", "/static/images/mobile/icon/menu-bar.png");
- setTimeout(function(){
- $(".warp-sidebar").css("display", "none");
- $("body").css("overflow","scroll");
- $("body").css("position","relative");
- $("body").css("top","0px");
- window.scrollTo(0,top);
- },300)
- $('.sidebar').stop(true, false).animate({
- 'right': '-2.56rem'
- }, 300)
- }
- })
- // 头部侧边菜单栏2
- $(".menu-1").click(function() {
- if ($(".warp-sidebar").css("display") == 'none') {
- var scrollTop = $(window).scrollTop();
- $(".menu-1 img").attr("src", "/static/images/mobile/icon/close-white.png")
- $(".warp-sidebar").css("display", "block");
- $("body").css("overflow","hidden");
- $("body").css("position","fixed");
- document.body.style.top=-1*scrollTop+"px";
- $('.sidebar').stop(true, false).animate({
- 'right': '0rem'
- }, 300)
- } else {
- var top = $('body').offset().top;
- top = -top
- $(".menu-1 img").attr("src", "/static/images/mobile/icon/menu-bar-1.png");
- setTimeout(function(){
- $(".warp-sidebar").css("display", "none");
- $("body").css("overflow","scroll");
- $("body").css("position","relative");
- $("body").css("top","0px");
- window.scrollTo(0,top);
- },300)
- $('.sidebar').stop(true, false).animate({
- 'right': '-2.56rem'
- }, 300)
- }
- })
- // 菜单栏其他区域
- $(".warp-sidebar").click(function(e) {
- var target = $(e.target);
- if (target.closest(".sidebar").length != 0) return;
- var top = $('body').offset().top;
- top = -top
- $(".menu img").attr("src", "/static/images/mobile/icon/menu-bar.png")
- $(".menu-1 img").attr("src", "/static/images/mobile/icon/menu-bar-1.png")
- setTimeout(function(){
- $(".warp-sidebar").css("display", "none");
- $("body").css("overflow","scroll");
- $("body").css("position","relative");
- $("body").css("top","0px");
- window.scrollTo(0,top);
- },300)
- $(".warp-sidebar").animate({
- backgroundColor:'#FF0000'
- }, 1000)
- $('.sidebar').stop(true, false).animate({
- 'right': '-2.56rem'
- }, 300)
- })
- // 返回顶部
- $(function () {
- //检测屏幕高度
- var height = $(window).height();
- height = 3 / 4 * height;
- //scroll() 方法为滚动事件
- $(window).scroll(function () {
- if ($(window).scrollTop() > height) {
- $(".return-top").fadeIn(500);
- } else {
- $(".return-top").fadeOut(500);
- }
- });
- });
- $(".return-top").click(function () {
- $("html,body").animate({ scrollTop: '0px' }, 1000);
- });
- // 下载弹窗 设备判断
- var ModalHelper = (function (bodyCls) {
- var scrollTop;
- return {
- afterOpen: function () {
- scrollTop = document.scrollingElement.scrollTop;
- document.body.classList.add(bodyCls);
- document.body.style.top = -scrollTop + 'px';
- },
- beforeClose: function () {
- document.body.classList.remove(bodyCls);
- // scrollTop lost after set position:fixed, restore it back.
- document.scrollingElement.scrollTop = scrollTop;
- }
- };
- })('modal-open');
- //显示遮罩层
- function showMask() {
- document.getElementById("Mask-weChat").style.display = "block";
- ModalHelper.afterOpen();
- }
-
- //隐藏遮罩层
- function hideMask() {
- document.getElementById("Mask-weChat").style.display = 'none';
- ModalHelper.beforeClose();
- }
-
-
- //ios端显示遮罩层
- function showMask2() {
- document.getElementById("Mask-IOS").style.display = "block";
- document.getElementsByClassName("iosTip-container")[0].style.display = "block";
- ModalHelper.afterOpen();
- }
-
- //ios端隐藏遮罩层
- function hideMask2() {
- document.getElementById("Mask-IOS").style.display = 'none';
- document.getElementsByClassName("iosTip-container")[0].style.display = 'none';
- ModalHelper.beforeClose();
- }
-
- //判断设备是否使用微信浏览器打开的
- function is_weixn() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.match(/MicroMessenger/i) == "micromessenger") {
- return true;
- } else {
- return false;
- }
- }
-
- //判断是安卓还是iOS
- function which_device() {
- var u = navigator.userAgent;
- var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
- if (isAndroid) {
- return 'Android'
- }
- if (isiOS) {
- return 'iOS'
- }
- }
-
-
- $(".download").on("click", function () {
- //安卓游戏下载地址
- var android_down_url = $(this).find(".android_down_url").html();
-
- //IOS游戏下载地址
- var ios_down_url = $(this).find(".ios_down_url").html();
- //如果是微信浏览器则提示在浏览器上打开
- if (is_weixn() == true) {
- showMask();
- } else {
-
- if (which_device() == "Android") { //如果设备是安卓则直接下载
- if (android_down_url.length !== 0 && android_down_url !== "undefined") {
- $(this).find("a").attr("href", android_down_url);
- } else {
- $.alert("该游戏暂无安卓版本下载<br>请稍后再试", "提示");
- }
- } else if (which_device() == "iOS") { //如果设备是iOS
- //弹出提示遮罩层
- showMask2();
- if (ios_down_url.length !== 0 && ios_down_url !== "undefined") {
- $("#iosdlBtn").attr("href", 'itms-services://?action=download-manifest&url=' + ios_down_url);
- } else{
- $("#iosdlBtn").attr("href", 'javascript:;');
- }
- //在遮罩层的其他地方触点就会隐藏遮罩层
- document.getElementById("Mask-IOS").onclick = function () {
- hideMask2();
- }
-
- //点击遮罩层上的【知道了,立即下载】按钮隐藏提示框并且下载
- document.getElementById("iosdlBtn").onclick = function () {
- document.getElementById('setProcess-wrap').scrollTop = 0;
-
- if (ios_down_url.length !== 0 && ios_down_url !== "undefined") {
- // $("#iosdlBtn").attr("href", 'itms-services://?action=download-manifest&url=' + ios_down_url);
- } else {
- $.alert("该游戏暂无IOS版本下载<br>请稍后再试", "提示");
- }
- hideMask2();
- }
- } else {
- //除了这两种设备外的,如PC端,还是直接下载安卓的
- if (android_down_url.length !== 0 && android_down_url !== "undefined") {
- console.log(android_down_url);
- $(this).find("a").attr("href", android_down_url);
- } else {
- $.alert("该游戏暂无安卓版本下载请稍后再试", "提示");
-
- }
- }
-
- }
-
- })
-
- //判断是PC还是移动设备 true是PC,false是移动设备
- function IsPC() {
- var userAgentInfo = navigator.userAgent;
- var Agents = ["Android", "iPhone",
- "SymbianOS", "Windows Phone",
- "iPad", "iPod"
- ];
- var flag = true;
- for (var v = 0; v < Agents.length; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
- flag = false;
- break;
- }
- }
- return flag;
- }
- if (!IsPC()) {
- $(".pc").hide();
- }
- //延迟加载图片
- $(function () {
- var visible;
- $('img').each(function () {
- visible = $(this).offset().top - $(window).scrollTop();
- if ((visible > 0) && (visible < $(window).height())) {
- visible = true;
- } else {
- visible = false;
- }
- if (visible) {
- $(this).attr('src', $(this).attr('lazy-src'));
- }
- });
- $(window).scroll(function () {
- $('img').each(function () {
- if ('/static/images/icon/990-625.png' == $(this).attr('src') || '/static/images/icon/150-150.png' == $(this).attr('src') || '/static/images/icon/625-990.png' == $(this).attr('src') || '/static/images/icon/1200-200.png' == $(this).attr('src') || '/static/images/icon/1200-625.png' == $(this).attr('src')) {
- visible = $(this).offset().top - $(window).scrollTop();
- if ((visible > 0) && (visible < $(window).height())) {
- visible = true;
- } else {
- visible = false;
- }
- if (visible) {
- $(this).attr('src', $(this).attr('lazy-src'));
- }
- }
- });
- });
- });
- // 设置默认游戏icon
- $(".smallIcon").error(function () {
- $(this).attr("src", "/static/images/aoyou_game.png");
- })
- $(".new-img").error(function () {
- $(this).attr("src", "/static/images/icon/990_625.png");
- })
- // 进度条
- $(".gift_surplus").each(function () {
- var b = $(this).width();
- var a = $(this).parent(".warp_gift_surplus").width();
- if (a == b) {
- $(this).css("border-radius", "8px")
- }
- })
- if ($(".no_content").length > 0) {
- var head = $("header").height();
- var foot = $('footer').height();
- $(".no_content").height(aHigh-head-foot)
- }
-
-
- // 底部位置
- var iHigh = document.body.clientHeight;
- // var aHigh = window.screen.height;
- var aHigh = $(window).height()
- var head = $("header").height();
- // var h = $("footer").height();
- if (aHigh > (iHigh + head)) {
- $(".footer").addClass("fixed");
- }
-
- var winHeight = $(window).height(); //获取当前页面高度
- $(window).resize(function () {
- var thisHeight = $(this).height();
- if ( winHeight - thisHeight > 140 ) {
- //键盘弹出
- $('.footer').hide();
- } else {
- //键盘收起
- $('.footer').show();
- var iHigh = document.body.clientHeight;
- // var aHigh = window.screen.height;
- var aHigh = $(window).height()
- var head = $("header").height();
- if (aHigh > (iHigh + head)) {
- $(".footer").addClass("fixed");
- }
- }
- })
|