(function(a,b){$window=a(b),a.fn.lazyload=function(c){function f(){var b=0;d.each(function(){var c=a(this);if(e.skip_invisible&&!c.is(":visible"))return;if(!a.abovethetop(this,e)&&!a.leftofbegin(this,e))if(!a.belowthefold(this,e)&&!a.rightoffold(this,e))c.trigger("appear");else if(++b>e.failure_limit)return!1})}var d=this,e={threshold:200,failure_limit:100,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null};return c&&(undefined!==c.failurelimit&&(c.failure_limit=c.failurelimit,delete c.failurelimit),undefined!==c.effectspeed&&(c.effect_speed=c.effectspeed,delete c.effectspeed),a.extend(e,c)),$container=e.container===undefined||e.container===b?$window:a(e.container),0===e.event.indexOf("scroll")&&$container.bind(e.event,function(a){return f()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,c.one("appear",function(){if(!this.loaded){if(e.appear){var f=d.length;e.appear.call(b,f,e)}a("<img />").bind("load",function(){c.hide().attr("src",c.data(e.data_attribute))[e.effect](e.effect_speed),b.loaded=!0;var f=a.grep(d,function(a){return!a.loaded});d=a(f);if(e.load){var g=d.length;e.load.call(b,g,e)}}).attr("src",c.data(e.data_attribute))}}),0!==e.event.indexOf("scroll")&&c.bind(e.event,function(a){b.loaded||c.trigger("appear")})}),$window.bind("resize",function(a){f()}),f(),this},a.belowthefold=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.height()+$window.scrollTop():e=$container.offset().top+$container.height(),e<=a(c).offset().top-d.threshold},a.rightoffold=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.width()+$window.scrollLeft():e=$container.offset().left+$container.width(),e<=a(c).offset().left-d.threshold},a.abovethetop=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.scrollTop():e=$container.offset().top,e>=a(c).offset().top+d.threshold+a(c).height()},a.leftofbegin=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.scrollLeft():e=$container.offset().left,e>=a(c).offset().left+d.threshold+a(c).width()},a.inviewport=function(b,c){return!a.rightofscreen(b,c)&&!a.leftofscreen(b,c)&&!a.belowthefold(b,c)&&!a.abovethetop(b,c)},a.extend(a.expr[":"],{"below-the-fold":function(c){return a.belowthefold(c,{threshold:0,container:b})},"above-the-top":function(c){return!a.belowthefold(c,{threshold:0,container:b})},"right-of-screen":function(c){return a.rightoffold(c,{threshold:0,container:b})},"left-of-screen":function(c){return!a.rightoffold(c,{threshold:0,container:b})},"in-viewport":function(c){return!a.inviewport(c,{threshold:0,container:b})},"above-the-fold":function(c){return!a.belowthefold(c,{threshold:0,container:b})},"right-of-fold":function(c){return a.rightoffold(c,{threshold:0,container:b})},"left-of-fold":function(c){return!a.rightoffold(c,{threshold:0,container:b})}})})(jQuery,window);
!function(window,$,undefined){var modules,LCGT,loadjscache,loadjs,tab,tipsFlag,tips,mask,popup,msg,simulateSelect;window.console=window.console||{log:function(){}},modules=["tab","tips","mask","popup","msg","loadjs","simulateSelect"],LCGT={getcookie:function(a){return a=window.document.cookie.match(RegExp("(?:^|;+|\\s+)"+a+"=([^;]*)")),a?a[1]:""},setcookie:function(a,b,c,d,e){var f,g;return e&&(f=new Date,f.setTime((new Date).getTime()+864e5*e)),g=window.location.host,window.document.cookie=a+"="+b+"; "+(e?"expires="+f.toGMTString()+"; ":"")+(d?"path="+d+"; ":"path=/; ")+(c?"domain="+c+";":"domain="+g+";"),!0}},$.each(modules,function(index,val){LCGT[val]=function(options){eval("new "+val+"(options);")}}),loadjscache=[],loadjs=function(a){var e,f,b=a.url,c=a.callback||function(){},d=loadjscache.length;for(e=0;d>e;e++)if(loadjscache[e]==b)return c(),!1;return loadjscache.push(b),f=document.createElement("script"),f.setAttribute("type","text/javascript"),f.setAttribute("src",b),document.getElementsByTagName("head")[0].appendChild(f),"object"==typeof f.onreadystatechange?f.onreadystatechange=function(){("loaded"==f.readyState||"complete"==f.readyState)&&c()}:f.onload=function(){c()},!1},tab=function(a){var c,d,b=this;if(b.el=$(a.el),!b.el.length)return!1;if(b.el.length>1)for(c=0;c<b.el.length;c++)d=a,d.el=b.el.eq(c),new tab(d);else b.eventType=a.eventType?a.eventType:"mouseenter",b.callback=a.callback?a.callback:function(){},b.trigger=a.trigger?b.el.find(a.trigger):b.el.find(".trigger").children(),b.panle=a.panle?b.el.find(a.panle):b.el.find(".panle").children(),b.active=a.active?a.active:"active",b.initIndex=a.initIndex?a.initIndex-1:0,b.init()},tab.prototype={init:function(){this.trigger.eq(this.initIndex).addClass(this.active).siblings().removeClass(this.active),this.panle.eq(this.initIndex).addClass(this.active).siblings().removeClass(this.active),this.events()},events:function(){var a=this,b=0;a.trigger.on(a.eventType,function(){var c=$(this),d=c.index();b&&clearTimeout(b),b=setTimeout(function(){c.hasClass(a.active)||(c.addClass(a.active).siblings().removeClass(a.active),a.panle.eq(d).addClass(a.active).siblings().removeClass(a.active),a.callback(a,d))},100)}),"mouseenter"==a.eventType&&a.trigger.on("mouseleave",function(){b&&clearTimeout(b)})}},tipsFlag=100,tips=function(a){this.el=a.el,this.content=a.text,this.skin=a.skin?a.skin:"bounceIn",this.duration=a.duration?a.duration:1e3,this.isKeep=a.isKeep?a.isKeep:!1,this.init(),tipsFlag++},tips.prototype={init:function(){this.createEl()},createEl:function(){var a=null;"undefined"!=typeof this.el.attr("data-tips")&&($("#ui-tips-"+this.el.attr("data-tips")).remove(),this.el.removeAttr("data-tips"),this.el.data("timer")&&clearTimeout(this.el.data("timer"))),this.el.attr("data-tips",tipsFlag),a=$('<div class="ui-tips animation">'),a.attr("id","ui-tips-"+tipsFlag).addClass(this.skin).html('<div class="tips-content"></div><i class="tips-arrow"></i>'),$("body").append(a),a.children(".tips-content").html(this.content),this.show(a)},show:function(a){var b=this.el.offset().left,c=this.el.offset().top,d=this.delta||[0,-40];a.css({left:b+d[0],top:c+d[1]}),this.hide(a)},hide:function(a){var b=this;b.isKeep?b.el.one("mouseleave",function(){b.el.data("timer",setTimeout(function(){a.remove(),b.el.removeAttr("data-tips")},b.duration))}):b.el.data("timer",setTimeout(function(){a.remove(),b.el.removeAttr("data-tips")},b.duration))}},mask=function(a){this.init(a)},mask.prototype={init:function(a){this.container=a.container?$(a.container):$("body"),this.bgcolor=a.bgcolor?a.bgcolor:"#000",this.opacity=a.opacity?a.opacity:.2,this.createEl(),this.show()},createEl:function(){this.el=$('<div class="ui-mask">'),this.el.css({background:this.bgcolor,opacity:this.opacity}),this.container.append(this.el)},resize:function(){var b,c,a=this.container.outerHeight();"body"==this.container.selector&&(a=$(document).outerHeight()),b=$(window).height(),c=$("body").width(),b>a&&(a=b),this.el.height(a),this.el.width(c)},show:function(){var a=this;a.el.css({display:"block",width:a.container.width(),height:a.container.height()}),"body"==a.container.selector&&(a.resize(),$(window).resize(function(){a.resize()}))},hide:function(){this.el.remove()}},popup=function(a){this.init(a)},popup.prototype={init:function(a){if(this.title=a.title,this.content=a.content,this.width=a.width||260,this.absolute=a.absolute||!1,this.skin=a.skin?a.skin:"bounceIn",this.isMaskClose=a.isMaskClose?a.isMaskClose:!1,this.confirm=a.confirm?a.confirm:!1,this.cancel=a.cancel?a.cancel:!1,this.onClose=a.onClose?a.onClose:function(){},this.createMask(a),window.ActiveXObject&&!window.XMLHttpRequest&&(this.absolute=!0),"el"in a){this.el=$(a.el),this.el.addClass("animation").addClass(this.skin).css("display","block");var b=this;if(this.el.find(".close").one("click",function(){b.mask.el.remove(),b.el.css("display","none"),b.onClose(b)}),"undefined"!=typeof this.el.attr("data-popup"))return this.resize(),!1;this.el.attr("data-popup",1)}else this.createEl();this.events(),this.btn()},createMask:function(a){var b=this,c=a.mask?a.mask:{};b.mask=new mask(c),b.isMaskClose&&b.mask.el.on("click",function(){b.hide()})},createEl:function(){this.el=$('<div class="ui-popup animation">'),this.el.css("width",this.width).addClass(this.skin).html('<div class="ui-popup-title">'+this.title+'</div><div class="ui-popup-content">'+this.content+'</div><div class="ui-popup-close"></div>'),$("body").append(this.el)},resize:function(){var a=this.el.outerWidth(),b=this.el.outerHeight(),c=$(window).width(),d=$(window).height();return this.absolute?(this.el.css({position:"absolute",left:c/2-a/2,top:d/2-b/2+$(window).scrollTop()}),!1):(this.el.css({position:"fixed",left:c/2-a/2,top:d/2-b/2}),void 0)},events:function(){var a=this;a.resize(),$(window).resize(function(){return a.absolute?!1:(a.resize(),void 0)}),a.el.children(".ui-popup-close").on("click",function(){a.hide(),a.onClose(a)})},hide:function(){this.mask.el.remove(),this.el.remove()},btn:function(){var b,c,a=this;(a.confirm||a.cancel)&&(b=$('<div class="ui-popup-btn">'),a.confirm&&(c=a.confirm.text||"确定",b.append('<a href="javascript:;" class="btn-confirm">'+c+"</a>"),b.children(".btn-confirm").on("click",function(){if(a.confirm.callback){var c=a.confirm.callback(a);c&&a.hide()}else a.hide()})),a.cancel&&(c=a.cancel.text||"取消",b.append('<a href="javascript:;" class="btn-cancel">'+c+"</a>"),b.children(".btn-cancel").on("click",function(){if(a.cancel.callback){var c=a.cancel.callback(a);c&&a.hide()}else a.hide()})),a.el.append(b))}},msg=function(a){var f,g,i,j,k,l,b=$(".ui-msg"),c=a.skin||"bounceIn",d=a.duration||2e3,e=a.position||["middle"];b.length&&b.remove(),b=$('<div class="ui-msg animation">'),b.addClass(c).html('<div class="msg-content">'),$("body").append(b),b.children(".msg-content").html(a.content),f=b.outerWidth(),g=b.outerHeight(),$(window).width(),i=$(window).height(),j=$(window).scrollTop(),k={},l=e[1]||0,"middle"==e[0]?k={marginLeft:-f/2,top:j+i/2-g/2}:"top"==e[0]?k={marginLeft:-f/2,top:j+l}:"bottom"==e[0]&&(k={marginLeft:-f/2,top:j+i+l-g}),b.css(k),setTimeout(function(){b.remove()},d)},simulateSelect=function(a){if(this.el=$(a.el),!this.el.length)return!1;if(this.el.length>1)for(var b=0;b<this.el.length;b++)new simulateSelect({el:this.el[b],callback:a.callback});else this.arrow=this.el.children(".simulateSelect-arrow"),this.selected=this.el.children(".select-selected"),this.option=this.el.children(".select-option"),this.item=this.option.children(),this.callback=a.callback||function(){},this.init()},simulateSelect.prototype={init:function(){var a=this,b=a.el.attr("data-name")||"",c=a.el.attr("data-value");a.hidden=$('<input type="hidden" name="'+b+'">'),a.el.append(a.hidden),"undefined"!=typeof c&&""!=c&&a.item.each(function(b){var e=$(this).attr("data-value");"undefined"!=typeof e&&c==e&&(a.hidden.val(c),a.item.eq(b).addClass("active"),a.selected.html(a.item.eq(b).text()))}),a.events()},events:function(){var a=this,b="ui-select-active";$(document).on("click",function(){a.el.removeClass(b)}),a.el.on("click",function(c){c.stopPropagation(),a.el.hasClass(b)?a.el.removeClass(b):($(".ui-select").removeClass(b),a.el.addClass(b))}),a.item.on("click",function(c){c.stopPropagation();var d=$(this),e=d.index(),f=d.attr("data-value");d.addClass("active").siblings().removeClass("active"),a.el.attr("data-value",f).removeClass(b),a.selected.html(d.text()),a.hidden.val(f),a.callback(a,e)})}},LCGT.validate={tips:function(a,b,c){var d,e;return LCGT.tips({el:a,text:b}),!c&&a.focus(),d=$(window).scrollTop(),e=a.offset().top-d,50>e&&$(window).scrollTop(d-50+e),!1},rules:{required:function(a,b,c){return""==c?(a.val(""),LCGT.validate.tips(a,b)):!0},isNumber:function(a,b,c){return new RegExp("^(13|15|18|14|17|19)[0-9]{9}$"),isNaN(c)?LCGT.validate.tips(a,b):!0},length:function(a,b,c){return c.length<b.rule[0]||c.length>b.rule[1]?LCGT.validate.tips(a,b.msg):!0},isMobile:function(a,b,c){var d=new RegExp("^(13|15|18|14|17|19)[0-9]{9}$");return d.test(c)?!0:LCGT.validate.tips(a,b)},isPhone:function(a,b,c){var d=new RegExp("^([0-9]{3,4}-)?[0-9]{7,8}$");return d.test(c)?!0:LCGT.validate.tips(a,b)},isEmail:function(a,b,c){var d=new RegExp("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$");return d.test(c)?!0:LCGT.validate.tips(a,b)}},check:function(a){var b=this,c=!0;return $.each(a,function(a,d){var h,i,j,k,e=[],f=!1,g=$.trim(d.el.val());for(h in d)"el"!=h&&e.push(h),"required"==h&&(f=!0);if(!f&&""==g)return!0;for(i=0;i<e.length;i++)if(j=e[i],j in b.rules&&(k=b.rules[j](d.el,d[j],g),!k))return c=!1,!1}),c}},$(document).ready(function(){new simulateSelect({el:".ui-select-model"}),new tab({el:".ui-tab-model"})}),window.LCGT=LCGT}(window,jQuery);
LCGT.topAd = function() {
    var topAd = $('.top-a-d-1');
    if (!topAd.length) {
        return false;
    }
    topAd.children('.close').click(function(event) {
        topAd.animate({
            height: 0
        }, 800);
    });
};
LCGT.topSearch = function() {

    var el = $(".top-search");
    var keywords = el.find(".keywords");
    var choice = el.find(".keyword_choice");
    var form = $("#search-form");
    $(".top-search .select-option span").eq(choice.val() - 1).hide();
    LCGT.simulateSelect({
        el: ".search-select",
        callback: function(o, index) {
            form.attr("action", o.item.show().eq(index).hide().attr("data-action"));
            if (index == 0) {
                keywords.attr("placeholder", "请输入要搜索的产品名称");
                choice.val(1);
            } else if (index == 1) {
                keywords.attr("placeholder", "请输入要搜索的公司名");
                choice.val(2);
            } else if (index == 2) {
                keywords.attr("placeholder", "请输入要搜索的内容");
                choice.val(3);
            } else if (index == 3) {
                keywords.attr("placeholder", "请输入要搜索价格的产品名称");
                choice.val(4);
            }
        }
    });

    form.submit(function(e){
        var url = form.attr('action');
        var key = 0;
        if (choice.val() == 2) {
            key = '';
        }
        if (keywords.val() != '') {
            key = encodeURIComponent(keywords.val());
        }
        e.preventDefault();
        if (choice.val() == 1) {
            // 重写产品搜索url
            url = url.replace('.html', '-' + key + '-0-0-0-0-kw' + '.html');
            //url = url.replace('.html', '-' + key + '-0-0-0-0-kw' + '.html');
           // url = url.replace('.html', str);
            window.location = encodeURI(url);
        } else if (choice.val() == 2) {
            ///company-0-0-0-0-0-0-0%257C0-%25E6%25B5%258B-0.html
            // 重写公司搜索url
            url = url + '?keywords=' + key;
            // url = url.replace('.html', '-0-0-0-0-0-0-0'+ '-' + key + '-0.html');
            window.location = encodeURI(url);
        } else if (choice.val() == 4) {
            url = url.replace('.html', '-' + key + '-kw.html');
            window.location = encodeURI(url);
        } else {
            url = url + '?keywords=' + key + '&choice=3';
            window.location = encodeURI(url);
        }
    });
    form.find(".btn").on("click", function(event) {
        form.submit();
    });
    form.find('input').keypress(function (e) {
        if (e.keyCode == 13) {
            form.submit();
        }
    });
};

