var menuId, layer; var aminInRight = "animated slideInRight"; var aminOutRight = "animated slideOutRight"; var aminInDown = "animated slideInDown"; var aminOutUp = "animated slideOutUp"; var a = "animated fadeInRight"; var b = "animated fadeOutRight"; var layer; layui.use('layer', function () { layer = layui.layer; }); function openMenu() { $("#xs-mainnav").show().addClass(aminInRight); setTimeout(function () { $("#xs-mainnav").removeClass(aminInRight); $("#xs-mainnav").removeClass(aminOutRight); }, 250); } function closeMenu() { $("#xs-mainnav").addClass(aminOutRight); setTimeout(function () { $("#xs-mainnav").removeClass(aminInRight); $("#xs-mainnav").removeClass(aminOutRight); $("#xs-mainnav").hide(); }, 250); } function openType() { $("#product-type").show(); $("#product-type .bg").show(); $("#product-type-content").addClass(a); setTimeout(function () { $("#product-type-content").removeClass(a); $("#product-type-content").removeClass(b); }, 900); } function closeType() { $("#product-type-content").addClass(b); $("#product-type .bg").hide(); setTimeout(function () { $("#product-type-content").removeClass(a); $("#product-type-content").removeClass(b); $("#product-type").hide(); }, 900); } // function resetScrollAnimation() { // var $containers = $('[data-animation]:not([data-animation-child]), [data-animation-container]'); // $containers.scrollAnimations(); // } // $(function () { // resetScrollAnimation() // }) function load(path, el, cb) { $.ajax({ url: path, success: function (res) { $(el).html(res); if (typeof cb == 'function') { cb() } } }) } $(function () { $("#xs-mainnav li").click(function () { $(this).siblings().removeClass("hover") $(this).toggleClass("hover") }) var t; $(".level2").mouseover(function () { clearTimeout(t); $(".level2").removeClass("active"); var index = $(this).index() $(this).addClass("active"); var ab = $(this).parent().parent().find('.product-type3') $('.level4').hide(); var typeId = $(this).data('type-id'); ab.find(".level4.type-id"+typeId).show().css("padding-top", 5 + index * 40 + "px"); }).mouseleave(function () { t = setTimeout( function () { $(".level2").removeClass("active"); $('.level4').hide() } , 500); }) $(".level4").mouseover(function () { clearTimeout(t); }).mouseleave(function () { t = setTimeout( function () { $(".level2").removeClass("active"); $('.level4').hide() } , 500); }) }) function displayRelation(parent, items, cb) { var parentChange = function (val) { var list = null; $(items).each(function () { var relactionVal = String($(this).data('relation-val')); if (relactionVal) { relactionVal = relactionVal.split(','); if (relactionVal.includes(val)) { var $el = $(this); list = list ? list.add($el) : $el; $el.show(); return; } } $(this).hide(); }) if (typeof cb == 'function') { cb(list, val); } } layui.use(['form'], function () { var form = layui.form; var filter = $(parent).attr('lay-filter'); $(parent).change(function(){ parentChange($(this).val()); }) form.on('select(' + filter + ')', function (data) { parentChange(data.value); }) }) parentChange($(parent).val()); } function Lock(options) { var insideLock = false; // 鍐呴儴閿 var that = this; var autoUnlockTimeOut = null; // 鑷姩瑙i攣鐨 timeout var option = $.extend({}, { /** * 鑷姩瑙i攣 */ autoUnlock: { enable: false, effective: 3000 }, }, options); /** * 鍔犻攣 */ this.lock = function () { insideLock = true; // 鑷姩瑙i攣 if (option.autoUnlock.enable) { clearTimeout(autoUnlockTimeOut); autoUnlockTimeOut = setTimeout(function () { that.unlock(); }, option.autoUnlock.effective); } } /** * 瑙i攣 */ this.unlock = function () { insideLock = false; } /** * 杩愯鍑芥暟骞惰嚜鍔ㄥ姞閿 * @param {function}} fun * @returns */ this.run = function (fun) { if (that.isLock()) { console.log("It's locked"); return; } else { that.lock(); } fun(); } this.isLock = function(){ return insideLock; } } /** * 闃叉姈鍔 * @param {*} fn * @param {*} delay * @returns */ function debounce(fn, delay) { let time = null;//time鐢ㄦ潵鎺у埗浜嬩欢鐨勮Е鍙 return function () { if (time !== null) { clearTimeout(time); } time = setTimeout(() => { fn.call(this); //鍒╃敤call(),璁﹖his鐨勬寚閽堜粠鎸囧悜window 杞垚鎸囧悜input }, delay) } }