$(function(){ if(is_pc()){ var _slide_num=4; $("nav .text .weixin").on("mouseover",function(){ var _this=$(this); _this.addClass("on"); }); $("nav .text .weixin").on("mouseout",function(){ var _this=$(this); _this.removeClass("on"); }); if($(".index_kefu").length){ var _swiper=new Swiper('.index_kefu .swiper-container',{ slidesPerView:_slide_num, spaceBetween:30, slidesPerGroup:_slide_num, autoplay:true, loop:true, loopFillGroupWithBlank:true, pagination:{ el:'.swiper-pagination', clickable:true, } }); } if($(".page_single .kefu").length){ _slide_num=3; var _swiper=new Swiper('.page_single .kefu .swiper-container',{ slidesPerView:_slide_num, spaceBetween:30, slidesPerGroup:_slide_num, autoplay:true, loop:true, loopFillGroupWithBlank:true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); } if($(".kf_link2").length){ $(".kf_link2").on("mouseover",function(){ $(".kf_qrcode").show(); }); $(".kf_link2").on("mouseout",function(){ $(".kf_qrcode").hide(); }); } } else{ var _slide_num=1; $(".header .fa").on("click",function(){ $(".header .menu").addClass("fixed"); }); if($(".index_kefu").length){ var _swiper=new Swiper('.index_kefu .swiper-container',{ slidesPerView:_slide_num, spaceBetween:30, slidesPerGroup:_slide_num, autoplay:true, loop:true, loopFillGroupWithBlank:true, pagination:{ el:'.swiper-pagination', clickable:true, } }); } $(document).on("mousedown touchstart",function(e){ var _con=$(".header .menu"); if(!_con.is(e.target) && _con.has(e.target).length === 0){ $(".header .menu").removeClass("fixed"); } }); if($(".get_page").length){ $(".get_page").on("click",function(){ get_page_list(); }); } if($(".page_single .kefu").length){ var _swiper=new Swiper('.page_single .kefu .swiper-container',{ slidesPerView:1, spaceBetween:30, slidesPerGroup:1, autoplay:true, loop:true, loopFillGroupWithBlank:true }); } if($(".page_single.szgs .block_5.mobile").length){ _slide_num=3; var _swiper=new Swiper('.page_single.szgs .block_5.mobile .swiper-container',{ slidesPerView:_slide_num, spaceBetween:30, slidesPerGroup:_slide_num, autoplay:true, loop:true, loopFillGroupWithBlank:true, }); } } if($(".product_detail").length){ $(".product_detail .wrap_left .top .btns .submit").on("click",function(){ $(".mask_1,.float_form").show(); }); $(".float_form h2 i").on("click",function(){ $(".mask_1,.float_form").hide(); }); } if($(".index_form").length){ $(".index_form .submit").on("click",function(){ set_company_name_check(); }); } if($(".product_content").length){ var _tab=$(".product_content .tabs"); var _tab_top=$(".tabs").offset().top; var _block=$(".product_content .list .block"); var _window_height=$(window).height(); $(window).scroll(function(){ var _scroll_top=$(window).scrollTop(); if(_tab_top-_scroll_top<=0){ _tab.css("width",$(".wrap_left").css("width")); _tab.addClass("on"); } else{ _tab.removeClass("on"); } _block.each(function(i,v){ var _this=$(this); var _top=_this.offset().top; if(_top-_scroll_top<=120){ _tab.find("a").removeClass("on"); _tab.find("a:eq("+$(_this).index()+")").addClass("on"); } }); }); $(".product_content .tabs a").on("click",function(){ var _this=$(this); var _index=_this.index(); var _top=$(".product_content .list .block:eq("+_index+")").offset().top; _this.parent().find("a").removeClass("on"); _this.addClass("on"); if($(".product_content .tabs").hasClass("on")){ _top=_top-$(".product_content .tabs").height()-10; } else{ _top=_top-$(".product_content .tabs").height()*2-10; } $('html,body').animate({"scrollTop":_top}); }); } if($(".ask_like").length){ $(".ask_like").on("click",function(){ var _this=$(this); var _data={ e_id:_this.attr("e_id") } $.post("/k_ajax/set_ask_like/",_data,function(res){ if(res){ var _res=JSON.parse(res); if(_res['status']==0){ alert(_res['msg']) } else if(_res['status']==1){ $(".article_answers em").text(_res['num']); } } }); }); } }); String.prototype.myReplace=function(f,e){ var reg=new RegExp(f,"g"); return this.replace(reg,e); } function is_pc() { 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; } function dalert(str,callback){ $.toast({ text:str, position:'mid-center', stack:true, allowToastClose:false, loader:false, has_close_btn: true, has_icon: true, }); callback=callback || null; if(callback!=null){ setTimeout(function(){ callback(); },3000); } } function ddate(timeStamp, type, auto) { type=type || 'Y-M-D H:I:S'; auto=auto || false; var time = (timeStamp + '').length === 10 ? new Date(parseInt(timeStamp) * 1000) : new Date(parseInt(timeStamp)); var _year = time.getFullYear(); var _month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1); var _date = time.getDate() < 10 ? '0' + time.getDate() : time.getDate(); var _hours = time.getHours() < 10 ? '0' + time.getHours() : time.getHours(); var _minutes = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes(); var _secconds = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds(); var formatTime = ''; var distinctTime = new Date().getTime() - time.getTime(); if (auto) { if (distinctTime <= (1 * 60 * 1000)) { // console.log('一分钟以内,以秒数计算'); var _s = Math.floor((distinctTime / 1000) % 60); formatTime = _s + '秒前'; } else if (distinctTime <= (1 * 3600 * 1000)) { // console.log('一小时以内,以分钟计算'); var _m = Math.floor((distinctTime / (60 * 1000)) % 60); formatTime = _m + '分钟前'; } else if (distinctTime <= (24 * 3600 * 1000)) { // console.log('一天以内,以小时计算'); var _h = Math.floor((distinctTime / (60 * 60 * 1000)) % 24); formatTime = _h + '小时前'; } else if (distinctTime <= (30 * 24 * 3600 * 1000)) { var _d = Math.floor((distinctTime / (24 * 60 * 60 * 1000)) % 30); formatTime = _d + '天前'; // console.log('30天以内,以天数计算'); } else { // 30天以外只显示年月日 formatTime = _year + '-' + _month + '-' + _date; } } else { switch (type) { case 'Y-M-D H:I:S': formatTime = _year + '-' + _month + '-' + _date + ' ' + _hours + ':' + _minutes + ':' + _secconds; break; case 'Y-M-D H:I:S zh': formatTime = _year + '年' + _month + '月' + _date + '日 ' + _hours + ':' + _minutes + ':' + _secconds; break; case 'Y-M-D H:I': formatTime = _year + '-' + _month + '-' + _date + ' ' + _hours + ':' + _minutes; break; case 'Y-M-D H': formatTime = _year + '-' + _month + '-' + _date + ' ' + _hours; break; case 'Y-M-D': formatTime = _year + '-' + _month + '-' + _date; break; case 'Y-M-D zh': formatTime = _year + '年' + _month + '月' + _date + '日'; break; case 'Y-M': formatTime = _year + '-' + _month; break; case 'Y': formatTime = _year; break; case 'M': formatTime = _month; break; case 'D': formatTime = _date; break; case 'H': formatTime = _hours; break; case 'I': formatTime = _minutes; break; case 'S': formatTime = _secconds; break; default: formatTime = _year + '-' + _month + '-' + _date + ' ' + _hours + ':' + _minutes + ':' + _secconds; break; } } // 返回格式化的日期字符串 return formatTime; } function get_page_list(){ if($("#page_total").length){ isLoadPage=true; var _page_now=$("#page_now"); var _page_total=$("#page_total"); if(parseInt(_page_total.val())>1){ var _page_next=parseInt(_page_now.val())+1; var _action=$("#page_action").val(); var _params=$("input[name='page_param[]']"); var _arr={}; if(_params.length){ _params.each(function(i,v){ _arr[$(v).attr("title")]=$(v).val(); }); } _arr['page']=_page_next; $.post(_action,_arr,function(res){ var _res=JSON.parse(res); if(_res['status']==1){ if(typeof(_res['result'])!="undefined"){ var _list=_res['result']['list']; } else{ var _list=_res['list']; } if(_list.length>0){ addPageRow(_list); _page_now.val(_page_next); if(_page_now.val()==_page_total.val()){ $(".page_more").hide(); } } } }); } } } function set_company_name_check(){ var _data={ c_name:$("#c_name").val(), c_mobile:$("#c_mobile").val(), c_type:$("#c_type").val(), c_from_name:$("#c_from_name").val(), } $.post("/k_ajax/set_company_name_check/",_data,function(res){ if(res){ var _res=JSON.parse(res); dalert(_res['msg']); $(".mask_1,.float_form").hide(); } }); }