LCGT.topNav = function() {
    var box = $(".topnav-box");
    $(".topnav-tar").hover(function() {
        $(this).addClass("topnav-active");
        box.css("display", "block");
    }, function() {
        $(this).removeClass("topnav-active");
        box.css("display", "none");
    });
};

LCGT.productNav = function() {
    var el = $(".product-nav");
    var bd = el.children(".bd");
    var item = bd.children(".item");
    var nba = item.find('.nav-a');
    var itemname = $(".new-name");
    var nnh = $('.new-nav-hd');
    var nb = $('.new-bd .nav-a');
    var hd = $('.product-nav .hd');
    item.on("mouseleave", function(event) {
        $(this).find('.new-name').css('color','#FFF');
    });
    el.on("mouseenter", function(event) {
        $('.item-active .new-name').css('color','#027cdf');
    });
    hd.on("mouseenter", function(event) {
        $('.item-active .new-name').css('color','#027cdf');
    });
    hd.on("mouseleave", function(event) {
        $(' .new-name').css('color','#FFF');
    });
    if (!el.hasClass("nav-show")) {
        el.hover(function() {
            bd.css("display", "block");
        }, function() {
            bd.css("display", "none");
        });
    } else {
        el.on("mouseleave", function(event) {
            if(!el.find(".buy-mask").length==1){
                item.removeClass("item-active");
            }
        });
    }
    item.on("mouseenter", function(event) {
        $(this).addClass("item-active").siblings(".item").removeClass("item-active");
    });
    nba.on("mouseenter", function(event) {
        $(this).parents().parents().parents('.item-active');
        $(this).parents().parents('.nav-hd').find('.new-name').css('color','#999');
        var _this = $(this).attr("class");
        var _thisdiv = $(this).parents().parents().parents('.item-active').find('.new-bd').find('.nav-a');
        $('.item-active .new-bd .nav-a').hide();
        if(_this==$('.item-active .new-bd .nav-a.nav-a-1').attr('class')){
            $('.item-active .new-bd .nav-a.nav-a-1').show();
        }
        if(_this==$('.item-active .new-bd .nav-a.nav-a-2').attr('class')){
            $('.item-active .new-bd .nav-a.nav-a-2').show();
        }
        if(_this==$('.item-active .new-bd .nav-a.nav-a-3').attr('class')){
            $('.item-active .new-bd .nav-a.nav-a-3').show();
        }
    });
    bd.on("mouseleave", function(event) {
        $('.item-active .new-bd .nav-a').hide();
    });
    itemname.on("mouseenter", function(event) {
        $(this).css('color','#027cdf');
        $('.item-active .new-bd .nav-a').hide();
    });
    nnh.on("mouseenter", function(event) {
        $('.item-active .new-bd .nav-a').hide();
    });
    nb.on("mouseenter", function(event) {
        $('.item-active .new-nav-hd-div a').css('color','#027cdf');
    });
    nb.on("mouseleave", function(event) {
        $('.new-nav-hd-div a').css('color','#999');
    });
};

