PageSourceSearch

https://www.qianxin.com/static/js_dist/header.js?v=2.1.0

js qianxin.com collected 2026-09-24 09:07:51 UTC 13,142 bytes, 504 lines download raw bytes

1"use strict";
2
3(function () {
4  var container = $('#pageNav'); //pc导航
5
6  var navBotton = container.find('.nav-button'); //导航按钮
7
8  var navBottonClose = container.find('.tool-icon-nav-close'); //导航关闭按钮
9
10  var subNavContainer = container.find('.sub-nav-container'); //二级导航的容器
11
12  var subNavContainerMobile = container.find('.sub-nav-container-mobile'); //移动端的导航
13
14  var pageNavShadow = container.find('.page-nav-shadow'); //移动端导航的遮罩
15
16  var subNavItems = subNavContainer.find('.nav-item'); //二级导航链接
17
18  var topNavItems = container.find('.content-wrap .content .nav-item'); //顶部导航的链接
19
20  var activedNav = topNavItems.filter('.active'); //顶部导航的链接高亮的那个
21
22  var subNav = subNavContainer.find('.subnav'); //3级导航容器
23
24  var topnavSide = subNavContainer.find('.topnav_side'); //3级导航的左侧导航 安全产品和解决方案
25
26  var topnavMain = subNav.find('.topnav_main'); //3级导航的内容区域
27
28  var secondNavItems = topnavSide.find('li'); //3级导航左侧导航的链接li
29
30  var secondNavItemsLins = topnavSide.find('li a'); //3级导航左侧导航的链接
31
32  var toolIcon = container.find('.tool-icon .icon'); //顶部小按钮 搜索 语言 登陆
33
34  var isSmallScreen = false; //是否手机小屏幕
35
36  var smallScreenWidth = 768; //手机小屏幕的宽度判断值
37
38  var searchInput = container.find('#searchBar .search-input'); //搜索输入框
39
40  var toolBox = container.find('.tool-box'); //语言 搜索 登陆的 下拉框
41
42  var searchIcon = container.find('#searchIcon'); //搜索的按钮
43  //搜索 用户 语言的下拉列表
44
45  toolIcon.on('click', function (e) {
46    var icon = $(this);
47    $.each(toolIcon, function (index, item) {
48      if (item != icon[0]) {
49        $(item.parentNode).removeClass('current');
50      }
51    });
52    $(icon[0].parentNode).toggleClass('current');
53    var target = icon.attr('open-target');
54    target = $('#' + target);
55    var toolList = container.find('.tool-list');
56    $.each(toolList, function (index, item) {
57      if (item != target[0]) {
58        $(item).hide();
59      }
60    });
61    searchInput.val('');
62    target.slideToggle(200);
63  }); //点击搜索按钮 关闭导航
64
65  searchIcon.on('click', function (e) {
66    e.preventDefault();
67    subNavContainer.hide();
68    initNav();
69
70    if (subNavContainerMobile[0].style.display !== 'none') {
71      subNavContainerMobile.hide();
72      pageNavShadow.hide();
73    }
74
75    pageNavShadow.toggle();
76    navBotton.removeClass('open');
77    navBotton.find('.tool-icon-nav').removeClass('open');
78    $('body').removeClass('nav-open');
79  }); //点击document时候,搜索 用户 语言的下拉列表隐藏
80
81  $(document).on('click', function (e) {
82    var target = e.target;
83    var toolIconArray = toolIcon.toArray();
84    var toolBoxArray = toolBox.toArray();
85    var res = toolIconArray.concat(toolBoxArray);
86    res.push(pageNavShadow[0]);
87    res = res.filter(function (item) {
88      if ($.contains(item, target) || target == item) {
89        return true;
90      }
91
92      return false;
93    });
94
95    if (res.length == 0) {
96      $.each(toolIcon, function (index, item) {
97        var item = $(item);
98        $(item[0].parentNode).removeClass('current');
99        var target = item.attr('open-target');
100        target = $('#' + target);
101        target.hide();
102      });
103    }
104  });
105
106  function checkScreenWith(screenSizeChange) {
107    var clientWidth = document.documentElement.clientWidth;
108
109    if (clientWidth > smallScreenWidth) {
110      isSmallScreen = false;
111    } else {
112      isSmallScreen = true;
113    }
114
115    screenSizeChange && screenSizeChange();
116  }
117
118  checkScreenWith();
119  $(window).on('resize', function () {
120    checkScreenWith();
121  }); // 初始化 导航
122
123  function initNav() {
124    subNav.hide();
125    subNavItems.removeClass('current');
126    secondNavItems.removeClass('current');
127  } // 导航开关的打开和关闭
128
129
130  navBotton.on('click', function (e) {
131    e.preventDefault();
132    initNav();
133    $('body').toggleClass('nav-open');
134
135    if (isSmallScreen) {
136      subNavContainerMobile.toggle();
137
138      if ($(this).hasClass('open')) {
139        pageNavShadow.hide();
140      } else {
141        pageNavShadow.show();
142      }
143
144      $(this).toggleClass('open');
145    } else {
146      subNavContainer.toggle();
147      var target = $(this).attr('target');
148      target = $('#' + target);
149      openFirstNav(target);
150    }
151  }); //关闭导航
152
153  function closeNav() {
154    $('body').removeClass('nav-open');
155    subNavContainer.hide();
156    topNavItems.removeClass('active');
157    activedNav.addClass('active');
158  }
159
160  topnavMain.on('click', '.items a', function () {
161    var link = $(this).attr('href');
162
163    if (link.includes(window.location.pathname)) {
164      closeNav();
165    }
166
167    var arr = link.split('#');
168    var targetAnchor = '';
169
170    if (arr.length > 0) {
171      targetAnchor = "#".concat(arr[1]);
172
173      if (targetAnchor) {
174        $("a[href=\"".concat(targetAnchor, "\"]")).click();
175      }
176    }
177  });
178  navBottonClose.on('click', function (e) {
179    debugger;
180    e.preventDefault();
181    closeNav();
182  }); //键盘事件
183
184  $(document).on('keydown', function (event) {
185    //esc 关闭导航
186    if (event.keyCode == 27) {
187      closeNav();
188    }
189  });
190  topNavItems.on('click', function (e) {
191    e.preventDefault();
192
193    if (!isSmallScreen) {
194      var target = $(this).attr('target');
195
196      if (target == 'qucikNavBar') {
197        return;
198      }
199
200      target = $('#' + target);
201      openFirstNav(target);
202      $('body').addClass('nav-open');
203      subNavContainer.show();
204    }
205  });
206  secondNavItemsLins.on('click', function (e) {
207    e.preventDefault();
208  }); //pc端 hover事件 展开二级菜单
209
210  secondNavItems.hover(function () {
211    var current = $(this);
212    var target = current.find('a').attr('data-target');
213    var subNav = current.parents('.subnav');
214    subNav = $(subNav[0]);
215    var thirdNav = subNav.find('.topnav-main-items');
216    secondNavItems.removeClass("current");
217    current.addClass("current");
218    thirdNav.hide();
219    var targetNav = subNav.find('.topnav_main ' + '.' + target);
220    targetNav.show();
221  });
222
223  function activatedTopNav(current) {
224    var navId = current.attr('id');
225
226    if (navId === 'qucikNavBar') {
227      return;
228    }
229
230    topNavItems.removeClass('active');
231    var currentTopNav = topNavItems.filter('[target="' + navId + '"]');
232    currentTopNav.addClass('active');
233  }
234
235  function openFirstNav(current) {
236    if (!current || !current.length) {
237      return;
238    }
239
240    activatedTopNav(current);
241    var target = current.attr('target');
242    var targetNav = $('#' + target);
243    subNav.hide();
244    subNavItems.removeClass("current");
245    current.addClass("current");
246    targetNav[0].style.display = 'flex';
247    secondNavItems.removeClass("current");
248    $(targetNav.find('.topnav_side li')[0]).addClass('current');
249    var thirdNav = targetNav.find('.topnav-main-items');
250    thirdNav.hide();
251    $(thirdNav[0]).show();
252  } //pc端 hover事件 展开一级菜单
253
254
255  subNavItems.hover(function () {
256    var current = $(this);
257    openFirstNav(current);
258  }); //移动端的导航的初始化 筛选出没有child的节点
259
260  function initSubNavContainerMobile() {
261    var items = subNavContainerMobile.find('li');
262    $.each(items, function (index, item) {
263      item = $(item);
264      var children = item.children('.children');
265
266      if (children.length === 0 || children.children('li').length === 0) {
267        item.addClass('no-child');
268      }
269    });
270  }
271
272  initSubNavContainerMobile(); //移动端的导航的展开
273
274  subNavContainerMobile.on('click', 'li', function (e) {
275    e.stopPropagation();
276    var target = $(e.currentTarget);
277    var parent = $(e.currentTarget.parentNode);
278    var children = target.children('.children');
279
280    if (children.length > 0 && children.children('li').length > 0) {
281      var others = parent.children('li');
282      others.children('.children').slideUp('fast');
283      target.removeClass('current');
284
285      if (children[0].style.display !== 'block') {
286        target.addClass('current');
287        children.slideDown('fast');
288      }
289    }
290  });
291  subNavContainerMobile.on('click', 'a', function (e) {
292    var link = $(this).attr('href');
293
294    if (link.includes(location.pathname)) {
295      window.location.href = link;
296      window.location.reload();
297    }
298  });
299})(); //搜索提示
300
301
302(function () {
303  var searchBar = $('#searchBar');
304  var searchResList = searchBar.find('.search-res-list');
305  var searchInput = searchBar.find('.search-input');
306  var searchIcon = searchBar.find('.search-botton');
307  var removeWord = searchBar.find('.remove-word');
308  $.ajaxSetup({
309    headers: {
310      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
311    }
312  });
313
314  function ajax(url, data, callback) {
315    $.ajax({
316      type: 'get',
317      async: true,
318      url: url,
319      data: data,
320      dataType: 'json',
321      success: function success(res) {
322        callback(res);
323      }
324    });
325  }
326
327  searchResList.hide(); //实现suggest框
328
329  function ajax_conjunctive(content) {
330    var url_conjunctive = "/search/suggest";
331    var data_conjunctive = {
332      kws: content
333    };
334    ajax(url_conjunctive, data_conjunctive, function (res) {
335      //调用成功以后的操作-关联词,如果有数据,就展示
336      if (res != '') {
337        var html = '';
338        $.each(res, function (i, val) {
339          html += '<li>' + val + '</li>';
340        });
341        searchResList.html(html);
342        searchResList.show();
343      } else {
344        searchResList.hide();
345      }
346    });
347  }
348
349  function debounce(fun, delay) {
350    var timer = null;
351    return function (args) {
352      var that = this;
353      var _args = args;
354      clearTimeout(timer);
355      timer = setTimeout(function () {
356        fun.call(that, _args);
357      }, delay);
358    };
359  } // keyCode :27 --esc键
360  // keyCode : 38--上方向键 
361  // keyCode :40 --下方向键
362
363
364  var keyCodeWhitelist = [27, 38, 40];
365  var conjunctiveAjax = debounce(ajax_conjunctive, 500);
366  searchInput.on('keyup focus', function (e) {
367    var keyCode = e.keyCode;
368
369    if (keyCode && keyCodeWhitelist.indexOf(keyCode) != -1) {
370      return;
371    }
372
373    conjunctiveAjax(e.target.value);
374  });
375  searchInput.on('focus', function (e) {
376    $(this).addClass('focus');
377  });
378  searchInput.on('blur', function (e) {
379    $(this).removeClass('focus');
380  }); //点击document时候,关联词弹出框隐藏
381
382  $(document).on('click', function (e) {
383    searchResList.hide();
384  }); //点击关联词
385
386  searchResList.on('click', 'li', function () {
387    searchInput.val($(this).text());
388    goSearch();
389    searchResList.hide();
390  });
391  searchIcon.on('click', function (e) {
392    e.preventDefault();
393    goSearch();
394  });
395  removeWord.on('click', function (e) {
396    e.preventDefault();
397    searchInput.val('');
398    searchResList.hide();
399  });
400
401  function changeSelected(direct) {
402    var searchResListItems = searchResList.find('li');
403    var itemsLength = searchResListItems.length;
404
405    if (itemsLength === 0) {
406      return;
407    }
408
409    var current = searchResList.find('li.current');
410    var index = current.index();
411
412    switch (direct) {
413      case 'up':
414        index--;
415
416        if (index < 0) {
417          index = itemsLength - 1;
418        }
419
420        break;
421
422      case 'down':
423        index++;
424
425        if (index > itemsLength - 1) {
426          index = 0;
427        }
428
429        break;
430    }
431
432    searchResListItems.removeClass('current');
433    var current = $(searchResListItems[index]);
434    current.addClass('current');
435    searchInput.val(current.text());
436  } //搜索框键盘事件
437
438
439  searchInput.on('keydown', function (event) {
440    //方向键 回车
441    if (event.keyCode == 13) {
442      goSearch();
443      searchResList.hide();
444      $(this).blur();
445    } //方向键 向上
446
447
448    if (event.keyCode == 38) {
449      changeSelected('up');
450    } //方向键 向下
451
452
453    if (event.keyCode == 40) {
454      changeSelected('down');
455    }
456
457    console.log(event.keyCode);
458  });
459
460  var goSearch = function goSearch() {
461    var search = searchInput.val();
462
463    if ($.trim(search) == "") {
464      return false;
465    } //挑转到搜索结果页面
466
467
468    var search_url = '/search/index?search=' + JSON.stringify(encodeURIComponent(search));
469    window.open(search_url, '_blank');
470  };
471})();
472
473$(function () {
474  function initAdSender() {
475    $('.topnav-main--container').each(function () {
476      var adLength = $(this).find('.billboard-sender').length;
477
478      if (adLength > 0) {
479        $(this).addClass('has-billboard');
480      }
481    });
482    $('.billboard-sender__media').on('click', function () {
483      var id = $(this).attr('rel_id');
484      $.ajax({
485        url: '/menuad/click',
486        type: 'post',
487        dataType: 'json',
488        data: {
489          code: id,
490          timestamp: new Date().getTime().toString().substring(0, 10)
491        },
492        success: function success(res) {
493          if (res && res.code !== '200') {
494            $.notify(res.errmsg, {
495              type: "danger"
496            });
497          }
498        }
499      });
500    });
501  }
502
503  initAdSender();
504});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.