| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604 |
- //菜单栏移入效果
- $(function () {
- $(".public_nav>ul>li").hover(function () {
- if ($(this).hasClass("current_page")) {
- } else {
- $(this).find('span').stop(true, true).animate({ width: "100%" }, 200);
- }
- }, function () {
- if ($(this).hasClass("current_page")) {
- } else {
- $(this).find('span').stop(true, true).animate({ width: "0px" }, 200);
- }
- });
- })
- // 头部登录状态下 个人中心弹窗
- $(".user_popup").hover(function () {
- $(".land_popup").show();
- }, function () {
- $(".land_popup").hide();
- });
- // 去掉ie浏览器 回车键 默认效果
- document.onkeydown = function (e) {
- var e = e || event;
- if (e.keyCode == 13) {
- e.preventDefault ? e.preventDefault() : (e.returnValue = false);
- }
- }
- //回到顶部
- $(function () {
- //检测屏幕高度
- var height = $(window).height();
- height = 3 / 4 * height;
- //scroll() 方法为滚动事件
- $(window).scroll(function () {
- if ($(window).scrollTop() > height) {
- $(".hide_top").fadeIn(500);
- } else {
- $(".hide_top").fadeOut(500);
- }
- });
- });
- $(".warp_ctlist .totop").click(function () {
- $("html,body").animate({ scrollTop: '0px' }, 500);
- });
- // 底部弹窗
- $(".ad_bottom .close").click(function () {
- $(".ad_bottom").hide();
- $(".footer ul").css("cssText", " padding: 35px 0 !important; ");
- });
- // setTimeout(function () {
- // if ($(".ad_bottom img").length > 0) {
- // if ($(".ad_bottom").css("display") == 'none') {
- // $(".footer ul").css("cssText", " padding: 35px 0 !important;");
- // } else {
- // $(".footer ul").css("cssText", " padding: 35px 0 153px 0 !important;");
- // }
- // } else {
- // $(".footer ul").css("cssText", " padding: 35px 0 !important;");
- // }
- // }, 1000);
- // 下载弹窗
- $(".az_code img").hover(function () {
- $(".download_popup .big_az_code").css("cssText", "display: block !important");
- }, function () {
- $(".download_popup .big_az_code").css("cssText", "display: none !important");
- });
- $(".download_popup .close").click(function () {
- $(".warp_download_popup").hide();
- });
- $(".download").click(function () {
- $(".warp_download_popup").show();
- });
- $(".tip .close,.determine,.cancel").click(function () {
- $(".warp_no_download_popup").hide();
- $(".warp_kf_popup").hide();
- });
- $(".no_download").click(function () {
- $(".warp_no_download_popup").show();
- });
- // 下载弹窗
- $(".small-code").hover(function () {
- $(this).next().show();
- // $(".az_code_right .big_az_code").show();
- }, function () {
- $(this).next().hide();
- // $(".az_code_right .big_az_code").hide();
- });
- $(".rollBox").hover(function () {
- $(".manu_phone_left").show();
- $(".manu_phone_right").show();
- }, function () {
- $(".manu_phone_left").hide();
- $(".manu_phone_right").hide();
- });
- $(".az_hover").hover(function () {
- $(".az_hover img").attr("src", "/static/images/home/az-white.png");
- $(".az_hover span").css("cssText", "color:#fff !important");
- }, function () {
- $(".az_hover img").attr("src", "/static/images/home/SVG-07.png");
- $(".az_hover span").css("cssText", "color: #8cc63d !important");
- });
- // 手游排行控件显示隐藏
- $(function () {
- $('.rank_list>div').eq(0).find('.big').show()
- $('.rank_list>div').eq(0).find('.small').hide()
- $('.rank_list').hover(function () {
- $('.rank_list>div').hover(function () {
- $(this).find('.big').show().parent().siblings().find('.big').hide();
- $(this).find('.small').hide().parent().siblings().find('.small').show();
- });
- });
- })
- // 右侧广告
- // 最下方两张图片
- $(function () {
- $('.article_adv').hover(function () {
- $('.article_adv div').stop(true, false).animate({
- bottom: 0
- })
- }, function () {
- $('.article_adv div').stop(true, false).animate({
- bottom: '-28px'
- })
- });
- })
- // 底部广告关闭不显示
- //今日不再显示
- $(".ad_bottom .close").click(function () {
- //当前日期
- var curDate = new Date();
- //当前时间戳
- var curTamp = curDate.getTime();
- //当日凌晨的时间戳,减去一毫秒是为了防止后续得到的时间不会达到00:00:00的状态
- var curWeeHours = new Date(curDate.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g, '')).getTime() - 1;
- //当日已经过去的时间(毫秒)
- var passedTamp = curTamp - curWeeHours;
- //当日剩余时间
- var leftTamp = 24 * 60 * 60 * 1000 - passedTamp;
- var leftTime = new Date();
- leftTime.setTime(leftTamp + curTamp);
- // 设置cookie
- document.cookie = 'loginCounta=1;expires=' + leftTime.toGMTString() + ';path=/';
- // $("#advert_laye").css("display", "none")
- })
- $(document).ready(function () {
- var isClosed = /(^|;| )loginCounta=1/.test(document.cookie); //判定cookie是否存在
- if (!isClosed) {
- $(".ad_bottom").css("display", "block")
- } else {
- $(".ad_bottom").css("display", "none")
- }
- });
- // 进度条
- $(".gift_surplus").each(function () {
- var b = $(this).width();
- var a = $(this).parent(".warp_gift_surplus").width();
- if (a == b) {
- $(this).css("border-radius", "8px")
- }
- })
- //延迟加载图片
- $(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'));
- }
- }
- });
- });
- });
- //右侧控件
- $(".customer_service ul,.warp_right.warp_qq_icon,.warp_ctlist .qq,.warp_qq").hover(function () {
- $(".customer_service").show();
- $(".warp_qq").stop(true, false).animate({ 'margin-top': '-58px' }, 160)
- }, function () {
- $(".customer_service").hide();
- $(".warp_qq").stop(true, false).animate({ 'margin-top': '0px' }, 160)
- });
- $(".warp_ctlist .weixin,.warp_right.warp_code,.ctlist .code,.warp_weixin").hover(function () {
- $(".ctlist .code").show();
- $(".warp_weixin").stop(true, false).animate({ 'margin-top': '-58px' }, 160)
- }, function () {
- $(".ctlist .code").hide();
- $(".warp_weixin").stop(true, false).animate({ 'margin-top': '0px' }, 160)
- });
- $(".customer_service li:first-child+li").hover(function () {
- $(".border-right-empty span").css("border-left", "10px solid #51a7ff")
- }, function () {
- $(".border-right-empty span").css("border-left", "10px solid #f6f6f6")
- });
- $('.warp_totop,.warp_feedback').hover(function () {
- $(this).stop(true, false).animate({
- 'margin-top': '-58px'
- }, 160)
- }, function () {
- $(this).stop(true, false).animate({
- 'margin-top': '0px'
- }, 160)
- });
- $(".qq_1").hover(function () {
- $(this).find("img").attr("src", "/static/images/home/SVG-16.png");
- }, function () {
- $(this).find("img").attr("src", "/static/images/home/SVG-09.png");
- });
- // 点击调用方法,弹出对话框
- $(".customer_service li").on("click", "a", function () {
- openQQ($(this).attr("data-QQ"));
- })
- // 打开对话框的方法
- function openQQ(qq) {
- window.location.href = "tencent://message/?uin=" + qq + "&Site=&Menu=yes";
- }
- // 设置默认游戏icon
- $(".smallIcon").error(function () {
- $(this).attr("src", "/static/images/icon/150-150.png");
- })
- // 分页
- $(function () {
- $(".pagination li:first-child a").html('上一页');
- $(".pagination li:first-child span").html('上一页');
- $(".pagination li:last-child a").html('下一页');
- $(".pagination li:last-child span").html('下一页');
- });
- $(".disabled").each(function(){
- var a = $(this).text();
- if(a="..."){
- //修改父元素
- $(this).find("span").css("cssText", "background:#fff;color:#494949 !important;border:none;cursor: context-menu;");
- }
- })
- // 退出登录
- function toExit() {
- $.ajax({
- type: 'POST',
- url: '/member/logout',
- data: {},
- dataType: 'json',
- success: function (json) {
- window.location.reload();
- },
- error: function () {
- alert('网络错误,请刷新页面重试');
- }
- });
- }
- // 搜索框
-
- $('body').bind('click', function (event) {
- // IE支持 event.srcElement , FF支持 event.target
- var evt = event.srcElement ? event.srcElement : event.target;
- if (evt.id == 'search-input'|| evt.id == 'delete') {
- var a = $('#search-input').val();
- if (a == "") {
- // $("#search_ul").hide();
- update_history();
- } else if ($("#search_ul li").length > 0) {
- $("#search_ul").show();
- }
- }
- else {
- $('#search ul ').hide(); // 如不是则隐藏元素
- }
- });
- $("#search_result").click(function () {
- var vala = $("#search-input").val();
- if (vala == "") {
- vala = $("#search-input").attr('placeholder');
- $("#search_ul").hide();
- } else if ($("#search_ul li").length > 0) {
- $("#search_ul").show();
- }
- var search = "/search/keyword/" + vala;
- $("#search_result").attr("href", search);
- })
- // 去掉ie回车键默认作用
- document.onkeydown = function (e) {
- var e = e || event;
- if (e.keyCode == 13) {
- e.preventDefault ? e.preventDefault() : (e.returnValue = false);
- }
- }
- var flag = true;
- $('#search-input').on('compositionstart', function () {
- flag = false;
- })
- $('#search-input').on('compositionend', function () {
- flag = true;
- })
- var search = {
- searchKeyword: function () {
- val = String($('#search-input').val())
- val = val.replace(/\s*/g, "");
- vala = $('#search-input').val();
- if (vala == "") {
- vala = $("#search-input").attr('placeholder');
- // $("#search_ul").hide();
- update_history();
- } else if ($("#search_ul li").length > 0) {
- $("#search_ul").show();
- }
- var search = "/search/keyword/" + vala;
- $("#search_result").attr("href", search);
- // 按回车搜索
- var e = event || window.event || arguments.callee.caller.arguments[0];
- if (e && e.keyCode == 13) { // enter 键
- document.getElementById("search_result").click();
- }
- setTimeout(function () {
- if (flag) {
- if (!val.length || val.length == 0 || vala == " ") {
- // $("#search_ul").hide();
- // $("#search_ul").empty();
- update_history();
- return
- }
- $.ajax({
- type: 'POST',
- url: '/game/ajaxGameList',
- dataType: 'json',
- data: { keyword: val },
- success: function (json) {
- if ($.isEmptyObject(json)) {
- $("#search_ul").empty();
- $("#search_ul").hide();
- } else {
- var html = '',
- turl = '/game101';
- $.each(json, function (i, row) {
- toUrl = turl.replace('101', row.id)
- html += '<li><a href="' + toUrl + '" target="_blank">' + row.nickname + '</a></li>';
- });
- arrow = ' <div class="border-up-empty"> <span></span></div>'
- $("#search_ul").html(html + arrow);
- $("#search_ul").show();
- }
- }
- });
- }
- }, 10)
- }
- }
- // 搜索框历史记录
- $(function(){
- // 搜索点击事件
- $("#search_result").click(function(){
- var keywords = $("#search-input").val();
- keywords= keywords.replace(/\s*/g, "");
- if ( keywords == "") {
- keywords = $("#search-input").attr('placeholder');
- }
-
- historya(keywords); //添加到缓存
- update_history(); //更新搜索历史
-
- })
- })
-
-
- /**
- * [update_history 更新搜索历史]
- * @return {[type]} [description]
- */
- function update_history(){
- console.log(mystorage.get("keywords"));
- var history = mystorage.get("keywords");
- if (history) {
- var html = "";
- $.each(history,function(i,v){
- var url = "/search/keyword/"+ v;
- html += '<li><a href="'+url+'" target="_blank">'+v+'</a><img src="/static/images/mobile/icon/close-gray.png" class="delete" id="delete"> </li>'
- })
- arrow = ' <div class="border-up-empty"><span></span></div>'
- $("#search_ul").html(html + arrow);
- };
- if($("#search_ul li").length ==0){
- $("#search_ul").hide();
- }else{
- $("#search_ul").show();
- }
- // 点击删除历史
- $(".delete").click(function(){
- var tqtest = $(this).prev().html();
- var history = mystorage.get("keywords");
- history.splice($.inArray(tqtest,history),1);
- mystorage.set("keywords",history);
- // $(this).parents("li").remove();
- update_history();
- })
- }
-
-
- /**
- * [history //搜索历史函数存储]
- * @param {[type]} value [搜索词]
- * @return {[type]} [description]
- */
- function historya(value){
- var data = mystorage.get("keywords");
-
- if (!data) {
- var data = []; //定义一个空数组
- }else if(data.length === 10){ //搜索历史数量
- data.pop(); //删除数组最后一个元素
- }else{
- };
-
- if (value) { //判断搜索词是否为空
- if (data.indexOf(value)<0) { //判断搜索词是否存在数组中
- // data.push(value); //搜索词添加到数组中
- data.splice(0, 0,value); //搜索词添加到数组第一个位置
- mystorage.set("keywords",data); //存储到本地化存储中
-
- }else{
- data.splice($.inArray(value,data),1);
- data.splice(0, 0,value); //搜索词添加到数组第一个位置
- mystorage.set("keywords",data); //存储到本地化存储中
-
- };
- };
- }
-
- /**
- * [mystorage 存储localstorage时候最好是封装一个自己的键值,在这个值里存储自己的内容对象,封装一个方法针对自己对象进行操作。避免冲突也会在开发中更方便。]
- * @param {String} ){ var ms [description]
- * @return {[type]} [description]
- console.log(mystorage.set('tqtest','tqtestcontent'));//存储
- console.log(mystorage.set('aa','123'));//存储
- console.log(mystorage.set('tqtest1','tqtestcontent1'));//存储
- console.log(mystorage.set('tqtest1','newtqtestcontent1'));//修改
- console.log(mystorage.get('tqtest'));//读取
- console.log(mystorage.remove('tqtest'));//删除
- mystorage.clear();//整体清除
- */
- var mystorage = (function mystorage(){
- var ms = "mystorage";
- var storage=window.localStorage;
- if(!window.localStorage){
- alert("浏览器不支持localstorage");
- return false;
- }
- var set = function(key,value){
- //存储
- var mydata = storage.getItem(ms);
- if(!mydata){
- this.init();
- mydata = storage.getItem(ms);
- }
- mydata = JSON.parse(mydata);
- mydata.data[key] = value;
- storage.setItem(ms,JSON.stringify(mydata));
- return mydata.data;
- };
- var get = function(key){
- //读取
- var mydata = storage.getItem(ms);
- if(!mydata){
- return false;
- }
- mydata = JSON.parse(mydata);
- return mydata.data[key];
- };
- var remove = function(key){
- //读取
- var mydata = storage.getItem(ms);
- if(!mydata){
- return false;
- }
- mydata = JSON.parse(mydata);
- delete mydata.data[key];
- storage.setItem(ms,JSON.stringify(mydata));
- return mydata.data;
- };
- var clear = function(){
- //清除对象
- storage.removeItem(ms);
- };
- var init = function(){
- storage.setItem(ms,'{"data":{}}');
- };
- return {
- set : set,
- get : get,
- remove : remove,
- init : init,
- clear : clear
- };
- })();
|