LCGT.contactWidget = function() {

    if ("undefined" != typeof SITE && "sys" in SITE && "service_switch" in SITE.sys) {
        if (SITE.sys.service_switch == "N") {
            return false;
        }
    } else {
        return false;
    }
    // var wxqr = SITE.
    console.log(SITE,'this is site asdsadfsdaf')
    var phone = SITE.sys.service_phone || "400-800-8333";
    var qq = SITE.sys.service_qq || "800032057";
    var wximg = SITE.sys.wechat_service_qrcode || "assets/images/common/weixin-service.jpg";
    var wxname = SITE.sys.wechat_service_qrcode_name || "钢铁世界网微信";
    var service_qrcode = SITE.sys.service_weixin_qrcode
    var service_name = SITE.sys.service_weixin_qrcode_name
    qq = qq.split(",")[0];
    var el = $('<div class="right-weiget noprint">');
    var isLogin = $('input[name=was_login]').val()
    var userType = $('input[name=user_type]').val();
    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
    console.log("domain==>",domain)
    console.log("www_domain_name==>",www_domain_name)
    var price_url = www_domain_name + '/news-list-184.html'
    var url = isLogin == 0 ? www_domain_name + '/login/login.html' : userType == 1 ? www_domain_name + '/buyer_center/index.html' : www_domain_name + '/seller_center/index.html';
    el.html("<div class='tab-wrap'> <a class='weiget-tab' href='" + url + "'><i class='licon-people'></i>个人中心</a> <div class='weiget-tab tel-tab'>" +
    "<img class='small-logo' src='../../assets/images/tiaodong1.gif'/>在线咨询   <div class='contact-popup'>"+
    "<p>客服热线： <span>"+ phone + "</span></p>"+
    "<p>服务时间：<span>08：30-18：00</span></p>" +
    "<div class= 'contact-popup-wechat-qrcode-wrap-wy'>"+
    "<img class= 'contact-popup-wechat-qrcode-wy' src='"+ service_qrcode +"' alt='' />"+
    "</div>"+
	"<div class='contact-popup-wechat-number-wy'>"+service_name+"</div> <div class='contact-popup-wechat-check-wy'>微信扫一扫客服微信二维码，立即咨询</div>   </div></div>"+
	"<div class='weiget-tab tel-tab goToCalculate' style='background: #fff; padding: 0 1px; padding-top: 30px; text-align: center;  margin: 0; width: 100%;position: relative; '>" +
    "<img class='small-logo' style='display:none;position: absolute; left: -29px; top: 57px; width: 33px;' src='../../assets/images/newIconLogo.png' /><img class='small-logo' src='../../assets/images/jisuanjiPic.jpg' style=' width: 30px; margin-right: 2px; margin-bottom: 3px;'/><span style='color: #6E6E6E;'>钢材</span><br><span style='color: #6E6E6E;'>计算器</span>   <div class='contact-popup' style='display: none !important;'>"+
    "<p>客服热线： <span>"+ phone + "</span></p>"+
    "<p>服务时间：<span>08：30-18：00</span></p>" +
    "<div class= 'contact-popup-wechat-qrcode-wrap-wy'>"+
    "<img class= 'contact-popup-wechat-qrcode-wy' src='"+ service_qrcode +"' alt='' />"+
    "</div>"+
    "<div class='contact-popup-wechat-number-wy'>"+service_name+"</div> <div class='contact-popup-wechat-check-wy'>微信扫一扫客服微信二维码，立即咨询</div>   </div></div>"+
    "<a class='weiget-tab' id='lcgt_right_park' style='display:none;' target='_blank' href='https://news.lcgt.cn/news-list-184.html'><img style='width:30px;height:30px;margin-left:-3px' src='assets/images/price_report.png' alt='' />价格日报</a>"+
    "<div class='code-tab' style='position: relative;cursor: pointer;'><i class='licon-code'></i><div class='code-popup'><img src=" + wximg + "><p>扫描二维码<br>关注" + wxname + "</p></div></div>" +
    "<div class='code-wrap'> " +
    "<div class='small-tab' style='display:none;'><img class='small-logo' src='../../assets/images/small-logo.png'/><div class='code-popup1'><img src='../../assets/images/small-program-logo.png'><p>询价小程序</p></div></div>"+
    "<div class='top-tab'><i class='licon-top'></i></div>");
    $("body").append(el);
    el.find(".top-tab").click(function() {
        $("body,html").stop(false, false).animate({
            scrollTop:0
        }, 500);
    });
    var qqUrl = "tencent://message/?Menu=yes&amp;uin=" + qq + "&amp;Service=58&amp;SigT=A7F6FEA02730C988679B55E8AA03F336D1F2FEFFDA4761978B045185229E5AA80F409A752C5BD334001F12EFFFC1D514699FBA02EFB433A934A22C68FBE14396EEFF11F08247A37608AA962A70AB123EB9EA910FE257D403202711D00FD5EECD34DDAAFF74762C42CCABE47BBA5C31F1FF55B984407798E6";
    el.find(".weiget-taba").on("click", function(event) {
        window.open(qqUrl, "_self");
    });
    $('.small-tab').on('mouseover',function(){
        $(this).find('.small-logo').attr('src','../../assets/images/small-logo-white.png');
    });
    $('.small-tab').on('mouseout',function(){
        $(this).find('.small-logo').attr('src','../../assets/images/small-logo.png');
    })
	
	$('.goToCalculate').click(function(){
        var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
		//var www_domain_name = '/calculate/index.html';
		window.open(www_domain_name+'/calculate/index.html');
	})
	
};



