| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- // tab切换
- function foo(top,a,box,b,class1,class2){
- var top = document.getElementById(top);
- var a = top.getElementsByTagName(a);
- var box = document.getElementById(box);
- var b = box.getElementsByTagName(b);
-
- for(var i=0;i<a.length;i++){
- a[i].index = b[i].index = i;
- a[i].onmouseenter = function(){
- for(var i=0;i<b.length;i++){
- a[i].className = '';
- b[i].className = '';
- }
- this.className = class1;
- b[this.index].className = class2;
- }
- }
- }
- // 搜索页功能
- $(function(){
- $(".more").click(function(){
- $(this).parents("dl").height(71);
- });
- $(".unfold").click(function(){
- $(this).parents("li").find(".specific").slideToggle();
- });
-
- // 锚链接平滑效果
- $('a[href*=#],area[href*=#]').click(function() {
- if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
- var $target = $(this.hash);
- $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
- if ($target.length) {
- var targetOffset = $target.offset().top;
- $('html,body').animate({
- scrollTop: targetOffset
- },
- 1000);
- return false;
- }
- }
- });
- // 十大品牌
- $(".section1_right ul li").mouseover(function(){
- $(this).addClass("ph_active").siblings().removeClass("ph_active");
- });
-
- // 锚链接平滑效果
- $('a[href*=#],area[href*=#]').click(function() {
- if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
- var $target = $(this.hash);
- $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
- if ($target.length) {
- var targetOffset = $target.offset().top;
- $('html,body').animate({
- scrollTop: targetOffset
- },
- 1000);
- return false;
- }
- }
- });
- })
- // 自适应高度
- function adaptHeight(id,tag){
- var ids = document.getElementById(id);
- var tags = ids.getElementsByTagName(tag);
- for(var i=0;i<tags.length;i++){
- var height = tags[i].children[1].offsetHeight;
- tags[i].style.height = Number(height) + 40 + "px";
- tags[i].style.lineHeight = Number(height) + 40 + "px";
- }
- };
- // 图片自适应裁剪
- function adaptImg(image){
- var imgs = document.querySelectorAll(".image img");
- for(var i=0;i<imgs.length;i++){
- imgs[i].style.marginTop = "-" + imgs[i].offsetWidth/2 + "px";
- imgs[i].style.marginLeft = "-" + imgs[i].offsetHeight/2 + "px";
- imgs[i].style.top = "50%";
- imgs[i].style.left = "50%";
- }
- }
- // 小圆点轮播
- function plays(id){
- var h0 = null,
- index0 = 0,
- $items0 = $(id+' .item'),
- len0 = $items0.length;
- for(var i=0;i<len0;i++){
- $(id+'>ul').append('<li></li>');
- }
- var $lis0 = $(id+'>ul>li');
- //$lis.first().addClass('active');
- $lis0.mouseover(function(){
- index0= $.inArray(this,$lis0);
- //$('.shouye>.item').hide();
- //$('.shouye>.item:eq('+index+')').show();
- play0();
- });
- $(id).hover(function(){
- clearInterval(h0);
- },function(){
- start_timer0();
- })
- function start_timer0(){
- h0=setInterval(function(){
- index0++;
- if(index0==len0){
- index0=0;
- }
- play0();
-
- },2000);
- }
- function play0(){
- $items0.removeClass('active');
- $lis0.removeClass('active');
- var $c_item0=$items0.eq(index0),
- color1=$c_item0.data('color');
- $c_item0.closest('.con').css({background:color1});
- $items0.eq(index0).addClass('active');
- $lis0.eq(index0).addClass('active');
- }
- start_timer0();
- play0();
- }
- // plays("#id");
- // 滚动轮播
- function gund(id0,id1,id2){
- var speed = 30;
- var demo0 = document.getElementById(id0);
- var demo1 = document.getElementById(id1);
- var demo2 = document.getElementById(id2);
- demo2.innerHTML = demo1.innerHTML
- function Marquee1() {
- if (demo2.offsetWidth - demo0.scrollLeft <= 0) demo0.scrollLeft -= demo1.offsetWidth
- else demo0.scrollLeft++
- }
- var MyMar1 = setInterval(Marquee1, speed)
- demo0.onmouseover = function () { clearInterval(MyMar1) }
- demo0.onmouseout = function () { MyMar1 = setInterval(Marquee1, speed) }
- }
- // gund('demo0','demo1','demo2'); //方法
- // 大图轮播
- function big(photo,uls,left,right){
- var id = function(el) { return document.getElementById(el); } ,
- c = id(photo);
- if(c) {
- var ul = id(uls),
- lis = ul.getElementsByTagName('li'),
- itemCount = lis.length,
- width = lis[0].offsetWidth; //获得每个img容器的宽度
- //正方向轮播
- var marquee = function() {
- c.scrollLeft += 1920;
- ul.appendChild(ul.getElementsByTagName('li')[0]);
- c.scrollLeft=0;
- },
- //反方向轮播
- f_marquee=function(){
- c.scrollRight += 1920;
- ul.insertBefore(ul.getElementsByTagName('li')[1],ul.getElementsByTagName('li')[0]);
- c.scrollRight=0;
- }
- speed = 3000; //数值越大越慢
- ul.style.width = width*itemCount + 'px'; //加载完后设置容器长度
- //右按钮
- var r_lunbo=id(right);
- r_lunbo.onclick=function(){
- marquee();
- }
- //左按钮
- var l_lunbo=id(left);
- l_lunbo.onclick=function(){
- f_marquee();
- }
- //自动轮播
- var t = setInterval(marquee, speed);
- r_lunbo.onmouseover = function() {
- clearInterval(t);
- };
- r_lunbo.onmouseout = function() {
- speed = 2000;//数值越大越慢
- t = setInterval(marquee, speed);
- };
- l_lunbo.onmouseover = function() {
- clearInterval(t);
- };
- l_lunbo.onmouseout = function() {
- speed = 2000;//数值越大越慢
- t = setInterval(marquee, speed);
- };
- };
- }
- // big('photo-list','scroll','btn_left','btn_right'); //方法
- function uaredirect(f) {
- try {
- if (document.getElementById("bdmark") != null) {
- return
- }
- var b = false;
- if (arguments[1]) {
- var e = window.location.host;
- var a = window.location.href;
- if (isSubdomain(arguments[1], e) == 1) {
- f = f + "/#m/" + a;
- b = true
- } else {
- if (isSubdomain(arguments[1], e) == 2) {
- f = f + "/#m/" + a;
- b = true
- } else {
- f = a;
- b = false
- }
- }
- } else {
- b = true
- }
- if (b) {
- var c = window.location.hash;
- if (!c.match("fromapp")) {
- if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) {
- location.replace(f)
- }
- }
- }
- } catch (d) {
- }
- }
- function isSubdomain(c, d) {
- this.getdomain = function (f) {
- var e = f.indexOf("://");
- if (e > 0) {
- var h = f.substr(e + 3)
- } else {
- var h = f
- }
- var g = /^www\./;
- if (g.test(h)) {
- h = h.substr(4)
- }
- return h
- };
- if (c == d) {
- return 1
- } else {
- var c = this.getdomain(c);
- var b = this.getdomain(d);
- if (c == b) {
- return 1
- } else {
- c = c.replace(".", "\\.");
- var a = new RegExp("\\." + c + "$");
- if (b.match(a)) {
- return 2
- } else {
- return 0
- }
- }
- }
- };
- (function() {
- if (!
- /*@cc_on!@*/
- 0) return;
- var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video".split(', ');
- var i= e.length;
- while (i--){
- document.createElement(e[i])
- }
- })()
|