bszn.js 2.63 KB
layui.use('element', function () {
    var element = layui.element;
});
layui.use('element', function () {
    var element = layui.element;
    //监听Tab切换,以改变地址hash值
    element.on('tab(navtab)', function () {
        if (this.getAttribute('lay-id') == 1) {
            $("body,html").animate({ scrollTop: $(".tudi").offset().top });
            $(".online_business h2").removeClass('titleActive')
            $(".tudi .online_business h2").addClass('titleActive')
        } else if (this.getAttribute('lay-id') == 2) {
            $("body,html").animate({ scrollTop: $(".jianzhu").offset().top });
            $(".online_business h2").removeClass('titleActive')
            $(".jianzhu .online_business h2").addClass('titleActive')
        } else if (this.getAttribute('lay-id') == 3) {
            $("body,html").animate({ scrollTop: $(".linmu").offset().top });
            $(".online_business h2").removeClass('titleActive')
            $(".linmu .online_business h2").addClass('titleActive')
        } else if (this.getAttribute('lay-id') == 4) {
            $("body,html").animate({ scrollTop: $(".qita").offset().top });
            $(".online_business h2").removeClass('titleActive')
            $(".qita .online_business h2").addClass('titleActive')
        } else {
            $("body,html").animate({ scrollTop: 0 });
            $(".online_business h2").removeClass('titleActive')
        }
    });
    element.on('tab(navtab1)', function () {
        if (this.getAttribute('lay-id') == 1) {
            $("body,html").animate({ scrollTop: $(".tudi1").offset().top });
            $(".navtab1  h2").removeClass('titleActive')
            $(".tudi1 .navtab1 h2").addClass('titleActive')
        } else if (this.getAttribute('lay-id') == 2) {
            $("body,html").animate({ scrollTop: $(".jianzhu1").offset().top });
            $(".navtab1 h2").removeClass('titleActive')
            $(".jianzhu1 .navtab1 h2").addClass('titleActive')
        } else if (this.getAttribute('lay-id') == 3) {
            $("body,html").animate({ scrollTop: $(".linmu1").offset().top });
            $(".navtab1 h2").removeClass('titleActive')
            $(".linmu1 .navtab1 h2").addClass('titleActive')
        } else {
            $("body,html").animate({ scrollTop: 0 });
            $(".navtab1 h2").removeClass('titleActive')
        }
    });
});
layui.use('util', function () {
    let util = layui.util;
    //执行
    util.fixbar({
        bar1: true,
        bar2: true,
        top: true
        , click: function (type) {
            console.log(type);
            if (type === 'bar1') {
                alert('点击了bar1')
            }
        }
    });
});