LCGT.openMarket = function(redirect, type) {

    $(".handleModal").remove();

    var url = window.location.href; // 跳转
    var type = type == undefined ? 0 : type; // 增加提示
    var el = $(".open-market");
    var domain = LCGT.parse_url();
    var rand = "";
    for(var i = 0; i < 5; i++){
        var r = Math.floor(Math.random() * 10);
        rand += r;
    }
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.')) + '/article_user/open_market';
    if (!el.length) {
        el = $('<div class="open-market">');
        el.html('<iframe src="' + www_domain_name + '" name="open-market" scrolling="no" width="800" height="680" frameborder="0"></iframe><div class="close-all"></div><script>window.addEventListener("message", function(e){if(e.data == 1){window.location.reload();}else{$(".close-all").toggle()}}, false);$("body").css("overflow", "hidden")</script>');
        $("body").append(el);
    }
    LCGT.popup({
        el: el
    });
};

LCGT.loginWidget = function(redirect, type,status) {

    $(".handleModal").remove();

    var url = redirect == undefined ? window.location.href : redirect; // 跳转
    var type = type == undefined ? 0 : type; // 增加提示
    var el = $(".login-widget");
    var domain = LCGT.parse_url();
    var rand = "";
    for(var i = 0; i < 5; i++){
        var r = Math.floor(Math.random() * 10);
        rand += r;
    }
    var channel = 1;
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.')) + '/login/loginWidget?t=' + rand + '&popup_redirect=' + url + '&type=' + type + '&channel=' + channel;
    if (!el.length) {
		if(status == 1){
            el = $('<div class="login-widget" data-ty=1>');
            LCGT.baojiaFlag = true //修改报价登录弹框
		}else{
			el = $('<div class="login-widget">');
		}
		// alert(海哥)
        el.addClass("placeholder-3");
        el.html('<iframe id="loginIframe" src="' + www_domain_name + '" name="login_widget" scrolling="no" width="290" height="380" frameborder="0"></iframe><div class="close"></div>');
        $("body").append(el);
    }
    LCGT.popup({
        el: el
    });
};
// 关闭弹窗登录
$(document).on('click', '.login-widget .close', function () {
    // 登录调整 关闭弹窗跳转页面
    if (typeof $('.login-widget').data('url') !== "undefined") {
        var url = $('.login-widget').data('url')
        setTimeout(function() {
                window.location.href = url;
        }, 1500);
    }

    $('.login-widget').remove();

});

$(document).on('click', '.open-market .close-all', function () {
    $('.open-market').remove()
    $('.ui-mask').fadeOut()
    $("body").css("overflow", "auto")
});

// 监听弹窗登录后关注二维码右上角关闭后跳转
window.addEventListener('message', function(event) {
    console.log(event.data)
    $('.login-widget').attr('data-url', event.data)
})

LCGT.baojiaFlag = false // 初始化报价登录弹框

LCGT.newsRemind = function(newsNum, isSend) {
    if (newsNum < 1) {
        return false;
    }
    $('.purchase_count').html(newsNum);
    if (!isSend) {
        return false;
    }
    var url = $("#purchaseoffer").attr('href');
    var el = $('<div class="news-remark">');
    var str = '<div class="close"></div></a><div class="ui-popup-content"><ul><li><span><i class="num">' + newsNum + '</i>条采购记录待报价</span></li><li>快速报价热线<br />400-800-83333</li></ul></div><div class="ui-popup-btn"><span><i class="count">10</i>秒后自动关闭弹窗</span><a href="'+ url +'" class="btn-confirm">马上查看</a></div><a href="'+ url +'" class="link">';
    el.html(str);
    $("body").append(el);
    var timer = 0;
    el.find(".close").on("click", function(event) {
        clearInterval(timer);
        $(".user_type_span1 .news-record").show();
    });
    var num = 10;
    var count = el.find(".count");
    timer = setInterval(function() {
        if (num > 0) {
            num--;
            count.html(num);
        } else {
            el.find(".close").click();
        }
    }, 1000);
    LCGT.popup({
        el:el,
        mask:{
            opacity:.1
        }
    });
};

