var Jiagle = Jiagle || {}; Jiagle.config = Jiagle.config || {}; Jiagle.required = function (args) { if (args.ext == 'js') { $('head').append(''); } else if (args.ext == 'css') { $('head').append(''); } } $(function () { $('#info div').each(function () { if (/^is/.test(this.className)) { Jiagle.config[this.className] = this.innerHTML != 0; } else { Jiagle.config[this.className] = this.innerHTML; } }); Jiagle.config.baseURL = Jiagle.config.baseURL || '/'; var link = window.location.href; var linkarray = link.split("/"); actionlink = link.replace(linkarray[linkarray.length - 1], ''); $('#jiagleform').attr("action", actionlink); //var reCat = new RegExp(""); var reCat = /www.+\.com\/[a-z]+_/; var arrdata = link.match(reCat); var linkSite = ""; if (arrdata) { linkSite = arrdata[0].substr(0, arrdata[0].length - 1); } if (!linkSite) { var linkArray = link.split("/"); var linkCat = /www.+\.com/; var linkHome = linkArray[2].match(linkCat); if (linkHome) { linkSite = linkArray[2] + "/" + linkArray[3] + "_"; } else { linkSite = linkArray[2] + "/"; } } else { linkSite = linkSite + "_"; } Jiagle.config.baseSiteURL = linkSite ? linkSite : "/"; if (window.btoa) Jiagle.config.returnURL = window.btoa(window.location.pathname); $.ajax({ url: '/index.php', type: 'post', dataType: 'json', data: { option: 'com_k2', view: 'ajax', task: 'islogin' }, success: function (data) { Jiagle.config.isLogin = data; var em = $('.topschfr').find('.em2'); if (data) { em.eq(0).html('个人中心'); em.eq(1).html('退出'); }else { em.eq(0).html('登录'); em.eq(1).html('注册'); } } }); $('.sq-hover').hover(function () { $(this).find('.j-nav-menu-link').show(); }, function () { $(this).find('.j-nav-menu-link').hide(); }) new Swiper('.cp_01_slide.swiper-container-horizontal', { slidesPerView: 1, effect: 'slide', paginationClickable: true, pagination: { el: '.cp_01_sp.swiper-pagination-bullets', clickable: true, }, }); new Swiper('.cpxq_05b_slide', { slidesPerView: 3, effect: 'slide', spaceBetween: 10, paginationClickable: true, pagination: { el: '.cpxq_05b_sp ', clickable: true, }, }); new Swiper('.cpxq_01_slide', { slidesPerView: 1, effect: 'slide', spaceBetween: 10, paginationClickable: true, pagination: { el: '.cpxq_01_sp', clickable: true, }, }); //首页轮播图 new Swiper('.banner_slide ', { slidesPerView: 1, effect: 'fade', paginationClickable: true, pagination: { el: '.banner_sp', clickable: true, }, // loop: true, autoplay: { delay: 6000, stopOnLastSlide: false, disableOnInteraction: true, }, }); //首页产品推荐 var swiper_product = new Swiper('.in_02t_slide ', { slidesPerView: 'auto', spaceBetween: 10, paginationClickable: true, }); //求购 new Swiper('.swiper-purchase', { autoplay: true, loop: false, pagination: { el: '.purchase_pagination', clickable: true, }, }); //热门推荐 new Swiper('.in_02_t.recommend', { slidesPerView: 2, spaceBetween: 15, autoplay: true, loop: false, pagination: { el: '.recommend_pagination', clickable: true, }, }); //行业展会 new Swiper('.trade_slide', { autoplay: false, loop: false, spaceBetween: 0, navigation: { nextEl: '#trade_next', prevEl: '#trade_prev', }, }); $('.in_02_t.trade a').each(function (i,el) { if ($(this).attr('href')){ if ($(this).attr('href').length < 3){ $(this).attr('href','https://www.hotelex.cn/') } } }) setTimeout(function () { var clone = $('.trade_slide .swiper-slide').eq(0).clone(1); $('.trade_slide .swiper-wrapper').append(clone); }, 2000); $('a.yingxiaoshouce').click(function () { $('.popup.yingxiaoshouce').show(); }) //底部adv new Swiper('.slide1 .swiper-bottomSlide', { autoplay:true, loop:true, pagination: { el: '.bottomSlide_box .bottomSlide-pagination', clickable: true, }, navigation: { nextEl: '#bottomSlide_next', prevEl: '#bottomSlide_prev', }, }); $('.bottomSlide_nav span').click(function () { var index = $('.bottomSlide_nav span').index($(this)); $('.bottomSlide_nav span').removeClass('forcus'); $(this).addClass('forcus'); $('.bottom_slide_item').hide(); $('.bottom_slide_item').eq(index).show(); var slide = '.slide'+ (index + 1); new Swiper(slide+ ' .swiper-bottomSlide', { autoplay:true, loop:true, pagination: { el: '.bottomSlide_box .bottomSlide-pagination', clickable: true, }, navigation: { nextEl: '#bottomSlide_next', prevEl: '#bottomSlide_prev', }, }); }) $('.bottom_slide_item.slide2').hide(); $('.bottom_slide_item.slide3').hide(); $(".in_02t_slide .swiper-slide").click(function () { $('.in_02t_slide').find('a').removeClass('on'); $(this).find('a').addClass('on') var index = $(this).index(); swiper_product.slideTo(index, 1000, false); var num = $(this).find('a').data('num') if (!$(this).hasClass('read')){ $(this).addClass("read"); $('.in_02c_slide').find('.product_box').eq(num).find('img').each(function (i,el){ var img = $(this).data('src'); $(this).attr('src',img); }) } $('.in_02c_slide').find('.product_box').css('display', 'none').removeClass('focus'); $('.in_02c_slide').find('.product_box').eq(num).css('display', 'block').addClass('focus'); var alias = $(this).data('alias'); if (alias){ alias = 'cat_'+alias } $('#product_more').attr('href','/chanpin/'+alias); new Swiper('.product_box.focus', { slidesPerView: 1, paginationClickable: true, pagination: { el: '.in_02c_pagination', clickable: true, }, loop: true, autoplay: true, }); }) $(".in_02t_slide .swiper-slide").eq(0).click(); new Swiper('.in_06c_slide', { slidesPerView: 1, paginationClickable: true, navigation: { nextEl: '#live_next', prevEl: '#live_prev', }, }); var curtop = $(window).scrollTop(); $(window).scroll(function () { curtop = $(window).scrollTop(); scorig(curtop); }); scorig(curtop); function scorig(_curtop) { if (_curtop > 50) { $(".rightfr .scrollTop").css('opacity', '1'); } else { $(".rightfr .scrollTop").css('opacity', '0'); } } $(".rightfr .scrollTop").click(function () { $('body,html').animate({scrollTop: "0px"}, 500); return false; }); $(".cp_07_t>a").click(function(){ var more = $(this).text(); if (more == "更多 >>") { $(this).html("收起 >>"); $(this).parent().next().css('height', "auto"); } else { $(this).text("更多 >>"); $(this).parent().next().css({height: "44px"}); } }) //厂商页面海外直采 $('#country').change(function () { var country_id = $(this).val(); window.location.href = getSelectAddressUrl('country', country_id); }) $('#provice').change(function () { var provice_id = $(this).val(); window.location.href = getSelectAddressUrl('province', provice_id); }) //厂商查看更多按钮 var sc_flag = 1, limitStart_changshang = 4, sc_over = 0; $(".companyProduct_addmore").click(function () { var data = { limitStart: limitStart_changshang, uid: $('[name=first_company_uid]').val(), option: 'com_jiudian_mobile', view: 'changshang', task: 'changshang.getProducts' }; addmoreProduct(data, $('.companyProduct_addmore'), $(".companyProduct dl"), sc_flag, limitStart_changshang, sc_over, 'cp'); limitStart_changshang = limitStart_changshang + 4; return false; }); $("#hotProduct_addmore").click(function () { var data = { limitStart: limitStart_changshang, option: 'com_jiudian_mobile', view: 'changshang', task: 'changshang.gethotProducts' }; addmoreProduct(data, $("#hotProduct_addmore"), $("#hotproduct ul"), sc_flag, limitStart_changshang, sc_over, 'hot_cp'); limitStart_changshang = limitStart_changshang + 4; return false; }); var limitstart = 3; $("#sp_addmore").click(function () { var data = { limitstart: limitstart, option: 'com_jiudian_mobile', view: 'changshang', task: 'changshang.getcompany' }; addmoreProduct(data, $("#sp_addmore"), $("#sp ul"), sc_flag, limitstart, sc_over, 'sp'); limitstart = limitstart + 3; return false; }); //产品页面查看更多产品 var limitStart_chanpin = 20; $(".cpmore_click").click(function () { var data = { limitStart: limitStart_chanpin, option: 'com_jiudian_mobile', view: 'chanpin', task: 'chanpin.getProducts' }; addmoreProduct(data, $('.cpmore_click'), $(".cpmore_frame ul"), sc_flag, limitStart_chanpin, sc_over, 'hot_cp'); limitStart_chanpin = limitStart_chanpin + 20; return false; }); //手机商铺 $(".cp_03_c li").click(function () { if ($(this).hasClass("on")) { $(this).removeClass("on") } else { $(this).addClass("on"); $(this).siblings().removeClass("on") } }) //产品详情 $(".cqxq_03_t a").click(function () { $('.cqxq_03_t').find('a').removeClass("on"); $(this).addClass("on"); var index = $(this).index() - 1; $(".cqxq_03fr").find(".cqxq_03_c").css("display", "none"); $(".cqxq_03fr").find(".cqxq_03_c").eq(index).css("display", "block"); $(window).scrollTop() return false; }); $(".cpxq_05_c a").click(function () { $(".cpxq_05_c").find('a').css('color', "#000") $(this).css("color", "#9a1b5a") var id = this.id; var company_id = $("[name=company_id]").val(); var html=''; j.submit({ 'data': { 'option': 'com_jiudian_mobile', 'view': 'chanpin_detail', 'task': 'chanpin_detail.getother', 'cid': id, 'company_id': company_id }, 'success': function (data) { $.each(data, function(i, item){ html+='
\n' + ''+item.title+''+item.title+'\n' + '
'; }); console.log('html',html) document.getElementById("product_silde").innerHTML=html; new Swiper('.cpxq_05b_slide', { slidesPerView: 3, effect: 'slide', spaceBetween: 10, paginationClickable: true, pagination: { el: '.cpxq_05b_sp ', clickable: true, }, }); return false; }, 'failure': function (e) { console.log(e) return false; } }) }); $(".cslb_03_down>img").click(function () { if ($(this).parent().parent().parent().parent().parent().hasClass('on')) { $(this).parent().parent().parent().parent().parent().removeClass('on') } else { $(this).parent().parent().parent().parent().parent().addClass('on') } }); $(".enquiry").each(function () { MobileEnquiry({btn: $(this), id: this.id, item: 'enquiry'}); }) $(".lease_product").each(function () { MobileLease({btn: $(this), id: this.id, item: 'lease_product'}); }) $(".sample_product").each(function () { MobileSample({btn: $(this), id: this.id, item: 'sample_product'}); }); $(".agency_product").each(function () { MobileAgency({btn: $(this), id: this.id, item: 'agency_product'}); }); //产品/公司收藏 $('.fav_company').each(function () { Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'changshang'}); // clab_tracker.ready(function(){ // this.track("sygle_store_fav", {"c_storename": title}); // }); }); $('.fav_product').each(function () { console.log("收藏了") Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'product'}); // clab_tracker.ready(function(){ // this.track("sygle_product_fav", {"c_productname": title}); // }); }); $('.like_company').each(function () { Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'changshang'}); // clab_tracker.ready(function(){ // this.track("sygle_store_fav", {"c_storename": title}); // }); }); $('.like_product').each(function () { Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'product'}); // clab_tracker.ready(function(){ // this.track("sygle_product_fav", {"c_productname": title}); // }); }); $('.like_product_detail').each(function () { Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'product_p'}); }); }); function addmoreProduct(data, obj1, obj2, sc_flag, limitStart, sc_over, type, url = null) { if (sc_flag !== 1) { return; } if (sc_over) { return; } // 准备 sc_flag = 0; obj1.html('正在加载数据...'); // 收集结果 var html = ''; j.submit({ 'data': data, 'success': function (data) { if (!data || data.length === 0) { sc_over = 1; obj1.html('没有更多数据!'); return; } if (type == "cp") { for (var i = 0; i < data.length; i++) { html += '
'; html += ''+data[i].title+''; html += ''; html += '' + data[i].title + ''; html += ' 询盘'; html += ''; html += ''; html += '
'; } } else if (type == "sp") { for (var i = 0; i < data.length; i++) { html += '
  • ' + '
    '+data[i].title+'' + '

    ' + data[i].title; if (data[i].isVIP){ html += '

    '; } if (data[i].isVR ){ if (!data[i].isVIP){ html +='

    '; } html += ''; } if (data[i].hotel_ezbuy_mp == 2){ if (!data[i].isVIP || !data[i].isVR){ html +='

    '; } html += ''; } html += '

    ' + '' + '
    ' + '
    ' + '

    成立时间:' + data[i].ext[52] + '年

    ' + '

    业务类型:' + data[i].com_type + '

    ' + '

    地址:' + data[i].province + '-' + data[i].city + '

    ' + '

    公司网址:' + data[i].ext[51] + '

    ' + '

    在售产品:' + data[i].num + '

    '; if (data[i].brand){ html +='

    直营品牌:' + data[i].brand + '

    '; } html += '

    主要产品:' + data[i].ext[58] + '

    ' + '
    ' + '' + '
    '; html += '
    '; for (var p = 0; p < 4; p++) { html+= '
    ' + data[i].product[p].title + '' + '' + data[i].product[p].title + '询盘
    '; } html += '
    '; } html += ''; } else if (type == "hot_cp") { for (var i = 0; i < data.length; i++) { html += '
  • '; html += ''+data[i].title+''; html += ''; html += '' + data[i].title + ''; html += ' 询盘'; html += ''; html += '
  • '; } } else if (type == "pp") { for (var i = 0; i < data.length; i++) { html += '
  • '; html += '
    '; html += '
    '+data[i].title+'
    '; html += '
    '; html += '

    ' + data[i].title + '

    '; html += data[i].introtext; html += '
    '; html += '
    '; html += '
    '; html += ''; html += '
    '; html += '
  • '; } }else if(type=='gs_cp'){ for(var i=0 ; i' html += '' html += '
    ' html += '' html += '' html += '
    ' html += '' } } obj2.append(html); $(".enquiry.new").each(function () { MobileEnquiry({btn: $(this), id: this.id, item: 'enquiry'}); $(this).removeClass('new'); }) $('.like_product_new').each(function () { Jiagle.doCookie('fav_returnurl', window.location.href) var id = this.id, title = this.title; MobileFavorite({btn: $(this), id: id, item: 'product'}); }); if (type == "sp") { obj1.html('查看更多商铺'); } else { obj1.html('查看更多产品'); } sc_flag = 1; } }) } /** *筛选国家/城市 * @param aid 城市/省份 id * @param sort 是否排序 * @param address_type country/province */ function getSelectAddressUrl(address_type, aid, sort) { var url = ""; var sort_time = ""; var newurl = window.location.href; if (window.location.href.indexOf("?") != -1) { let index = window.location.href.lastIndexOf("?"); newurl = window.location.href.substring(0, index); } if (window.location.href.indexOf("_sort_time") != -1) { let index = newurl.lastIndexOf("_sort_time") url = newurl.substring(0, index); sort_time = "_sort_time"; }else if (window.location.href.indexOf("sort_time") != -1) { let index = newurl.lastIndexOf("sort_time") url = newurl.substring(0, index); sort_time = "_sort_time"; } else { url = newurl; } if (address_type == "province") { var str = 'province_' + aid ; if (url.indexOf("province") != -1) { let index = url.lastIndexOf("province_") if (url.indexOf("cat_") != -1) { str = 'province_' + aid; } url = url.substring(0, index) + str; } else if (url.indexOf("country_") != -1) { let index = url.lastIndexOf("country_") if (url.indexOf("cat_") != -1) { str = 'province_' + aid; } url = url.substring(0, index) + str; } else if (url.indexOf("cat_") != -1) { let index = url.lastIndexOf("/") url = url.substring(0, index) + "_" + str; } else { url = url + '/province_' + aid; } url = url + sort_time; } else if (address_type == "country") { var str = 'country_' + aid; if (url.indexOf("country") != -1) { let index = url.lastIndexOf("country_") if (url.indexOf("cat_") != -1) { str = 'country_' + aid; } url = url.substring(0, index) + str; } else if (url.indexOf("province") != -1) { let index = url.lastIndexOf("province_") if (url.indexOf("cat_") != -1) { str = 'country_' + aid; } url = url.substring(0, index) + str; } else if (url.indexOf("cat_") != -1) { let index = window.location.href.lastIndexOf("/"); str = '_country_' + aid; url = url.substring(0, index) + str; } else { url = url + '/country_' + aid; } url = url + sort_time; } return url; } // 初始化天地图 function initMap() { var map; var marker; var infoWindow; // 创建地图对象 map = new T.Map("allmap"); // 设置地图中心点和缩放级别 var center = new T.LngLat(116.4074, 39.9042); // 默认北京天安门位置 map.centerAndZoom(center, 12); // 添加地图控件 map.addControl(new T.Control.Zoom()); // 缩放控件 map.addControl(new T.Control.Scale()); // 比例尺控件 map.addControl(new T.Control.OverviewMap()); // 鹰眼控件 // 默认标注一个示例公司 // markCompany(); var companyAddress = jQuery('#address_for_baidu').val(); var companyName = jQuery('#company_title').val(); var zoomLevel = 16; //地图精度 // 使用天地图地理编码服务将地址转换为坐标 var geocoder = new T.Geocoder(); geocoder.getPoint(companyAddress, function(result) { if (result.getStatus() == 0) { // 获取坐标点 var lngLat = result.getLocationPoint(); // 清除之前的标记 if (marker) { map.removeOverLay(marker); } // 创建标记 marker = new T.Marker(lngLat); map.addOverLay(marker); // 设置地图中心为标记位置并设置缩放级别 map.centerAndZoom(lngLat, zoomLevel); // 创建信息窗口内容 var infoContent = "
    " + "

    " + companyName + "

    " + "

    地址: " + companyAddress + "

    " + "
    "; // 绑定信息窗口 marker.addEventListener("click", function() { // 移除之前的信息窗口 if (infoWindow) { map.closeInfoWindow(); } // 创建新的信息窗口并打开 infoWindow = new T.InfoWindow(infoContent, { offset: new T.Point(0, -30) }); map.openInfoWindow(infoWindow, lngLat); }); // 修正:使用正确的方式触发点击事件显示信息窗口 // 直接调用事件处理函数而不是触发事件 setTimeout(function() { // 直接执行点击事件的处理逻辑 if (infoWindow) { map.closeInfoWindow(); } infoWindow = new T.InfoWindow(infoContent, { offset: new T.Point(0, -30) }); map.openInfoWindow(infoWindow, lngLat); }, 500); } else { alert("无法找到该地址,请检查地址是否正确!"); } }); } //加载地图 function LoadBaiduMapScript() { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://api.tianditu.gov.cn/api?v=4.0&tk=b8209be96a41b5e675475a7263b9dd53"; document.body.appendChild(script); } function favorite(type, id) { var option = 'com_jiudian_mobile_ucenter'; var view = ''; var task = ''; if (type == 'changshang') { view = 'favoritecompany'; task = 'favoritecompany.add' } else if (type == 'product') { view = 'favoriteproduct'; task = 'favoriteproduct.add' }else if (type == 'product_p') { view = 'favoriteproduct'; task = 'favoriteproduct.add' } j.submit({ 'data': { 'option': option, 'view': view, 'task': task, 'id': id, }, 'success': function (data) { if (type == 'changshang') { $('.like_company').addClass('collect_company') $('.fav_company').addClass('favorite') }else if(type=='product'){ $('#'+id).addClass('collect_company') }else if (type == 'product_p') { $('.like_product_p').addClass('like_product_p_on'); }else { window.location.href = window.location.href; } alert('收藏成功!'); return false; }, 'failure': function (data) { if (data.code == '1000003') { alert('已收藏该产品'); } else { alert('参数传递错误,无法完成操作'); } } }); } function MobileEnquiry(args) { if (args.btn.length == 0) return; args.btn.click(function () { var url = 'usercenter/enquiryinbox?layout=add'; if (args.id) { url += '&id=' + args.id } else if (args.cid) { url += '&cid=' + args.cid } if (Jiagle.config.isLogin) { window.location.href = 'https://' + Jiagle.config.baseSiteURL + url; } else { window.location.href = 'https://' + Jiagle.config.baseSiteURL + 'login?return='+ window.btoa(Jiagle.config.baseSiteURL + url); } }); } function MobileLease(args) { if (args.btn.length == 0) return; args.btn.click(function () { var url = 'usercenter/rentalmanagemenmylease?layout=add'; if(j.user.id == $(this).data('createdby')){ j.alert('您本公司产品不可租赁');return } if (args.id) { url += '&p_id=' + args.id } else if (args.cid) { url += '&cid=' + args.cid } if (Jiagle.config.isLogin) { window.location.href = 'https://' + Jiagle.config.baseSiteURL + url; } else { window.location.href = 'https://' + Jiagle.config.baseSiteURL + 'login?return='+ window.btoa(Jiagle.config.baseSiteURL + url); } }); } function MobileSample(args) { if (args.btn.length == 0) return; args.btn.click(function () { if(j.user.id == $(this).data('createdby')){ j.alert('您本公司产品不可领样');return } if(Jiagle.config.isLogin){ ajaxProductSample(args,$(this).data('sampleid')); }else{ locationUrl(args); } }); } function MobileAgency(args) { if (args.btn.length == 0) return; var url = 'usercenter/my_agent?layout=add'; args.btn.click(function () { if(j.user.id == $(this).data('createdby')){ j.alert('您本公司产品不可代理');return } if (args.id) { url += '&p_id=' + args.id } else if (args.cid) { url += '&cid=' + args.cid } if (Jiagle.config.isLogin) { window.location.href = 'https://' + Jiagle.config.baseSiteURL + url; } else { window.location.href = 'https://' + Jiagle.config.baseSiteURL + 'login?return='+ window.btoa(Jiagle.config.baseSiteURL + url); } }); } function ajaxProductSample(args,id) { $.ajax({ url: '', type: 'post', dataType: 'json', data: { option: 'com_jiudian_ucenter', view: 'sampleservice', task: 'sampleservice.getProductsInfo', id : id }, success: function (obj) { if (obj.code == 6 || obj.code == 7) { j.alert({ 'msg': obj.msg, 'height':270 }); return; } var result = obj.data; if( result.stock_state == 1 || result.recipients_state == 1 ){ j.alert({ 'msg': '样品已全部领完,请等待厂商补货!', 'okText': '提醒补货' }) return; } locationUrl(args); } }); } function locationUrl(args) { var url = 'usercenter/collarsamplemy?layout=add'; if (args.id) { url += '&p_id=' + args.id } else if (args.cid) { url += '&cid=' + args.cid } if (Jiagle.config.isLogin) { window.location.href = 'https://' + Jiagle.config.baseSiteURL + url; } else { window.location.href = 'https://' + Jiagle.config.baseSiteURL + 'login?return='+ window.btoa(Jiagle.config.baseSiteURL + url); } } /** * 收藏产品,企业 * @param args * btn:按钮的jQuery对象 * id:产品id */ function MobileFavorite(args) { if (args.btn.length == 0) return; args.btn.click(function () { if (Jiagle.config.isLogin) { favorite(args.item, args.id); } else { window.location.href = "https://"+Jiagle.config.baseSiteURL + 'login?return='+window.btoa(window.location.href.replace(/https:\/\//g,'')); } }); } Jiagle.cookie = { set: function (key, val,num) { var date = new Date(); if (num >=6){ var flag = 1; var getCookie = document.cookie.replace(/[ ]/g, ""); var arrCookie = getCookie.split(";"); date.setTime(date.getTime() + 7 * 24 * 3600 * 1000); for (var i = 0; i < arrCookie.length; i++) { var arr = arrCookie[i].split("="); if (new RegExp(key,'g').test(arr[0]) && arr[0]!= key + '_1') { document.cookie = key + '_' + flag + "=" + arr[1] + ";expires=" + date.toGMTString() + ";path=/"; flag ++; } } document.cookie = key + '_6 =' + val + ";expires=" + date.toGMTString() + ";path=/"; }else { date.setTime(date.getTime() + Jiagle.expiresDays * 24 * 3600 * 1000); document.cookie = key + '_' + (num + 1) + "=" + val + ";expires=" + date.toGMTString() + ";path=/"; } }, get: function (key) { var getCookie = document.cookie.replace(/[ ]/g, ""); var arrCookie = getCookie.split(";"); var newarr = new Array(); var date = new Date(); date.setTime(date.getTime() + 7 * 24 * 3600 * 1000); for (var i = 0; i < arrCookie.length; i++) { var arr = arrCookie[i].split("="); if (new RegExp(key,'g').test(arr[0])) { newarr.push(arr[1]); } } newarr.reverse(); return newarr.toString(); }, check: function (key, val) { var getCookie = document.cookie.replace(/[ ]/g, ""); var arrCookie = getCookie.split(";"); for (var i = 0; i < arrCookie.length; i++) { var arr = arrCookie[i].split("="); if (new RegExp(key,'g').test(arr[0]) && val == arr[1]) { return true } } return false; }, delete: function (key) { var date=new Date(); date.setTime(date.getTime()-10000); document.cookie = key + "=0;expires="+date.toGMTString(); } }; Jiagle.doCookie = function (index, val,num) { if (!Jiagle.cookie.check(index, val)){ Jiagle.cookie.set(index, val,num); } }; Jiagle.loadCookie = function (index, site) { var path_arr = index.split('-'); var path1 = path_arr[1] + '-' + path_arr[2]; var path2 = path_arr[1]; if (document.cookie.indexOf(index) >= 0) { var index_str = Jiagle.cookie.get(index); var index_arr = index_str.split(','); var html = ''; for (var i = 0; i < index_arr.length; i++) { if (index_arr[i] != 'undefined') { var link = site + path1 + '/' + index_arr[i]; var name = index_arr[i]; name = name.replace(/\_/g, '%u'); name = unescape(name); html += '
  • ' + name + '
  • '; } } if (html != '') { $('.hot_search_' + path2).find('.hs_left .hs_left_ul').html(html); $('.hot_search_' + path2).find('.hs_left .is_none').hide(); $('.hot_search_' + path2).find('.hs_left .hs_left_ul').show(); } } else { $('.hot_search_' + path2).find('.hs_left .is_none').show(); $('.hot_search_' + path2).find('.hs_left .hs_left_ul').hide(); } }