demand.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. @update:2018/06/04
  3. */
  4. import 'css/bootstrap.less';
  5. import 'bootstrap/dist/js/bootstrap.js';
  6. import 'css/newMenu/public.css';
  7. import 'css/newMenu/header.css'
  8. import 'css/newMenu/demand.css';
  9. import 'js/public.js';
  10. import 'js/newMenu/demand.js';
  11. $(function () {
  12. init();
  13. function init() {
  14. nav();
  15. industryFun();
  16. search();
  17. searchFun();
  18. inpFun();
  19. }
  20. //二级导航
  21. function nav() {
  22. $('.nav ul li').mouseenter(function () {
  23. $(this).find('.subnavigation').slideDown(100);
  24. });
  25. $('.nav ul li').mouseleave(function () {
  26. $(this).find('.subnavigation').slideUp(100);
  27. $('.nav ul li').stop(false, true);
  28. });
  29. //轮播
  30. $('#myCarousel').carousel({
  31. interval: 4000
  32. })
  33. }
  34. //行业选择
  35. function industryFun() {
  36. $('.navMeau').mouseenter(function () {
  37. $(this).find('.menuList').slideDown(200);
  38. });
  39. $('.navMeau').mouseleave(function () {
  40. $(this).find('.menuList').slideUp(200);
  41. $('.navMeau').stop(false, true);
  42. });
  43. }
  44. //搜索
  45. let valArr = [],valTxt=[];
  46. function search(){
  47. $('.menuList ul li').on('click',function(){
  48. let txts = $(this).text();
  49. valArr=[];
  50. valTxt=[];
  51. inputVal(txts);
  52. })
  53. }
  54. function inputVal(item){
  55. $('.demandSearch').val('');
  56. valTxt.push(item);
  57. valArr.push(`<span>${item}</span>`);
  58. $('.demandSearch').attr('placeholder','');
  59. $('.txtVal').html(valArr);
  60. }
  61. function inpFun(){
  62. $('.demandSearch').focus(function(){
  63. if(valArr.length){
  64. valArr=[];
  65. valTxt=[];
  66. $('.txtVal').html('');
  67. }
  68. })
  69. $('.demandSearch').focus(function(){
  70. if(!valArr.length&&!($(this).val())){
  71. $('.demandSearch').attr('placeholder','输入你感兴趣的内容');
  72. }
  73. })
  74. }
  75. function searchFun(){
  76. $('.searchBtn').on('click',function(){
  77. let sVal = $('.search-inp .demandSearch').val();
  78. if(sVal){
  79. console.log(sVal);
  80. // window.location.href = globalConfig.context + '/user/account/index.html#consultList'
  81. }
  82. if(valTxt.length){
  83. console.log(valTxt.join(''))
  84. }
  85. });
  86. }
  87. })