$(document).ready(function($) {

    LCGT.login_top(); // 登录相关数据操作

    $("img[data-original]").lazyload({
        effect: "fadeIn"
    });
    LCGT.topSearch();
    LCGT.topNav();
    LCGT.productNav();

    LCGT.topAd();
    $("body").on('click', '.bizqqwpa', function(event) {
        var qq = SITE.sys.service_qq;
        var qqUrl = "tencent://message/?Menu=yes&amp;uin="+ qq +"&amp;Service=58&amp;SigT=A7F6FEA02730C988679B55E8AA03F336D1F2FEFFDA4761978B045185229E5AA80F409A752C5BD334001F12EFFFC1D514699FBA02EFB433A934A22C68FBE14396EEFF11F08247A37608AA962A70AB123EB9EA910FE257D403202711D00FD5EECD34DDAAFF74762C42CCABE47BBA5C31F1FF55B984407798E6";
        window.open(qqUrl, "_self");
    });
    $(".add-favorite").on("click", function(event) {
        try {
            window.external.addFavorite(location.href, document.title);
        } catch (e) {
            try {
                window.sidebar.addPanel(document.title, location.href, "");
            } catch (e) {
                alert("抱歉，您所使用的浏览器无法完成此操作。\n\n加入收藏失败，请进入新网站后使用Ctrl+D进行添加");
            }
        }
    });
    $(".user_type_span").hover(function() {
        $(this).children("#cc").css("display", "block");
    }, function() {
        $(this).children("#cc").css("display", "none");
    });

    var phoneCode = $(".topbar-right .phone-code");
    var timer = 0;
    $(".phone-version").hover(function() {
        timer && clearTimeout(timer);
        phoneCode.stop().animate({
            top: 29
        }, 300, function() {
            phoneCode.css("z-index", 4);
        });
    }, function() {
        timer = setTimeout(function() {
            phoneCode.css("z-index", 4).stop().animate({
                top: -137
            }, 300);
        }, 100);

    });
    phoneCode.hover(function() {
        timer && clearTimeout(timer);
    }, function() {
        timer = setTimeout(function() {
            phoneCode.css("z-index", 4).stop().animate({
                top: -137
            }, 300);
        }, 100);
    });

    if($('.ui-popup')){
        $('.ui-popup-close').click(function(event){
            event.stopPropagation();
            $(this).parents('.ui-popup').addClass('hide');
            $('.ui-mask').addClass('hide');
        });
    }

    LCGT.popupInit();
    server_remind(); // 初始化弹窗

    LCGT.textOverFlow();


    // 绑定核心事件
    var $container = $("body");
    // 初始化编辑器
    $container.find("[data-editor]").each(function(){
        var $this = $(this);
        var opts = $this.data();
        KindEditor.create(this, {
            themeType: 'simple',
            langType: 'zh-CN',
            //urlType: 'relative',
            fullscreenShortcut: true,
            dialogAlignType: '',
            width: '100%',
            imageSizeLimit: '10MB',
            height: opts['height'] || 400,
            filterMode: opts['filter'] || true,
            // uploadJson: __root__+ "/uploads/upload.html?type=" + (opts['type'] || "common"),
            ossName: $this.attr("name") || opts['name'],
            ossPolicy: opts['policy'] || '',
            ossRatio: opts['ratio'] || 4/3,
            ossClose: opts['close'] || 'Y',
            ossLimit: opts['limit'] || 10,
            ossLibrary: opts['library'],
            filePostName: 'upload',
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'ossImage',
                'ossFlash', 'ossMedia', 'ossFile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                'anchor', 'link', 'unlink', '|', 'about'
            ]
        });

        //UE.getEditor(this, {
        //    serverUrl: window.UEDITOR_CONFIG.serverUrl + '?type='  + (opts['type'] || "common"),
        //    initialFrameHeight: opts['height'] || 400
        //});
    });


    // 请求广告模式数据
    // var uriArray = location.host.split('.');
    // var url = 'checkAdMode';
    // if (uriArray[0] == 'www') {
    //     url = '/index/checkAdMode';
    // }
    // $.ajax({
    //     'url': url,
    //     'type': 'post',
    //     'data': {},
    //     'dataType': 'json',
    //     'success': function (res) {
    //         if(res.code==1){
    //             $('#adMode').html(res.data.link);
    //             $('.count').html(res.data.count);
    //
    //             var showAdLine=$('[name=showAdLine]').val();
    //             if(showAdLine==1){
    //                 $('.buy-site-hint').show();
    //                 $('body').addClass('buy-site-pattern');
    //                 $('.item-1').addClass('item-active');
    //             }
    //         }
    //
    //     }
    // });

    var $body = $("body");
    // 图片预览
    $body.on("click", "[data-lightbox]", function(){
        var img = $(this).data("lightbox") || $(this).data("image");
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            offset: '150px',
            area: '500px',
            skin: 'layui-layer-lightbox', //没有背景色
            shadeClose: true,
            content: '<div style="text-align: center;"><img src="'+img+'" border="0" style="max-width: 500px;"/></div>'
        });
        return false;
    })

});

/**
 * 登录后获取用户信息
 */
LCGT.login_top = function() {
    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
    $.ajax({
        url: www_domain_name + '/login/getMessByUInfo.html',
        type: 'get',
        dataType: 'jsonp',
        data: {},
        jsonp:'callback',
        success: function(res) {
            var data = res.data;
            if (data != null) {
                // $('.is_login').css({'display':'block'});
                if (data.user_type == 1) {
                    // 买家
                    $('.company_buyer_center').css({'display':'inline-block'}); //公司子页登录
                    $('.company_seller_center').remove(); //公司子页登录
                } else {
                    // 卖家
                    $('.company_seller_center').css({'display':'inline-block'}); //公司子页登录
                    $('.company_buyer_center').remove(); //公司子页登录

                    // 采购订单提示
                    LCGT.porderRemind();
                }
                var checkCollect = function (obj) {
                    for ( var i in data.collect) {
                        if (obj.attr('data-id') == data.collect[i]) {
                            obj.addClass('collected');
                        }
                    }
                };
                var collectEl = $('.company-selected-item .icon-pentangle');
                if (collectEl.length > 0) {
                    collectEl.each(function () {
                        checkCollect($(this));
                    });
                }
                var subCollect = $('.header-right .collect');
                if (subCollect.length > 0) {
                    checkCollect(subCollect);
                }
                var checkCollectGoods = function (obj) {
                    for ( var i in data.collectGoods) {
                        if (obj.attr('data-id') == data.collectGoods[i]) {
                            obj.addClass('active');
                        }
                    }
                };
                var collectGoodsEl = $('.product-selected-item .icon-pentangle');
                if (collectGoodsEl.length > 0) {
                    collectGoodsEl.each(function () {
                        checkCollectGoods($(this));
                    });
                }

            }
        },
        error: function (res) {
            console.log(22, res);
        }
    });
};

LCGT.ajaxSubmit = function (url, type, data, fn) {
    var nav_type = $('input[name=nav_type]').val();
    $.ajax({
        url: url,
        type: type,
        dataType: 'json',
        data: data,
        cache: false,
        beforeSend: function(){
            html_progress('正在处理...');
        },
        success: function (res) {
            if (res.code == 1) {
                LCGT.popup({
                    title: "提示",
                    content: "<p>"+ res.msg +"</p>",
                    confirm: {
                        callback: function(a) {
                            if (res.url.indexOf('?') != -1) {
                                res.url = res.url + '&nav_type=' + nav_type;
                            } else {
                                res.url = res.url + '?nav_type=' + nav_type;
                            }
                            window.location.href = res.url;
                            return true;
                        }
                    }
                });
                /* 成功回调 */
                if(fn){
                    fn()
                }
            } else {
                LCGT.msg({content: res.msg});
            }
        },
        complete: function() {
            html_Complete();
        }
    })
};

// 退出登录
LCGT.logout = function (obj) {
    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));

    // var domain_name =  SITE.CONST.host;
    // var www_domain_name = '//www'+domain_name.substr(domain_name.indexOf('.'));

    var url = typeof (obj.attr('data-url')) != 'undefined' ? obj.attr('data-url') : '/';
    $.ajax({
        url: www_domain_name + '/login/logout.html',
        type:'GET',
        dataType:'jsonp',
        data:{},
        jsonp:'callback',
        success:function(res){
            $(document).on('click', '.ui-popup-close', function () {
                window.location.reload();
            });
            LCGT.popup({
                title: "提示",
                content: "<p>"+ res.msg +"</p>",
                confirm: {
                    callback: function(a) {
                        window.location.href = url;
                        return true;
                    }
                }
            });
            obj.after(res.data)
        },
    });

};

//popup ui
LCGT.popupInit = function(){

    if($('.ui-popup')){
        $('.ui-popup-close').click(function(event){
            event.stopPropagation();
            $(this).parents('.ui-popup').addClass('hide');
            $('.ui-mask').addClass('hide');
        });
        $('.ui-popup').each(function () {
            var height = $(this).height();
            var width = $(this).width();
            $(this).css({"margin-top": -height/2, "margin-left":-width/2});
        });
    }
};

// 异步登录
LCGT.ajaxLogin = function (type, data, url) {
    // 登录
    $.ajax({
        type:type,
        data: data,
        url: url+'/login/saveData', // 登录api
        dataType: 'jsonp',
        jsonp: 'callback',
        success:function (res) {
            console.log(res)
        }
    })
};

LCGT.parse_url = function(url) {
    var a =  document.createElement('a');
    a.href = url || location.href;
    return {
        protocol: a.protocol.replace(':',''),
        host: a.hostname,
        port: a.port,
        query: a.search,
        file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
        path: a.pathname.replace(/^([^\/])/,'/$1')
    };
};

