PageSourceSearch

https://res.cqnews.net/ires/2024/8/1/2006181/js/common.js

js cqnews.net collected 2026-10-02 04:43:19 UTC 50,704 bytes, 1,654 lines download raw bytes

1// 18.1.3版本更新
2//头条+banner轮播+专题自动播放
3/*
4 * 所有拓展组件,在同个页面引用时,其按钮等等选择器class 不能相同,否则将会冲突
5 *
6 * */
7(function ($) {
8  //所有 class均为jquery选择器
9  //切换
10  /*
11   * option参数说明:没有特殊说明类型则为string
12   * text:切换文本的class,如果没有则不填写
13   * prev 切换btn class,如果没有则不填写
14   * next 切换btn class ,如果没有则不填写
15   * num  通过num切换,如果没有则不填写,num的length必须与切换对象length相同
16   * className 当前选中num的className(不是选择器),默认:cur
17   * callback 类型:function 每次切换完成调用,如果没有则不填写
18   * index 类型:number 切换开始位置
19   * time  类型 number  切换过渡时间,默认:300;
20   * autoPlay 类型 boolean 是否轮播,默认:true;
21   * playTime 类型 number 自动播放时间,默认:4000,
22   * direction 自动播放的顺序  默认:next
23   * type 切换方向top或left,默认:left
24   * space 类型:number 切换item中的间距 默认:0
25   * indy动态数字变化
26   * lendy 总长度
27   * */
28  function simpleSwitch(option) {
29    var $banner = option._this,
30      $text = option.text ? $(option.text) : null,
31      $prev = option.prev ? $(option.prev) : null,
32      $next = option.next ? $(option.next) : null,
33      $num = option.num ? $(option.num) : null,
34      $indy = option.indy ? $(option.indy) : null,
35      $lendy = option.lendy ? $(option.lendy) : null,
36      callBack = option.callback;
37    var len = $banner.length,
38      index = option.index || 0,
39      time = option.time || 300,
40      playTime = option.playTime || 4000,
41      type = option.type || "left",
42      direction = option.direction || "next",
43      autoPlay =
44        option.autoPlay === undefined || option.autoPlay === true
45          ? true
46          : false,
47      className = option.className || "cur";
48    type = type === "top" ? "top" : "left";
49    var pw =
50        type === "top" ? $banner.parent().height() : $banner.parent().width(),
51      cw = type === "top" ? $banner.height() : $banner.width();
52    option.space = option.space || 0;
53    cw += option.space;
54    var css = {};
55    if (cw * len <= pw) return;
56    init();
57    function init() {
58      if ($lendy) {
59        $lendy.text(len);
60      }
61      $banner.each(function () {
62        var _i = $(this).index();
63        $(this).show();
64        css[type] = (_i - index) * cw;
65        $(this).css(css);
66      });
67      if ($num) {
68        $num.eq(index).addClass(className).siblings().removeClass(className);
69      }
70      if ($indy) {
71        $indy.text(index + 1);
72      }
73      if ($text) {
74        $text.eq(index).show(0).siblings().hide();
75      }
76    }
77    function nextMove() {
78      if (!$banner.is(":visible")) return;
79      for (var i = 0; i < len; i++) {
80        var $item = $banner.eq(i);
81        var pos = Math.floor($item.position()[type]);
82        if (pos <= -cw) {
83          var perLeft = 0;
84          if (i === 0) {
85            perLeft = $banner.eq(len - 1).position()[type];
86          } else {
87            perLeft = $banner.eq(i - 1).position()[type];
88          }
89          css[type] = perLeft + cw;
90          $item.css(css);
91        }
92        var nowLeft = $item.position()[type];
93        css[type] = nowLeft - cw;
94        $item.animate(css, time);
95      }
96    }
97    function prevMove() {
98      if (!$banner.is(":visible")) return;
99      for (var i = 0; i < len; i++) {
100        var $item = $banner.eq(i);
101        var pos = Math.floor($item.position()[type]);
102        if (pos >= pw) {
103          var perLeft = 0;
104          if (i === len - 1) {
105            perLeft = $banner.eq(0).position()[type];
106          } else {
107            perLeft = $banner.eq(i + 1).position()[type];
108          }
109          css[type] = perLeft - cw;
110          $item.css(css);
111        }
112        var nowLeft = $item.position()[type];
113        css[type] = nowLeft + cw;
114        $item.animate(css, time);
115      }
116    }
117    function bannerPlay() {
118      if ($banner.is(":animated")) return;
119      index++;
120      index = index >= len ? 0 : index;
121      if (direction === "next") {
122        nextMove();
123      } else {
124        prevMove();
125      }
126      toNextShow();
127    }
128    if (autoPlay) {
129      var play = setInterval(bannerPlay, playTime);
130    }
131    function toNextShow() {
132      if ($num) {
133        if (direction === "next") {
134          $num.eq(index).addClass(className).siblings().removeClass(className);
135        } else {
136          $num
137            .eq(len - index)
138            .addClass(className)
139            .siblings()
140            .removeClass(className);
141        }
142      }
143      if ($text) {
144        if (direction === "next") {
145          $text.eq(index).show(0).siblings().hide();
146        } else {
147          $text
148            .eq(len - index)
149            .show(0)
150            .siblings()
151            .hide();
152        }
153      }
154      if ($indy) {
155        if (direction === "next") {
156          $indy.text(index + 1);
157        } else {
158          $indy.text(len - index + 1);
159        }
160      }
161      if (!autoPlay) return;
162      clearInterval(play);
163      play = null;
164      play = setInterval(bannerPlay, playTime);
165      if (callBack) callBack();
166    }
167    if ($next) {
168      $next.click(function () {
169        if ($banner.is(":animated")) return;
170        index--;
171        index = index < 0 ? len - 1 : index;
172        // 12.10修改
173        prevMove();
174        toNextShow();
175      });
176    }
177    if ($prev) {
178      $prev.click(function () {
179        if ($banner.is(":animated")) return;
180        index++;
181        index = index >= len ? 0 : index;
182        // 12.10修改
183        nextMove();
184        toNextShow();
185      });
186    }
187    if ($num) {
188      $num.mouseenter(function () {
189        if ($banner.is(":animated")) return;
190        var nextIndex = $num.index($(this));
191        $banner.each(function () {
192          var _i = $(this).index();
193          $(this).show();
194          css[type] = (_i - index) * cw;
195          $(this).css(css);
196        });
197        for (var i = 0; i < len; i++) {
198          var $item = $banner.eq(i);
199          var nowLeft = $item.position()[type];
200          css[type] = nowLeft + -cw * (nextIndex - index);
201          $item.animate(css, time);
202        }
203        index = nextIndex;
204        toNextShow();
205      });
206    }
207  }
208
209  // 淡入淡出切换
210  /*
211   * 参数配置如上
212   * */
213  function SwitchFade(option) {
214    var $banner = option._this,
215      $text = option.text ? $(option.text) : null,
216      $num = option.num ? $(option.num) : null,
217      $indy = option.indy ? $(option.indy) : null,
218      $lendy = option.lendy ? $(option.lendy) : null,
219      index = option.index || 0,
220      len = $banner.length,
221      time = option.time || 300,
222      playTime = option.playTime || 4000,
223      className = option.className || "cur";
224    $banner.hide();
225    $banner.eq(index).show();
226    SwitchTransform();
227    function SwitchTransform() {
228      $banner.stop().eq(index).fadeIn(time).siblings().fadeOut(time);
229      $num.eq(index).addClass(className).siblings().removeClass(className);
230      $text.eq(index).show().siblings().hide();
231      if ($indy) {
232        $lendy.text(len);
233        $indy.text(index + 1);
234      }
235    }
236    function SwitchPlay() {
237      if ($banner.is(":animated")) return;
238      index++;
239      index = index >= len ? 0 : index;
240      SwitchTransform();
241    }
242    var play = setInterval(SwitchPlay, playTime);
243    $num.hover(
244      function () {
245        clearInterval(play);
246        play = null;
247        index = $num.index($(this));
248        SwitchTransform();
249      },
250      function () {
251        play = setInterval(SwitchPlay, playTime);
252      }
253    );
254    if (option.prev) {
255      var $left = $(option.prev);
256      $left.click(function () {
257        index--;
258        index = index < 0 ? len - 1 : index;
259        SwitchTransform();
260        clearInterval(play);
261        play = null;
262        play = setInterval(SwitchPlay, playTime);
263      });
264    }
265    if (option.next) {
266      var $next = $(option.next);
267      $next.click(function () {
268        index++;
269        index = index >= len ? 0 : index;
270        SwitchTransform();
271        clearInterval(play);
272        play = null;
273        play = setInterval(SwitchPlay, playTime);
274      });
275    }
276  }
277
278  //滚动
279  /*
280   * option={
281   * type: 方向 top或 left 默认 left
282   * space:间距 默认 15(可以是负数,最好设置一下)
283   * next、prev左右切换按钮
284   * direction   prev或者next 默认 next,就是设置开始的时候是向左或者向右
285   * time 滚动时间 默认25,时间越大滚动越慢
286   *
287   * }
288   * */
289  function simpleRoll(option) {
290    function RollNext() {
291      // console.log(Width)
292      for (var i = 0; i < len; i++) {
293        var $item = $photo.eq(i);
294        if ($item.position()[type] <= -Width) {
295          var perLeft = 0;
296          if (i === 0) {
297            perLeft = $photo.eq(len - 1).position()[type];
298          } else {
299            perLeft = $photo.eq(i - 1).position()[type];
300          }
301          var _css = {};
302          if (type === "left") {
303            _css[type] = perLeft + cw;
304          } else {
305            _css[type] = perLeft + Width;
306          }
307          $item.css(_css);
308        }
309        var nowLeft = $item.position()[type];
310        (function ($item, nowLeft) {
311          setTimeout(function () {
312            var _css = {};
313            _css[type] = nowLeft - 1;
314            $item.css(_css);
315          }, 5);
316        })($item, nowLeft);
317      }
318    }
319    function RollPrev() {
320      for (var i = 0; i < len; i++) {
321        var $item = $photo.eq(i);
322        // console.log(Width)
323        if ($item.position()[type] >= Width) {
324          var perLeft = 0;
325          if (i === len - 1) {
326            perLeft = $photo.eq(0).position()[type];
327          } else {
328            perLeft = $photo.eq(i + 1).position()[type];
329          }
330          var _css = {};
331          if (type === "left") {
332            _css[type] = perLeft - cw;
333          } else {
334            _css[type] = perLeft - Width;
335          }
336          $item.css(_css);
337        }
338        // 12.13修改
339        var nowLeft = $item.position()[type];
340        (function ($item, nowLeft) {
341          setTimeout(function () {
342            var _css = {};
343            _css[type] = nowLeft + 1;
344            $item.css(_css);
345          }, 5);
346        })($item, nowLeft);
347      }
348    }
349    function playtmFun() {
350      play = setInterval(playFun, time);
351    }
352    var $photo = option._this,
353      direction = option.direction || "next",
354      $next = option.next ? $(option.next) : null,
355      $prev = option.prev ? $(option.prev) : null,
356      $parent = $photo.parent(),
357      len = $photo.length,
358      space = option.space || 15,
359      cw = $photo.width() + space,
360      play = null,
361      playFun = null,
362      time = option.time || 25,
363      type = option.type === "top" ? "top" : "left";
364    // $photo.height()注意这个是$parent.height()还是下面这个
365    var Width = type === "top" ? $photo.height() : $parent.width();
366    $photo.each(function () {
367      var index = $(this).index();
368      var _css = {};
369      if (type === "left") {
370        _css[type] = index * cw;
371      } else {
372        _css[type] = index * Width;
373      }
374      $(this).css(_css);
375    });
376    if (cw * len <= Width) return $photo;
377    if (direction === "next") {
378      playFun = RollNext;
379    } else {
380      playFun = RollPrev;
381    }
382    // 12.13修改
383    playtmFun();
384    if ($prev) {
385      $prev.click(function () {
386        clearInterval(play);
387        playFun = RollNext;
388        playtmFun();
389      });
390    }
391    if ($next) {
392      $next.click(function () {
393        clearInterval(play);
394        playFun = RollPrev;
395        playtmFun();
396      });
397    }
398    $photo.hover(
399      function () {
400        clearInterval(play);
401        play = null;
402      },
403      function () {
404        play = setInterval(playFun, time);
405      }
406    );
407  }
408  //滚动2
409  /*
410   * option={
411   * type: 方向 top或 left 默认 left
412   * space:间距 默认 15(最好设置一下)
413   * next、prev左右切换按钮
414   * direction   prev或者next 默认 next,就是设置开始的时候是向左或者向右
415   * time 滚动时间 默认25,时间越大滚动越慢
416   *
417   * }
418   * */
419  function rollImages(option) {
420    var $photo = option._this,
421      direction = option.direction || "next",
422      $next = option.next ? $(option.next) : null,
423      $prev = option.prev ? $(option.prev) : null,
424      $parent = $photo.parent(),
425      len = $photo.children().length,
426      space = option.space || 15,
427      cw = $photo.children().eq(0).width() + space,
428      play = null,
429      playFun = null,
430      time = option.time || 25,
431      type = option.type === "top" ? "top" : "left",
432      $child = $photo.children();
433    console.log(option);
434    var Width = type === "top" ? $child.height() : $photo.children().width();
435    $child.each(function () {
436      var index = $(this).index();
437      $photo
438        .css({ position: "relative" })
439        .children()
440        .css({ position: "absolute" });
441      var _css = {};
442      if (type === "left") {
443        _css[type] = index * cw;
444      } else {
445        Width = 35;
446        _css[type] = index * Width;
447      }
448      $(this).css(_css);
449    });
450    if ($prev) {
451      $prev.click(function () {
452        clearInterval(play);
453        playFun = prevRoll;
454        playtmFun();
455      });
456    }
457    if ($next) {
458      $next.click(function () {
459        clearInterval(play);
460        playFun = nextRoll;
461        playtmFun();
462      });
463    }
464    $child.hover(
465      function () {
466        clearInterval(play);
467        play = null;
468      },
469      function () {
470        play = setInterval(playFun, time);
471      }
472    );
473    function playtmFun() {
474      play = setInterval(playFun, time);
475    }
476    if (direction === "next") {
477      playFun = prevRoll;
478    } else {
479      playFun = nextRoll;
480    }
481    playtmFun();
482    function prevRoll() {
483      for (var i = 0; i < len; i++) {
484        var $item = $child.eq(i);
485        if ($item.position()[type] <= -Width) {
486          var perLeft = 0;
487          if (i === 0) {
488            perLeft = $child.eq(len - 1).position()[type];
489          } else {
490            perLeft = $child.eq(i - 1).position()[type];
491          }
492          var _css = {};
493          if (type === "left") {
494            _css[type] = perLeft + cw;
495          } else {
496            _css[type] = perLeft + Width;
497          }
498          $item.css(_css);
499        }
500        var nowLeft = $item.position()[type];
501        (function ($item, nowLeft) {
502          setTimeout(function () {
503            var _css = {};
504            _css[type] = nowLeft - 1;
505            $item.css(_css);
506          }, 5);
507        })($item, nowLeft);
508      }
509    }
510    function nextRoll() {
511      for (var i = 0; i < len; i++) {
512        var $item = $child.eq(i);
513        if ($item.position()[type] >= cw * (len - 1)) {
514          var perLeft = 0;
515          if (i === len - 1) {
516            perLeft = $child.eq(0).position()[type];
517          } else {
518            perLeft = $child.eq(i + 1).position()[type];
519          }
520          var _css = {};
521          if (type === "left") {
522            _css[type] = perLeft - cw;
523          } else {
524            _css[type] = perLeft - Width;
525          }
526          $item.css(_css);
527        }
528        // 12.13修改
529        var nowLeft = $item.position()[type];
530        (function ($item, nowLeft) {
531          setTimeout(function () {
532            var _css = {};
533            _css[type] = nowLeft + 1;
534            $item.css(_css);
535          }, 5);
536        })($item, nowLeft);
537      }
538    }
539  }
540  //多张图片左右滚动(每次只滚动一张)
541  /*
542   * option={
543   * len 显示几个的数量
544   * type: 方向 right 或 left 默认 left
545   * space:间距 默认 15
546   * prev next 左右按钮
547   * parentBox 父容器元素
548   * childBox 子元素
549   * childMargin 子元素外边距,没有可不传
550   *
551    aniTime:默认500,//过渡时间
552    moveTime:默认3000//间隔滑动时间
553    fun: 滑动回调
554   *
555   *
556   * }
557   * */
558  function bannerRollLR(option) {
559    var len = option.len || banBox.children().length, //显示几个的数量
560      aniTime = option.aniTime || 500, //过渡时间
561      moveTime = option.moveTime || 3000, //间隔滑动时间
562      banBox = option._this, //移动的容器
563      type = option.type || "left",
564      banBtnL = option.prev ? $(option.prev) : null, //左按钮
565      banBtnR = option.next ? $(option.next) : null; //右按钮
566    // banBtnL.show();
567    // banBtnR.show();
568    var i = 0,
569      cloneArr = [];
570    // moveM = (banBox.parent().width())/len;
571    banBox.each(function () {
572      for (var i = 0; i < len; i++) {
573        cloneArr.push(banBox.children().eq(i).clone());
574      }
575    });
576    for (var j = 0; j < cloneArr.length; j++) {
577      banBox.append(cloneArr[j]);
578    }
579    var sizeChild = banBox.children().length;
580    var moveM = banBox.children().outerWidth(true); //获取内外边距
581    banBox.css({ width: sizeChild * moveM * 1.2 });
582    function movel() {
583      if (banBox.is(":animated")) return;
584      i++;
585      if (i === sizeChild - (len - 1)) {
586        banBox.css({ left: 0 });
587        i = 1;
588      }
589      banBox.stop().animate({ left: -i * moveM }, aniTime, function () {
590        changeLStyle(
591          option.parentBox,
592          option.childBox,
593          option.len,
594          option.childMargin
595        );
596      });
597    }
598    function mover() {
599      if (banBox.is(":animated")) return;
600      i--;
601      if (i === -1) {
602        banBox.css({ left: -(sizeChild - len) * moveM });
603        i = sizeChild - (len + 1);
604      }
605      banBox.stop().animate({ left: -i * moveM }, aniTime, function () {
606        changeRStyle(option.parentBox, option.childBox, option.len);
607      });
608    }
609    /**
610     * 往右走的样式
611     */
612    var tabStatus = true,
613      Lstautus = false;
614    function changeRStyle(parentBox, childBox, Num) {
615      var CurDom = $(parentBox).find(".cur");
616      var leftLen = parseFloat($(parentBox).css("left"));
617      if (tabStatus) {
618        var listNums = $(parentBox).children("li").length;
619        $(childBox).removeClass("cur");
620        $(childBox)
621          .eq(listNums - Num + 1)
622          .addClass("cur");
623        tabStatus = false;
624        return;
625      }
626      if (leftLen == 0) {
627        tabStatus = true;
628      }
629      CurDom.prev().addClass("cur").next().removeClass("cur");
630    }
631
632    /**
633     * 往左走的样式
634     */
635    function changeLStyle(parentBox, childBox, Num, childMargin) {
636      var CurDom = $(parentBox).find(".cur");
637      var leftLen = parseFloat($(parentBox).css("left"));
638      if (!childMargin) {
639        childMargin = 0;
640      }
641      var liWidth = parseFloat($(childBox).width()) + childMargin; //30是margin
642      if (tabStatus) {
643        $(childBox).removeClass("cur");
644        if (Lstautus) {
645          $(childBox)
646            .eq(Num - 1)
647            .addClass("cur");
648        } else {
649          $(childBox)
650            .eq(Num - 2)
651            .addClass("cur");
652        }
653        tabStatus = false;
654        Lstautus = false;
655        return;
656      }
657      if (leftLen == -liWidth) {
658        tabStatus = true;
659        Lstautus = true;
660        $(childBox).removeClass("cur");
661        $(childBox)
662          .eq(Num - 2)
663          .addClass("cur");
664        return;
665      }
666      CurDom.next().addClass("cur").prev().removeClass("cur");
667    }
668    // 左按钮
669    // 添加三个变量12.10
670    var tmr;
671    var tml;
672    var t;
673    var bj;
674    if (type === "left") {
675      bj = false;
676    } else {
677      bj = true;
678    }
679    if (banBtnL) {
680      banBtnL.click(function () {
681        clearInterval(t);
682        clearInterval(tmr);
683        clearInterval(tml);
684        movel();
685        tml = setInterval(movel, moveTime);
686        bj = false;
687      });
688    }
689    // 右按钮
690    if (banBtnR) {
691      banBtnR.click(function () {
692        clearInterval(t);
693        clearInterval(tml);
694        clearInterval(tmr);
695        mover();
696        tmr = setInterval(mover, moveTime);
697        bj = true;
698      });
699    }
700    // 定时器
701    if (type === "left") {
702      t = setInterval(movel, moveTime);
703    } else {
704      t = setInterval(mover, moveTime);
705    }
706    // 对banner定时器的操作
707    banBox.parent().hover(
708      function () {
709        clearInterval(t);
710        clearInterval(tml);
711        clearInterval(tmr);
712      },
713      function () {
714        if (bj === false) {
715          t = setInterval(movel, moveTime);
716        } else {
717          t = setInterval(mover, moveTime);
718        }
719      }
720    );
721  }
722
723  /*
724    * tab切换
725    *jQuery(".news-tab-header li").tabPanelFun({
726      cur:'cur',   鼠标经过选项添加的类
727      tabContent:'.news-tab-lists', tab切换内容的最外层容器,是news-tab-header的兄弟元素
728      tabItem:'.news-tab-item'   tab切换内容里的子元素(即要切换内容)
729      pra:默认false,如果tab的选项按钮是多层次的就选ture
730      pradom 深层次的最父级元素
731      evnets 点击事件或者其他事件evnets:'click',默认mouseenter
732    })
733    *
734    *
735   */
736  function tabPanelFun(option) {
737    var $panel = option._this,
738      cur = option.cur ? option.cur : null,
739      pra = option.pra ? option.pra : false,
740      pradom = option.pradom ? option.pradom : null,
741      tabContent = option.tabContent ? option.tabContent : null,
742      tabItem = option.tabItem ? option.tabItem : null,
743      ev = option.evnets ? option.evnets : "mouseenter";
744    var tabItemdu = $(tabContent).find(tabItem);
745    $panel.eq(0).addClass(cur);
746    //$(tabItemdu).hide();
747    //$(tabItemdu).eq(0).show();
748    $panel.on(ev, function () {
749      var index = $(this).parent().children($panel.selector).index(this);
750      if (pra === true) {
751        jQuery(this)
752          .parents(pradom)
753          .siblings(tabContent)
754          .children(tabItemdu)
755          .eq(index)
756          .show()
757          .siblings()
758          .hide();
759      } else {
760        jQuery(this)
761          .parent()
762          .siblings(tabContent)
763          .children(tabItemdu)
764          .eq(index)
765          .show()
766          .siblings()
767          .hide();
768      }
769      jQuery(this).addClass(cur).siblings($panel.selector).removeClass(cur);
770    });
771  }
772  /**
773   * [dropDownFun description]
774   * tagSiblings:.drop-down .tag的兄弟元素
775   * optionItem:下拉子选项
776   * optionBool:是否是获取当前元素的值给.tag元素,默认是fasle(默认)当前元素,true是子元素
777   * cur:当前添加的样式,不传递默认为空
778   * @return {[type]}        [description]
779   */
780  function dropDownFun(option) {
781    var $label = option._this,
782      cur = option.cur ? option.cur : "",
783      $tagSiblings = option.tagSiblings,
784      $optionBool = option.optionBool ? option.optionBool : false,
785      $optionItem = option.optionItem;
786    $label.each(function () {
787      $(this).on("click", function (e) {
788        var ev = e || window.event;
789        if (ev.stopPropagation) {
790          ev.stopPropagation();
791        } else {
792          ev.cancelBubble = true;
793        }
794        var index = $label.index($(this));
795        $(this).stop().toggleClass(cur).siblings($tagSiblings).slideToggle();
796        for (var i = 0, max = $label.length; i < max; i++) {
797          if (index !== i)
798            $label
799              .eq(i)
800              .stop()
801              .removeClass(cur)
802              .siblings($tagSiblings)
803              .slideUp();
804        }
805      });
806    });
807    $(document).on("click", $optionItem, function () {
808      // 注意是获取当前元素还是子元素
809      var text =
810        $optionBool === false ? $(this).children().text() : $(this).text();
811      $(this).parents($tagSiblings).siblings($label).text(text);
812    });
813    $(document).on("click", function () {
814      $label.stop().removeClass(cur).siblings($tagSiblings).slideUp();
815    });
816  }
817  // 多行文字超出用省略号显示
818  function overEllipsis(option) {
819    var $list = option._this,
820      maxCount = option.maxCount;
821    $list.each(function (index, item) {
822      var itemString = $(item).text();
823      if (itemString.length > maxCount) {
824        $(item).html(itemString.substring(0, maxCount) + "...");
825      }
826    });
827  }
828  //echart初始化
829  function initEchart(option) {
830    var $id = option._this,
831      toption = option.echartoption;
832    var myChart = echarts.init($id[0]);
833    myChart.setOption(toption);
834  }
835  //尾部下拉
836  function dropDownImgText(option) {
837    var tag = option.tag,
838      cont = option._this,
839      text = option.text,
840      arrow = option.arrow,
841      drop = option.drop,
842      label = option.label,
843      event = option.event || "click",
844      cur = option.cur || "cur";
845    $(cont).each(function (index, item) {
846      $(item)
847        .children(tag)
848        .on(event, function (e) {
849          e = e || event;
850          e.stopPropagation();
851          var _thi = $(this);
852          $(this).parent().siblings(cont).children(drop).slideUp();
853          $(this)
854            .parent()
855            .siblings(cont)
856            .children(tag)
857            .children()
858            .children(arrow)
859            .removeClass(cur);
860          $(document).on(event, function () {
861            _thi.siblings().slideUp();
862            _thi.children().children(arrow).removeClass(cur);
863          });
864          if ($(this).siblings().css("display") === "block") {
865            $(this).children().children(arrow).removeClass(cur);
866            $(this).siblings().slideUp();
867            return;
868          } else {
869            $(this).children().children(arrow).addClass(cur);
870            $(this).siblings().slideDown();
871            $(this)
872              .siblings()
873              .find(label)
874              .on(event, function (e) {
875                e = e || event;
876                _thi.children().children(arrow).removeClass(cur);
877                _thi.children(text).text($(this).text());
878                _thi.siblings().slideUp();
879                e.stopPropagation();
880              });
881            return;
882          }
883        });
884    });
885  }
886  //tab切换
887  function tabSwitch(option) {
888    var items = $(option._this),
889      event = option.event || "mouseover",
890      cur = option.cur || "cur",
891      tabHead = option.tabHead,
892      tabCont = option.tabCont;
893    items.each(function (index, item) {
894      var btns = $(item).find(tabHead);
895      var cons = $(item).find(tabCont);
896      $(btns).eq(0).addClass(cur);
897      $(cons).hide();
898      $(cons).eq(0).show();
899      $(btns).on(event, function () {
900        $(this).addClass(cur).siblings().removeClass(cur);
901        $(cons).eq($(btns).index(this)).show().siblings().hide();
902      });
903    });
904  }
905  /*
906   *联动图片播放
907   *大图图片数量和图片列表的图片数量要一致
908   *option参数说明:没有特殊说明类型则为string
909   *prev: 大图的向前播放按钮,
910   *next: 大图的向后播放按钮,
911   *ptNext: 图片列表向后播放按钮,
912   *ptPrev: 图片列表向前播放按钮,
913   *banner: 大图播放项,
914   *text: 大图文字项,
915   *link: 小图列表项,
916   *linkSpace: 类型 number 小图之间的间距, 默认0
917   *linkType: 小图移动的方向,默认: top
918   *type: 大图切换方向top或left,默认:left
919   *autoPlay 类型 boolean 是否轮播,默认:true;
920   *playTime 类型 number 自动播放时间,默认:4000;
921   *direction 大图自动播放的顺序  默认:next;
922   *time  类型 number  切换过渡时间,默认:300;
923   *cur 小图的效果类名, 默认: 'cur'
924   */
925  function linkSwitch(option) {
926    var $banner = option._this ? $(option._this) : null,
927      $link = option.link ? $(option.link) : null,
928      $text = option.text ? $(option.text) : null;
929    var playTime = option.playTime || 4000,
930      linkSpace = option.linkSpace || 0,
931      direction = option.direction || "next",
932      linkType = option.linkType || "top",
933      type = option.type ? option.type : "left",
934      autoPlay = option.autoPlay ? option.autoPlay : true,
935      time = option.time || 300,
936      cur = option.cur || "cur";
937    var unit =
938        type === "top" ? $banner.parent().height() : $banner.parent().width(),
939      match =
940        linkType === "top"
941          ? $link.height() + linkSpace
942          : $link.width() + linkSpace,
943      len = $banner ? $banner.length : 0,
944      index = 0,
945      css = {},
946      cssLink = {};
947
948    init();
949
950    if (autoPlay) {
951      var play = setInterval(bannerPlay, playTime);
952      $banner.hover(
953        function () {
954          clearInterval(play);
955          play = null;
956        },
957        function () {
958          play = setInterval(bannerPlay, playTime);
959        }
960      );
961    }
962
963    if ($link) {
964      $link.click(function () {
965        if ($banner.is(":animated")) return;
966        if ($link.is(":animated")) return;
967        index = $(this).index();
968        configShow();
969        index = index < 0 ? len - 1 : index;
970        $(this).addClass(cur).siblings().removeClass(cur);
971        move();
972      });
973    }
974
975    function init() {
976      $banner.eq(index).show().siblings().hide();
977      $link.each(function () {
978        var _i = $(this).index();
979        $(this).show();
980        cssLink[linkType] = (_i - index) * match;
981        $(this).css(cssLink);
982      });
983      configShow();
984    }
985
986    function bannerPlay() {
987      if ($banner.is(":animated")) return;
988      index++;
989      index = index >= len ? 0 : index;
990      move();
991      configShow();
992      linkPlay();
993    }
994
995    function move() {
996      $banner.eq(index).fadeIn(time).siblings().fadeOut(time);
997    }
998
999    function linkPlay() {
1000      for (var i = 0; i < len; i++) {
1001        var $item = $link.eq(i);
1002        var type = linkType;
1003        if ($item.position()[type] <= -match) {
1004          var perLeft = 0;
1005          if (i === 0) {
1006            perLeft = $link.eq(len - 1).position()[type];
1007          } else {
1008            perLeft = $link.eq(i - 1).position()[type];
1009          }
1010          cssLink[type] = perLeft + match;
1011          $item.css(cssLink);
1012        }
1013        var nowLeft = $item.position()[type];
1014        cssLink[type] = nowLeft - match;
1015        $item.animate(cssLink, time);
1016      }
1017    }
1018
1019    function configShow() {
1020      if ($text) {
1021        $text.eq(index).show().siblings().hide();
1022      }
1023      $link.eq(index).addClass(cur).siblings().removeClass(cur);
1024    }
1025  }
1026  /****
1027   * 回到顶部
1028   */
1029  function goBack(option) {
1030    var $banner = option._this ? $(option._this) : null;
1031    $banner.click(function () {
1032      $("html,body").animate({ scrollTop: 0 }, 500);
1033    });
1034    $(window).scroll(function () {
1035      var gun = $(document).scrollTop();
1036      if (gun <= 400) {
1037        if (option.isShow) {
1038          $banner.hide();
1039        }
1040      } else {
1041        $banner.show();
1042      }
1043    });
1044  }
1045  /****
1046   * 左右浮动(广告弹窗)
1047   * direction(left right)必填
1048   */
1049  function floatLR(option) {
1050    var $banner = option._this ? $(option._this) : null,
1051      direction = option.direction;
1052    var margin_dis =
1053      (parseInt($(document.body).width()) - 1200) / 2 + 1200 + 30 + "px";
1054    $banner.css(direction, margin_dis);
1055    $(window).resize(function () {
1056      if (parseInt($(window).width()) < 1480) {
1057        margin_dis = parseInt($(window).width()) - 100 + "px";
1058      } else {
1059        margin_dis =
1060          (parseInt($(document.body).width()) - 1200) / 2 + 1200 + 30 + "px";
1061      }
1062      $banner.css(direction, margin_dis);
1063    });
1064  }
1065
1066  $.fn.extend({
1067    SwitchFade: function (option) {
1068      var opt = option || {};
1069      opt._this = $(this);
1070      SwitchFade(opt);
1071    },
1072    simpleSwitch: function (option) {
1073      var opt = option || {};
1074      opt._this = $(this);
1075      simpleSwitch(opt);
1076    },
1077    simpleRoll: function (optioin) {
1078      var option = optioin || {};
1079      option._this = $(this);
1080      simpleRoll(option);
1081    },
1082    rollImages: function (optioin) {
1083      var option = optioin || {};
1084      option._this = $(this);
1085      rollImages(option);
1086    },
1087    bannerRollLR: function (optioin) {
1088      var option = optioin || {};
1089      option._this = $(this);
1090      bannerRollLR(option);
1091    },
1092    tabPanelFun: function (optioin) {
1093      var option = optioin || {};
1094      option._this = $(this);
1095      tabPanelFun(option);
1096    },
1097    dropDownFun: function (optioin) {
1098      var option = optioin || {};
1099      option._this = $(this);
1100      dropDownFun(option);
1101    },
1102    overEllipsis: function (optioin) {
1103      var option = optioin || {};
1104      option._this = $(this);
1105      overEllipsis(option);
1106    },
1107    initEchart: function (optioin) {
1108      var option = optioin || {};
1109      option._this = $(this);
1110      initEchart(option);
1111    },
1112    dropDownImgText: function (optioin) {
1113      var option = optioin || {};
1114      option._this = $(this);
1115      dropDownImgText(option);
1116    },
1117    tabSwitch: function (optioin) {
1118      var option = optioin || {};
1119      option._this = $(this);
1120      tabSwitch(option);
1121    },
1122    linkSwitch: function (optioin) {
1123      var option = optioin || {};
1124      option._this = $(this);
1125      linkSwitch(option);
1126    },
1127    goBack: function (optioin) {
1128      var option = optioin || {};
1129      option._this = $(this);
1130      goBack(option);
1131    },
1132    floatLR: function (optioin) {
1133      var option = optioin || {};
1134      option._this = $(this);
1135      floatLR(option);
1136    },
1137    rowsCentered: function (optioin) {
1138      var option = optioin || {};
1139      option._this = $(this);
1140      rowsCentered(option);
1141    },
1142    swiperInit: function (optioin) {
1143      var option = optioin || {};
1144      option._this = $(this);
1145      swiperInit(option);
1146    },
1147    boxReSizeToWap: function (optioin) {
1148      var option = optioin || {};
1149      option._this = $(this);
1150      boxReSizeToWap(option);
1151    },
1152    swiperTo: function (index) {
1153      swiperTo(index);
1154    },
1155  });
1156})(jQuery);
1157
1158if (typeof exports === "object") {
1159  module.exports = jQuery;
1160}
1161
1162/**
1163 * 多行文本竖直方向居中
1164 * @param options
1165 */
1166function rowsCentered(options) {
1167  var items = $(options._this);
1168  items.each(function () {
1169    var _this = $(this);
1170    _this.css({
1171      position: "absolute",
1172      top: "50%",
1173      marginTop: -_this.height() / 2
1174    });
1175    _this.parent().css({ position: "relative" });
1176  });
1177}
1178
1179/**
1180 * 公共轮播组件
1181 * @param SwiperNums number //swiper被调用的次数类型
1182 * @param swiperObject object  //swiper的所有实例
1183 * @param options参数说明:
1184 * @param type number //swiper类型 1, 2, 3, 4
1185 * @param loop boolean //是否循环轮播
1186 * @param spped number //轮播滑动速度
1187 * @param grabCursor boolean //是否支持手滑
1188 * @param paginationClickable boolean //是否可以点击分页切换
1189 * @param calculateHeight boolean //是否根据内容自动计算高度
1190 * @param autoplayDisableOnInteraction boolean //是否手动切换之后暂停轮播
1191 * @param slidesPerView number //屏幕显示的盒子个数
1192 * @param slidesPerGroup number //轮播每次滚动的盒子个数
1193 * @param slidesPerViewByWap number //h5轮播屏幕显示的盒子个数
1194 * @param slidesPerGroupByWap number //h5轮播每次滚动的盒子个数
1195 * @param tdFlow boolean //是否展示3d效果
1196 * @param btnAside boolean //是否需要添加按钮靠边样式
1197 *
1198 */
1199var SwiperNums = 0,
1200  swiperObject = {};
1201function swiperInit(options) {
1202  var items = $(options._this);
1203  SwiperNums++;
1204  var swiper = "swiper_" + SwiperNums;
1205  options.swiper = swiper;
1206  switch (options.type) {
1207    case 1:
1208      swiper1(options, items);
1209      break;
1210    case 2:
1211      swiper2(options, items);
1212      break;
1213    case 3:
1214      swiper3(options, items);
1215      break;
1216    case 4:
1217      swiper4(options, items);
1218      break;
1219    default:
1220      swiper1(options, items);
1221  }
1222}
1223function swiperTo(index) {
1224  console.log(index)
1225  swiperObject[index].swipePrev();
1226}
1227
1228/**
1229 * 第一种轮播:只显示一张图和文字,循环轮播
1230 * @param options
1231 * @param _this
1232 */
1233function swiper1(options, _this) {
1234  var swiper = options.swiper,
1235    swiperPagination;
1236  _this.attr("id", swiper).addClass("SWIPER-1");
1237  if ($("#" + swiper + " .pagination").length == 0) {
1238    swiperPagination = "";
1239  } else {
1240    swiperPagination = "#" + swiper + " .pagination";
1241  }
1242  swiperObject[swiper] = new Swiper("#" + swiper + " .swiper-container", {
1243    pagination: swiperPagination,
1244    loop: options.loop != undefined ? options.loop : true,
1245    speed: options.speed != undefined ? options.speed : 500,
1246    autoplay: options.autoplay != undefined ? options.autoplay : 3000,
1247    grabCursor: options.grabCursor != undefined ? options.grabCursor : false,
1248    paginationClickable:
1249      options.paginationClickable != undefined
1250        ? options.paginationClickable
1251        : true,
1252    autoplayDisableOnInteraction: false
1253  });
1254  _this.find(".arrow-left").on("click", function (e) {
1255    e.preventDefault();
1256    swiperObject[swiper].swipePrev();
1257  });
1258  _this.find(".arrow-right").on("click", function (e) {
1259    e.preventDefault();
1260    swiperObject[swiper].swipeNext();
1261  });
1262}
1263
1264/**
1265 * 第一种轮播:多个盒子连续滚动切换,默认切换一整屏内容,循环轮播
1266 * @param options
1267 * @param _this
1268 */
1269function swiper2(options, _this) {
1270  var swiper = options.swiper,
1271    swiperPagination;
1272  var slidesPerView = options.slidesPerView;
1273  var slidesPerGroup = options.slidesPerGroup;
1274  _this.attr("id", swiper).addClass("SWIPER-2");
1275  if ($(window).width() < 768) {
1276    $("#" + swiper)
1277      .parent()
1278      .css({ width: "100%" });
1279    slidesPerView =
1280      options.slidesPerViewByWap != undefined ? options.slidesPerViewByWap : 1;
1281    slidesPerGroup =
1282      options.slidesPerGroupByWap != undefined
1283        ? options.slidesPerGroupByWap
1284        : 1;
1285    options.tdFlow = "";
1286  } else if ($(window).width() >= 768 && $(window).width() < 1200) {
1287    // ipad
1288    slidesPerView = 3;
1289    slidesPerGroup =
1290      options.slidesPerGroup != undefined ? options.slidesPerGroup : 3;
1291  } else {
1292    slidesPerView =
1293      options.slidesPerView != undefined ? options.slidesPerView : 4;
1294    slidesPerGroup =
1295      options.slidesPerGroup != undefined ? options.slidesPerGroup : 1;
1296  }
1297  if ($("#" + swiper + " .pagination").length == 0) {
1298    swiperPagination = "";
1299  } else {
1300    swiperPagination = "#" + swiper + " .pagination";
1301  }
1302  swiperObject[swiper] = new Swiper("#" + swiper + " .swiper-container", {
1303    pagination: swiperPagination,
1304    loop: options.loop != undefined ? options.loop : true,
1305    speed: options.speed != undefined ? options.speed : 500,
1306    autoplay: options.autoplay != undefined ? options.autoplay : 3000,
1307    grabCursor: options.grabCursor != undefined ? options.grabCursor : false,
1308    calculateHeight: true,
1309    paginationClickable: true,
1310    slidesPerView: slidesPerView,
1311    slidesPerGroup: slidesPerGroup,
1312    centerInsufficientSlides: true,
1313    autoplayDisableOnInteraction: false,
1314    tdFlow: options.tdFlow != undefined ? options.tdFlow : "",
1315    touchRatio: 0.5
1316  });
1317  $(window).resize(function () {
1318    swiperResize(swiperObject[swiper]);
1319  });
1320  function swiperResize(mySwiper2) {
1321    var width = $(window).width();
1322    if (width >= 768 && width < 1200) {
1323      // ipad
1324      slidesPerView = 3;
1325      slidesPerGroup =
1326        mySwiper2.params.slidesPerGroup != undefined
1327          ? mySwiper2.params.slidesPerGroup
1328          : 3;
1329    } else if (width >= 1200) {
1330      // pc
1331      slidesPerView =
1332        mySwiper2.params.slidesPerView != undefined
1333          ? mySwiper2.params.slidesPerView
1334          : 4;
1335      slidesPerGroup =
1336        mySwiper2.params.slidesPerGroup != undefined
1337          ? mySwiper2.params.slidesPerGroup
1338          : 1;
1339    } else {
1340      //wap
1341      $("#" + swiper)
1342        .parent()
1343        .css({ width: "100%" });
1344      slidesPerView =
1345        mySwiper2.params.slidesPerViewByWap != undefined
1346          ? mySwiper2.params.slidesPerViewByWap
1347          : 1;
1348      slidesPerGroup =
1349        mySwiper2.params.slidesPerGroupByWap != undefined
1350          ? mySwiper2.params.slidesPerGroupByWap
1351          : 1;
1352      mySwiper2.params.tdFlow = "";
1353    }
1354    if (typeof mySwiper2 != "undefined") {
1355      mySwiper2.params.slidesPerView = slidesPerView;
1356      mySwiper2.params.slidesPerGroup = slidesPerGroup;
1357      mySwiper2.reInit();
1358    }
1359    reAside(options, mySwiper2);
1360  }
1361  _this.find(".arrow-left").on("click", function (e) {
1362    e.preventDefault();
1363    swiperObject[swiper].swipePrev();
1364  });
1365  _this.find(".arrow-right").on("click", function (e) {
1366    e.preventDefault();
1367    swiperObject[swiper].swipeNext();
1368  });
1369  var _this_swiper = $("#" + swiper);
1370
1371  reAside(swiperObject[swiper]);
1372  function reAside(_options, mySwiper2) {
1373    //如果按钮靠边,更改整体swiper-slide样式
1374    if (!_options.btnAside) {
1375      return;
1376    }
1377    var style_str = "";
1378    if (mySwiper2.params.slidesPerView == 3) {
1379      style_str =
1380        "<style>" +
1381        "#" +
1382        swiper +
1383        " .swiper-slide-active img { margin-left: -2.5%} " +
1384        "#" +
1385        swiper +
1386        " .swiper-slide-active + div img { margin-left: 1.5%} " +
1387        "#" +
1388        swiper +
1389        " .swiper-slide-active + div + div img { margin-left: 5.5% }" +
1390        "#" +
1391        swiper +
1392        " .swiper-slide-active p { margin-left: -2.5%} " +
1393        "#" +
1394        swiper +
1395        " .swiper-slide-active + div p { margin-left: 1.5%} " +
1396        "#" +
1397        swiper +
1398        " .swiper-slide-active + div + div p { margin-left: 5.5% }" +
1399        "</style>";
1400      // _this_swiper.find('.swiper-slide-active img').css({marginLeft: '-3%'});
1401      // _this_swiper.find('.swiper-slide-active').next().next().find('img').css({marginLeft: '2%'})
1402    } else if (mySwiper2.params.slidesPerView == 4) {
1403      style_str =
1404        "<style>" +
1405        "#" +
1406        swiper +
1407        " .swiper-slide-active img { margin-left: -2.5%} " +
1408        "#" +
1409        swiper +
1410        " .swiper-slide-active + div img { margin-left: 0 } " +
1411        "#" +
1412        swiper +
1413        " .swiper-slide-active + div + div img { margin-left: 2.5% } " +
1414        "#" +
1415        swiper +
1416        " .swiper-slide-active + div + div + div img { margin-left: 5.5% } " +
1417        "#" +
1418        swiper +
1419        " .swiper-slide-active p { margin-left: -2.5%} " +
1420        "#" +
1421        swiper +
1422        " .swiper-slide-active + div p { margin-left: 0 } " +
1423        "#" +
1424        swiper +
1425        " .swiper-slide-active + div + div p { margin-left: 2.5% } " +
1426        "#" +
1427        swiper +
1428        " .swiper-slide-active + div + div + div p { margin-left: 5.5% } " +
1429        "</style>";
1430      // _this_swiper.find('.swiper-slide-active img').css({marginLeft: '-2.5%'});
1431      // _this_swiper.find('.swiper-slide-active').next().find('img').css({marginLeft: '-2.5%'});
1432      // _this_swiper.find('.swiper-slide-active').next().next().find('img').css({marginLeft: '-1.7%'});
1433      // _this_swiper.find('.swiper-slide-active').next().next().next().find('img').css({marginLeft: '-1.6%'});
1434      // _this_swiper.find('.swiper-slide-active').next().next().next().next().find('img').css({marginRight: '-2.5%'});
1435    }
1436    if ($("#" + swiper + "_style").length == 0) {
1437      $("body").append('<div id="' + swiper + '_style"></div>');
1438    }
1439    $("#" + swiper + "_style").html(style_str);
1440  }
1441}
1442
1443/**
1444 * 第三种轮播:内容自定义
1445 * @param options
1446 * @param _this
1447 */
1448function swiper3(options, _this) {
1449  var swiper = options.swiper,
1450    swiperPagination;
1451  _this.attr("id", swiper).addClass("SWIPER-3");
1452  if ($("#" + swiper + " .pagination").length == 0) {
1453    swiperPagination = "";
1454  } else {
1455    swiperPagination = "#" + swiper + " .pagination";
1456  }
1457  swiperObject[swiper] = new Swiper("#" + swiper + " .swiper-container", {
1458    pagination: swiperPagination,
1459    loop: options.loop != undefined ? options.loop : true,
1460    speed: options.speed != undefined ? options.speed : 500,
1461    autoplay: options.autoplay != undefined ? options.autoplay : 3000,
1462    grabCursor: options.grabCursor != undefined ? options.grabCursor : false,
1463    paginationClickable:
1464      options.paginationClickable != undefined
1465        ? options.paginationClickable
1466        : true,
1467    autoplayDisableOnInteraction: false
1468  });
1469  _this.find(".arrow-left").on("click", function (e) {
1470    e.preventDefault();
1471    swiperObject[swiper].swipePrev();
1472  });
1473  _this.find(".arrow-right").on("click", function (e) {
1474    e.preventDefault();
1475    swiperObject[swiper].swipeNext();
1476  });
1477}
1478
1479/**
1480 *将基于1200px的盒子在小于768px以下,进行同比例缩放
1481 */
1482function boxReSizeToWap(options) {
1483  var _this = $(options._this);
1484  if ($(window).width() > 768) {
1485    return;
1486  }
1487  var boxWidth = parseInt(_this.width());
1488  var size = (boxWidth * 2) / 1200;
1489  _this.css("transform", "scale(" + size + ")").css("transform-origin", "0 0");
1490}
1491
1492/**
1493 *将基于1200px的页面在小于768px以下,进行同比例缩放
1494 */
1495function pageReSizeToWap() {
1496  if ($(window).width() > 768) {
1497    return;
1498  }
1499  var viewport = document.querySelector("meta[name=viewport]");
1500  if (!viewport) {
1501    $("head").append(
1502      '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">'
1503    );
1504  }
1505  if (!document.querySelector("meta[http-equiv]")) {
1506    $("head").append('<meta http-equiv="X-UA-Compatible" content="ie=edge">');
1507  }
1508  var viewport = document.querySelector("meta[name=viewport]");
1509  var winWidth = $(window).width();
1510  var winHeight = $("body").height();
1511  var size = winWidth / 1200;
1512  $(
1513    " body, footer, footer .foot-top, footer .foot-bottom, footer .foot-top .foot-t-cont"
1514  ).css({ width: "12rem" });
1515  $("html").css({
1516    "font-size": "100px",
1517    transform: "scale(" + size + ")",
1518    "transform-origin": "0 0",
1519    width: "12rem",
1520    height: winHeight * size + "px"
1521  });
1522}
1523
1524/**
1525 * 点击图标回到顶部
1526 * @Author: Mr.Hu
1527 * @Date: 2020-12-17 22:20
1528 * @Last Modified by: Mr.Hu
1529 * @Last Modified time: 2020-12-17 22:20
1530 */
1531(function () {
1532  var scrollDom = $(".SCROLLTOP");
1533  if (scrollDom.length < 1) {
1534    return;
1535  }
1536  // $('body').append('<div class="SCROLLTOP"><img src="/images/scrollTop.png"></div>');
1537  $("body").on("click", ".SCROLLTOP", function () {
1538    $("html,body").animate({ scrollTop: 0 }, 500, "swing");
1539  });
1540  $(window).scroll(function () {
1541    var scrollTop = $(document).scrollTop();
1542    if (scrollTop <= 400) {
1543      $(".SCROLLTOP").fadeOut();
1544    } else {
1545      $(".SCROLLTOP").fadeIn();
1546    }
1547  });
1548})();
1549
1550/**
1551 * 敲击键盘事件
1552 *  obj  Object
1553 *       el       String   css选择 器默认为 document
1554 *       keyCode  Number   键盘码 默认是回车键
1555 *       showCode Boolean  控制台打打印所按键盘的键码 默认不打印
1556 *       callBack Function 按下对应键盘所有处理的业务逻辑
1557 * */
1558
1559function keyboardEv(obj) {
1560  var dName = obj.el || document,
1561    keyCode = obj.keyCode || 13;
1562  $(dName).on("keypress", function (e) {
1563    obj.showCode && console.log(obj.showCode);
1564    if (e.keyCode == keyCode) {
1565      obj.callBack && obj.callBack();
1566    }
1567  });
1568}
1569
1570/**
1571 * ajax 网络请求
1572 * @param resUrl 请求地址
1573 * @param type 请求类型
1574 * @param url 请求地址
1575 * @param param 请求参数
1576 * @param callback回调函数
1577 */
1578var resUrl = {};
1579var baseUrl = "http://www.cq.gov.cn/";
1580resUrl.getZCJJUrl = "govserver/tors/businessEnv/zh/policy/highlight.html"; //获取政策直通车-政策集锦数据
1581
1582function sendAjax(type, url, param, callback) {
1583  $.ajax({
1584    type: type,
1585    url: baseUrl + url,
1586    data: param,
1587    success: callback,
1588    error: function (res) {
1589      console.log(res);
1590    }
1591  });
1592}
1593
1594/**建行接口请求的封装参考渝快办建行ajax
1595 * obj
1596 *     body // 实体信息
1597 *     page //  分页信息
1598 *           // pageIndex 当前页
1599 *           // pageSize  每页条数
1600 *     success  成功之后的回调
1601 * */
1602function jhAJAX(obj) {
1603  // todo item.DEPTNAME 区划编码  item.AREACODE == 5 属于街镇
1604  var op = packPayload(obj.body, obj.page);
1605
1606  $.ajax({
1607    url: obj.url, //self.BASEURL +
1608    type: obj.method || "post",
1609    headers: { "Content-Type": "application/json" },
1610    data: JSON.stringify(op),
1611    dataType: "text",
1612    success: function (res) {
1613      res = JSON.parse(res);
1614      if (res["C-Response-Desc"] == "success") {
1615        res = JSON.parse(res["C-Response-Body"]);
1616        obj.success(res);
1617      } else {
1618        console.log("服务出错");
1619      }
1620    },
1621    error: function (err) {
1622      console.log("网络错误");
1623    }
1624  });
1625}
1626
1627/**
1628 * @param payload 请求的data {}
1629 * @param page 请求的数据的分页
1630 * @param headers 请求头
1631 */
1632function packPayload(payload, page) {
1633  // 默认请求域需要带的参数
1634  var txnCommCom = {
1635    txnIttChnlId: "C0071234567890987654321",
1636    txnIttChnlCgyCode: "BC01C101"
1637  };
1638
1639  // 如果有分页,组装分页
1640  if (page) {
1641    txnCommCom.tRecInPage = page.pageSize; // 分页数量
1642    txnCommCom.tPageJump = page.pageIndex; // 分页页码
1643  }
1644
1645  var payload2 = {};
1646  for (var i in payload) {
1647    //for in 会遍历对象的属性,包括实例中和原型中的属性。(
1648    payload2[i] = payload[i];
1649  }
1650  return {
1651    txnCommCom: txnCommCom,
1652    txnBodyCom: payload2
1653  };
1654}

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.