/* @update:2018/06/04 */ import 'css/bootstrap.less'; import 'bootstrap/dist/js/bootstrap.js'; import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'css/newMenu/demand.css'; import 'js/public.js'; import 'js/newMenu/demand.js'; $(function () { init(); function init() { nav(); industryFun(); search(); searchFun(); inpFun(); } //二级导航 function nav() { $('.nav ul li').mouseenter(function () { $(this).find('.subnavigation').slideDown(100); }); $('.nav ul li').mouseleave(function () { $(this).find('.subnavigation').slideUp(100); $('.nav ul li').stop(false, true); }); //轮播 $('#myCarousel').carousel({ interval: 4000 }) } //行业选择 function industryFun() { $('.navMeau').mouseenter(function () { $(this).find('.menuList').slideDown(200); }); $('.navMeau').mouseleave(function () { $(this).find('.menuList').slideUp(200); $('.navMeau').stop(false, true); }); } //搜索 let valArr = [],valTxt=[]; function search(){ $('.menuList ul li').on('click',function(){ let txts = $(this).text(); valArr=[]; valTxt=[]; inputVal(txts); }) } function inputVal(item){ $('.demandSearch').val(''); valTxt.push(item); valArr.push(`${item}`); $('.demandSearch').attr('placeholder',''); $('.txtVal').html(valArr); } function inpFun(){ $('.demandSearch').focus(function(){ if(valArr.length){ valArr=[]; valTxt=[]; $('.txtVal').html(''); } }) $('.demandSearch').focus(function(){ if(!valArr.length&&!($(this).val())){ $('.demandSearch').attr('placeholder','输入你感兴趣的内容'); } }) } function searchFun(){ $('.searchBtn').on('click',function(){ let sVal = $('.search-inp .demandSearch').val(); if(sVal){ console.log(sVal); // window.location.href = globalConfig.context + '/user/account/index.html#consultList' } if(valTxt.length){ console.log(valTxt.join('')) } }); } })