// 获取当前页面url
function get_page_url() {
    return window.location.protocol + '//' + window.location.host + window.location.pathname;
}

// 服务端返回异步提醒, 因为后端无法直接输出弹窗提示, 所以用这种方法
function server_remind() {
    var remind = $('#server_remind').val();
    if (remind != undefined && remind != '') {
        LCGT.popup({
            title: "提示",
            content: "<p>"+ remind +"</p>",
            confirm: {
                callback: function(a) {
                    return true;
                }
            }
        });
    }
}

/**
 * Loading进度
 * @param content
 * @param timeout
 */
function html_progress(content, timeout){
    if( content == "[close]" ){
        layer.close(this.status);
    }else{
        this.status = layer.msg('<span class="icon-spinner icon-spin"></span> ' + (content || "加载中..."), {
            time: timeout || 0,
            shift: 5,
            shade: [0.2, '#EEEEEE']
        });
    }
    // $('.ui-mask').removeClass('hide');
}

/**
 * Loading完毕
 * @param content
 * @param timeout
 */
function html_Complete(){
    $('.layui-layer-shade').addClass('hide');
    $('.layui-layer').addClass('hide');

    // $('.ui-mask').addClass('hide');
}

/**
 * 获取cookie
 */
function get_cookie(name)
{
    var arr=document.cookie.split('; ');
    var i=0;
    for(i=0;i<arr.length;i++)
    {
        //arr2->['username', 'abc']
        var arr2=arr[i].split('=');

        if(arr2[0]==name)
        {
            var getC = decodeURIComponent(arr2[1]);
            return getC;
        }
    }

    return '';
}

/**
 * 采购订单提醒
 */
LCGT.porderRemind = function () {
    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));

    $.ajax({
        url: www_domain_name + '/seller_purchase/orderRemind.html',
        type: 'get',
        dataType: 'jsonp',
        data: {},
        jsonp:'callback',
        success: function(res) {
            if (res.length != 0) {
                var confirm = $('.ui-popup.login-purchase-popup-confirm');
                event.stopPropagation();
                $('.ui-mask').removeClass('hide');
                confirm.removeClass('hide');
                $.each(res, function (i, h) {
                    confirm.find('table').append('<tr>' +
                        '<td>'+h.show_name+'</td>' +
                        '<td>'+h.actual_number+'</td>'+
                        '<td>'+h.actual_weight+'</td>'+
                        '<td>'+h.seller_price+'</td>'+
                        '<td>'+h.total+'</td>'+
                        '</tr>');
                });
                LCGT.popupInit();

            }
        }
    })
};

LCGT.removePopup = function () {
    $('.ui-popup:not(.hide)').find('.ui-popup-close').trigger('click');
};






/**
 * 构建URL
 * @param url
 * @param vars
 */
function build_url(url, vars){
    var parse = parse_url(url),
        query = parse.params || {},
        params = [];
    if( typeof vars == "string" ){
        if( vars.substr(0,1) != "?" ){
            vars = "?" + vars;
        }
        vars = parse_url_params(vars);
    }
    $.each(vars, function(k, v){
        query[k] = v;
    });
    $.each(query, function(k, v){
        params.push(k+"="+v);
    });
    return "//" + parse.host + parse.path + "?" + params.join("&");
}

/**
 * 解析URL
 * @param {string} url 完整的URL地址
 * @returns {object} 自定义的对象
 * @description
 用法示例：var myURL = parseURL('http://abc.com:8080/dir/index.html?id=255&m=hello#top');
 myURL.file='index.html'
 myURL.host= 'abc.com'
 myURL.query= '?id=255&m=hello'
 myURL.params= Object = { id: 255, m: hello }
 myURL.path= '/dir/index.html'
 myURL.port= '8080'
 yURL.protocol= 'http'
 */
function parse_url(url) {
    var a =  document.createElement('a');
    a.href = url;
    return {
        protocol: a.protocol.replace(':',''),
        host: a.hostname,
        port: a.port,
        query: a.search,
        params: parse_url_params(a.search),
        file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
        path: a.pathname.replace(/^([^\/])/,'/$1')
    };
}



/**
 * 解析URL参数
 * @param query
 * @returns {{}}
 */
function parse_url_params(query){
    var ret = {},
        seg = query.replace(/^\?/,'').split('&'),
        len = seg.length, i = 0, s;
    for (;i<len;i++) {
        if (!seg[i]) { continue; }
        s = seg[i].split('=');
        ret[s[0]] = s[1];
    }
    return ret;
}

/**
 * 使用新窗口打开一个页面的时候指定回跳地址
 */
LCGT.errorBackUrl = function (url) {
    window.open(url + '&back_page=' + window.location.href);
};

/**
 * 文字溢出使用省略号，在元素标签中加入text_overflow类和text-overflow-len属性即可： class="text_overflow" text-overflow-len="10"
 */
LCGT.textOverFlow = function () {
        //限制字符个数
    $(".text_overflow").each(function(){
        var maxwidth = $(this).attr('text-overflow-len'); // 指定截取长度
        console.log($(this).text().length, maxwidth);
        if($(this).text().length>maxwidth-1){
            var new_text = $(this).text().substring(0,maxwidth-1);
            $(this).text(new_text);
            $(this).html($(this).html() + '..');

        }
    });
};

/**
 * 模仿PHP的date()函数
 * strtotime('Y-m-d H:i:s');
 * @param format 只支持 'Y-m-d H:i:s','Y-m-d','H:i:s', 'm-d H:i' 四种调用方式
 * @param time 为空时，取当前时间
 * @return 日期格式化的字符串
 */
LCGT.date = function date(format,time){
    var _temp = (time != null) ? new Date(time*1000) : new Date();
    var _return = '';

    if(/Y-m-d/.test(format)){
        var _day = [_temp.getFullYear(),addzero(1 + _temp.getMonth()),addzero(_temp.getDate())];
        _return = _day.join('-');
    }
    if(/H:i:s/.test(format)){
        var _time = [addzero(_temp.getHours()),addzero(_temp.getMinutes()),addzero(_temp.getSeconds())];
        _return += ' ' +_time.join(':');
    }
    if(/m-d H:i/.test(format)){
        _return += addzero(1 + _temp.getMonth()) + '-' + addzero(_temp.getDate()) + ' ' + addzero(_temp.getHours()) + ':' + addzero(_temp.getMinutes());
    }
    return _return;
    function addzero(i){
        if(i<=9){
            return '0' + i;
        }else{
            return i;
        }
    }
};

/**
 * 模拟php in_array() 函数
 * @param search 要查找的元素
 * @param array
 * @returns {boolean}
 */
LCGT.in_array = function (search,array) {
    for(var i in array){
        if(array[i]==search){
            return true;
        }
    }
    return false;
};

/**
 * 提交采购单后的处理
 */
LCGT.purchase_submit = function (res) {
    // var domain_name =  SITE.CONST.host;
    // var url = '//www'+domain_name.substr(domain_name.indexOf('.')); // 登录api

    var url_data = LCGT.parse_url();
    var dom = url_data.host;
    var domUrl = "//www" + dom.substring(dom.indexOf("."), dom.length);

    LCGT.ajaxLogin('get', res.data, domUrl);// 登录

    console.log(123123, res)

    if (res.msg == 'password') {
        // 未登录状态新账号注册: 登录
        $('.purchase-popup').removeClass('hide');
        $('.ui-mask').removeClass('hide');
        LCGT.popupInit();
        $('.purchase-popup .btn-blue').click(function(event){
            window.location.href = domUrl + '/buyer_center/index.html';
        });
    } else if (res.msg == 'switch_password') {
        // 已登录状态新注册: 切换登录
        $('.purchase-popup2').removeClass('hide');
        $('.ui-mask').removeClass('hide');
        LCGT.popupInit();
        $('.purchase-popup2 .btn-blue').click(function(event){
            window.location.href = domUrl + '/buyer_center/index.html';
        });
    } else if (res.msg == 'login') {
        // 未登录状态: 登录
        LCGT.msg({content: '提交成功'})
        // 跳转到买家中心
        setTimeout(function () {
            window.location.href = '/buyer_center/index.html';
        }, 1500)
    } else if (res.msg == 'succ'){
        // 已登录状态: 登录
        LCGT.msg({content: '提交成功'})
        // 跳转到买家中心
        setTimeout(function () {
            window.location.reload();
        }, 1500)
    } else if (res.msg == 'switch_login') {
        // 已登录状态: 切换登录
        LCGT.msg({content: '提交成功, 已为您切换登录账号', time: 3000})
        // 跳转到买家中心
        setTimeout(function () {
            window.location.href = '/buyer_center/index.html';
        }, 1500)
    }
}

LCGT.mp_subscribe = {
    init: function (type, ticket, url, qrcode, msg) {
        var mp = this
        mp.type = typeof type !== 'undefined' ? type : 1
        // 微信登录
        if (typeof ticket !== 'undefined') {
            mp.ticket = ticket
        } else {
            mp.ticket = $('.subscribe_login').data('ticket')
        }

        if (typeof url !== 'undefined') {
            mp.url = url
        } else {
            mp.url = $('.subscribe_login').data('url')
        }

        if (mp.type == 2) {
            // 显示二维码
            if ($('.wechatBlackBox').length > 0) {
                $('.wechatBlackBox').show()
                $('.wechatBlackBox #subscribe').attr('src', qrcode)

                $('.wechatBlackBox .wechatCloseBtn').click(function () {
                    $('.wechatBlackBox').hide()
                    mp.stop()
                    setTimeout(function() {
                        if ($('.wechatBlackBox').length > 0) {
                            window.location.href = mp.url;
                        } else {
                            parent.window.location.href = mp.url;
                        }
                    }, 2000);
                })
            } else {
                $('.login_wechatImg').show()
                $('.login_wechatImg #subscribe').attr('src', qrcode)
                window.parent.postMessage(mp.url, '*')
                // $('.login-widget', top.document).attr('data-url', mp.url)
            }

        }




        mp.msg = msg
        mp.delay = 1500
        mp.run()
    },
    run: function () {
        var mp = this
        mp.stop()
        mp.num = 0;
        mp.max = 500;
        mp.timer = setInterval(function () {
            mp.checkTicket();
        }, mp.delay);
    },
    checkTicket: function () {
        var mp = this
        mp.num++
        if (mp.num > mp.max) {
            mp.stop()
            alert('二维码超时')
            return false
        }
        var ticket = mp.ticket
        var url_data = LCGT.parse_url();
        var dom = url_data.host;
        var domUrl = "//www" + dom.substring(dom.indexOf("."), dom.length);
        var url = domUrl + '/login/checkSubscribe'
        $.ajax({
            'url': url,
            'type': 'post',
            'data': {ticket: ticket},
            'dataType': 'jsonp',
            'success': function (res) {
                if(res.code == 1){
                    mp.stop()
                    if (typeof mp.msg !== 'undefined') {
                        LCGT.msg({
                            content: mp.msg,
                            duration: 2000
                        });
                    }

                    setTimeout(function() {
                        if ($('.wechatBlackBox').length > 0) {
                            window.location.href = mp.url;
                        } else {
                            parent.window.location.href = mp.url;
                        }
                    }, 2000);
                } else {
                    if (res.code != 1000) {
                        var msg = '绑定出错,请联系客服'
                        if (typeof res.msg !== 'undefined') {
                            msg = res.msg
                        }
                        LCGT.msg({
                            content: msg,
                            duration: 2000
                        });
                        mp.stop()
                        setTimeout(function() {
                            if ($('.wechatBlackBox').length > 0) {
                                window.location.reload()
                            } else {
                                parent.window.location.reload()
                            }
                        }, 2000);
                    }
                }

            }
        });
    },
    stop: function () {
        var mp = this
        clearInterval(mp.timer);
        mp.timer = undefined;
    }
}

function getMonthDay() {
    var now = new Date();
    var month = now.getMonth() + 1;
    var date = now.getDate();
    date < 10 ? date = '0' + date : date = date;
    return month + '-' + date;
}

function getTabIndex() {
    var hash = location.hash;
    var index = hash.search('tab');
    var tabIndex;
    if (index >= 0) {
        index = index + 9;
        tabIndex = hash.charAt(index);
    } else {
        tabIndex = 0;
    }
    return tabIndex;
}

/**
 * 获取当前时间
 */
function getNowFormatDate(flag) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    month = month >= 1 && month <= 9 ? '0' + month : month;
    var strDate = date.getDate() >= 0 && date.getDate() <= 9 ? '0' + date.getDate() : date.getDate();
    var hours = date.getHours() >= 0 && date.getHours() <= 9 ? '0' + date.getHours() : date.getHours();
    var minutes = date.getMinutes() >= 0 && date.getMinutes() <= 9 ? '0' + date.getMinutes() : date.getMinutes();
    var seconds = date.getSeconds() >= 0 && date.getSeconds() <= 9 ? '0' + date.getSeconds() : date.getSeconds();

    var currentdate = '';
    if (flag == undefined) {
        currentdate = year + seperator1 + month + seperator1 + strDate
            + " " + hours + seperator2 + minutes
            + seperator2 + seconds;
    } else {
        if (flag.indexOf('y') != -1) {
            currentdate = currentdate + year;
        }
        if (flag.indexOf('m') != -1) {
            currentdate = currentdate != '' ? currentdate + seperator1 + month : month;
        }
        if (flag.indexOf('d') != -1) {
            currentdate = currentdate != '' ? currentdate + seperator1 + strDate : strDate;
        }
        if (flag.indexOf('h') != -1) {
            currentdate = currentdate != '' ? currentdate + ' ' + hours : hours;
        }
        if (flag.indexOf('i') != -1) {
            currentdate = currentdate != '' ? currentdate + seperator2 + minutes : minutes;
        }
        if (flag.indexOf('s') != -1) {
            currentdate = currentdate != '' ? currentdate + seperator2 + seconds : seconds;
        }
    }

    return currentdate;
}

// 业务员注册弹窗 begin
$(document).on('click', '.footer-left  ul:eq(2) li:eq(1)', function () {//点击弹出弹窗的按钮
    // 点击底部的 我要卖钢材 触发弹窗
    var was_login = $('input[name=was_login]').val();
    var user_type = $('input[name=user_type]').val();
    var footerleftP  = $('.popup-salesman-register');//关闭弹窗DIV的Class

    // if (was_login == 1) {
    //     if (user_type == 2) {
    //         LCGT.msg({content: '您是卖家, 无法申请'});
    //     } else if (user_type == 1) {
    //         // 跳转
    //         var domain = LCGT.parse_url();
    //         var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
    //         window.location.href = www_domain_name + '/sales_register/register.html';
    //     }
    // } else {
    //     LCGT.popup({
    //         el: footerleftP,
    //         mask: {
    //             opacity: .1
    //         }
    //     });
    // }
});

$(document).on('click', '.com-popup-close', function () {//关闭弹出
    $('.ui-mask').remove();
    var footerleftP  = $('.popup-salesman-register');//关闭弹窗DIV的Class
    footerleftP.stop().animate({
        left: "-100%",
        display:"none"
    }, 600);
});
$(document).on('click', '.popup-salesman-register .btn-blue', function () {
    $('.ui-mask').remove();
    var footerleftP  = $('.popup-salesman-register');
    footerleftP.css("display","none");

    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.')); // 跳转
    LCGT.loginWidget(www_domain_name + '/sales_register/register.html');
});
$(document).on('click', '.popup-salesman-register .btn-gray', function () {
    var domain = LCGT.parse_url();
    var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
    window.location.href = www_domain_name + "/sales_register/register.html";
});
// 业务员注册弹窗 end

var footerleftP  = $('.com-popup');//关闭弹窗DIV的Class
footerleftP.find('.com-popup-close').click(function(event) {//关闭弹出
    $('.ui-mask').remove();
    footerleftP.stop().animate({
        left: "-100%",
        display:"none"
    }, 600);
});

// 鼠标经过分享按钮增加类识别
$(document).on('mouseover', '.bdsharebuttonbox', function () {//关闭弹出
    $('.mouse_share').removeClass('mouse_share')
    $(this).addClass('mouse_share')
});
$(document).on('mouseenter','.p-hover',function(){
    $('.p-hover a').css({'color':'#027cdf'});
});
$(document).on("mouseleave",'.p-hover',function(){
    $('.p-hover a').css({'color':'#333333'});
    $('.p-hover-a').css({'color':'#666666'})
})
function parkService() {
    var protocol = window.location.protocol;
    var url = protocol + "//api-ykt.lcgt.cn/v1/entrance/get_entrance?key=lcgt_head_park,lcgt_right_park,lcgt_index_today_offer,lcgt_index_focus,lcgt_index_inquiry,lcgt_index_strength_business,lcgt_product_lists,lcgt_suppliers_lists";
    $.ajax({
        type: 'GET',
        url: url,
        success: function(res) {
            if(res.code === 1){
                const lcgt_head_park = res.data.filter(function(item){
                    return item.key == 'lcgt_head_park'
                })
                const lcgt_right_park = res.data.filter(function(item){
                    return item.key == 'lcgt_right_park'
                })
                const lcgt_index_today_offer = res.data.filter(function(item){
                    return item.key == 'lcgt_index_today_offer'
                })
                const lcgt_index_focus = res.data.filter(function(item){
                    return item.key == 'lcgt_index_focus'
                })
                const lcgt_index_inquiry = res.data.filter(function(item){
                    return item.key == 'lcgt_index_inquiry'
                })
                const lcgt_index_strength_business = res.data.filter(function(item){
                    return item.key == 'lcgt_index_strength_business'
                })
                const lcgt_product_lists = res.data.filter(function(item){
                    return item.key == 'lcgt_product_lists'
                })
                const lcgt_suppliers_lists = res.data.filter(function(item){
                    return item.key == 'lcgt_suppliers_lists'
                })
                var protocol = window.location.protocol;
                var domain = LCGT.parse_url();
                var www_domain_name = '//www'+domain.host.substr(domain.host.indexOf('.'));
                var urlreroute = www_domain_name+"/login/urlRewrite?url=";

                const user_type_yuanqu = $('#is_login_user_type').val()
                
                // 头部
                if(lcgt_head_park.length>0){
                    $('#lcgt_head_park a').attr('href', urlreroute + lcgt_head_park[0].url)
                    if (lcgt_head_park[0].user_type === 0) {
                        $('#lcgt_head_park').show()
                    } else if (lcgt_head_park[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_head_park').show()
                        } else {
                            $('#lcgt_head_park').hide()
                        }
                    } else if (lcgt_head_park[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_head_park').show()
                        } else {
                            $('#lcgt_head_park').hide()
                        }
                    }else{
                        $('#lcgt_head_park').hide()
                    }
                }else{
                    $('#lcgt_head_park').hide()
                }
                // 右侧
                if(lcgt_right_park.length>0){
                    // $('#lcgt_right_park').attr('href', urlreroute + lcgt_right_park[0].url)
                    if (lcgt_right_park[0].user_type === 0) {
                        $('#lcgt_right_park').show()
                    } else if (lcgt_right_park[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_right_park').show()
                        } else {
                            $('#lcgt_right_park').hide()
                        }
                    } else if (lcgt_right_park[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_right_park').show()
                        } else {
                            $('#lcgt_right_park').hide()
                        }
                    }else{
                        $('#lcgt_right_park').hide()
                    }
                }else{
                    $('#lcgt_right_park').hide()
                }
                // 首页今日报价
                if(lcgt_index_today_offer.length>0){
                    $('#lcgt_index_today_offer').attr('href', urlreroute + lcgt_index_today_offer[0].url)
                    $('#lcgt_index_today_offer span').text(lcgt_index_today_offer[0].text)
                    if (lcgt_index_today_offer[0].user_type === 0) {
                        $('#lcgt_index_today_offer').show()
                    } else if (lcgt_index_today_offer[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_index_today_offer').show()
                        } else {
                            $('#lcgt_index_today_offer').hide()
                        }
                    } else if (lcgt_index_today_offer[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_index_today_offer').show()
                        } else {
                            $('#lcgt_index_today_offer').hide()
                        }
                    }else{
                        $('#lcgt_index_today_offer').hide()
                    }
                }else{
                    $('#lcgt_index_today_offer').hide()
                }
                // 首页焦点推荐
                if(lcgt_index_focus.length>0){
                    $('#lcgt_index_focus').attr('href', urlreroute + lcgt_index_focus[0].url)
                    $('#lcgt_index_focus span').text(lcgt_index_focus[0].text)
                    if (lcgt_index_focus[0].user_type === 0) {
                        $('#lcgt_index_focus').show()
                    } else if (lcgt_index_focus[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_index_focus').show()
                        } else {
                            $('#lcgt_index_focus').hide()
                        }
                    } else if (lcgt_index_focus[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_index_focus').show()
                        } else {
                            $('#lcgt_index_focus').hide()
                        }
                    }else{
                        $('#lcgt_index_focus').hide()
                    }
                }else{
                    $('#lcgt_index_focus').hide()
                }
                // 首页实力商家
                if(lcgt_index_strength_business.length>0){
                    $('#lcgt_index_strength_business').attr('href', urlreroute + lcgt_index_strength_business[0].url)
                    $('#lcgt_index_strength_business span').text(lcgt_index_strength_business[0].text)
                    if (lcgt_index_strength_business[0].user_type === 0) {
                        $('#lcgt_index_strength_business').show()
                    } else if (lcgt_index_strength_business[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_index_strength_business').show()
                        } else {
                            $('#lcgt_index_strength_business').hide()
                        }
                    } else if (lcgt_index_strength_business[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_index_strength_business').show()
                        } else {
                            $('#lcgt_index_strength_business').hide()
                        }
                    }else{
                        $('#lcgt_index_strength_business').hide()
                    }
                }else{
                    $('#lcgt_index_strength_business').hide()
                }
                // 产品列表
                if(lcgt_product_lists.length>0){
                    $('#lcgt_product_lists a').attr('href', urlreroute + lcgt_product_lists[0].url)
                    $('#lcgt_product_lists a').text(lcgt_product_lists[0].text)
                    if (lcgt_product_lists[0].user_type === 0) {
                        $('#lcgt_product_lists').show()
                    } else if (lcgt_product_lists[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_product_lists').show()
                        } else {
                            $('#lcgt_product_lists').hide()
                        }
                    } else if (lcgt_product_lists[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_product_lists').show()
                        } else {
                            $('#lcgt_product_lists').hide()
                        }
                    }else{
                        $('#lcgt_product_lists').hide()
                    }
                }else{
                    $('#lcgt_product_lists').hide()
                }

                if(lcgt_suppliers_lists.length>0){
                    $('#lcgt_suppliers_lists a').attr('href', urlreroute + lcgt_suppliers_lists[0].url)
                    $('#lcgt_suppliers_lists a').text(lcgt_suppliers_lists[0].text)
                    // 公司列表
                    if (lcgt_suppliers_lists[0].user_type === 0) {
                        $('#lcgt_suppliers_lists').show()
                    } else if (lcgt_suppliers_lists[0].user_type === 1){
                        if (user_type_yuanqu == 1) {
                            $('#lcgt_suppliers_lists').show()
                        } else {
                            $('#lcgt_suppliers_lists').hide()
                        }
                    } else if (lcgt_suppliers_lists[0].user_type === 2){
                        if (user_type_yuanqu == 2) {
                            $('#lcgt_suppliers_lists').show()
                        } else {
                            $('#lcgt_suppliers_lists').hide()
                        }
                    }else{
                        $('#lcgt_suppliers_lists').hide()
                    }
                }else{
                    $('#lcgt_suppliers_lists').hide()
                }
            }
        }
    });
}


