public.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // tab切换
  2. function foo(top,a,box,b,class1,class2){
  3. var top = document.getElementById(top);
  4. var a = top.getElementsByTagName(a);
  5. var box = document.getElementById(box);
  6. var b = box.getElementsByTagName(b);
  7. for(var i=0;i<a.length;i++){
  8. a[i].index = b[i].index = i;
  9. a[i].onmouseenter = function(){
  10. for(var i=0;i<b.length;i++){
  11. a[i].className = '';
  12. b[i].className = '';
  13. }
  14. this.className = class1;
  15. b[this.index].className = class2;
  16. }
  17. }
  18. }
  19. // 搜索页功能
  20. $(function(){
  21. $(".more").click(function(){
  22. $(this).parents("dl").height(71);
  23. });
  24. $(".unfold").click(function(){
  25. $(this).parents("li").find(".specific").slideToggle();
  26. });
  27. // 锚链接平滑效果
  28. $('a[href*=#],area[href*=#]').click(function() {
  29. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  30. var $target = $(this.hash);
  31. $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
  32. if ($target.length) {
  33. var targetOffset = $target.offset().top;
  34. $('html,body').animate({
  35. scrollTop: targetOffset
  36. },
  37. 1000);
  38. return false;
  39. }
  40. }
  41. });
  42. // 十大品牌
  43. $(".section1_right ul li").mouseover(function(){
  44. $(this).addClass("ph_active").siblings().removeClass("ph_active");
  45. });
  46. // 锚链接平滑效果
  47. $('a[href*=#],area[href*=#]').click(function() {
  48. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  49. var $target = $(this.hash);
  50. $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
  51. if ($target.length) {
  52. var targetOffset = $target.offset().top;
  53. $('html,body').animate({
  54. scrollTop: targetOffset
  55. },
  56. 1000);
  57. return false;
  58. }
  59. }
  60. });
  61. })
  62. // 自适应高度
  63. function adaptHeight(id,tag){
  64. var ids = document.getElementById(id);
  65. var tags = ids.getElementsByTagName(tag);
  66. for(var i=0;i<tags.length;i++){
  67. var height = tags[i].children[1].offsetHeight;
  68. tags[i].style.height = Number(height) + 40 + "px";
  69. tags[i].style.lineHeight = Number(height) + 40 + "px";
  70. }
  71. };
  72. // 图片自适应裁剪
  73. function adaptImg(image){
  74. var imgs = document.querySelectorAll(".image img");
  75. for(var i=0;i<imgs.length;i++){
  76. imgs[i].style.marginTop = "-" + imgs[i].offsetWidth/2 + "px";
  77. imgs[i].style.marginLeft = "-" + imgs[i].offsetHeight/2 + "px";
  78. imgs[i].style.top = "50%";
  79. imgs[i].style.left = "50%";
  80. }
  81. }
  82. // 小圆点轮播
  83. function plays(id){
  84. var h0 = null,
  85. index0 = 0,
  86. $items0 = $(id+' .item'),
  87. len0 = $items0.length;
  88. for(var i=0;i<len0;i++){
  89. $(id+'>ul').append('<li></li>');
  90. }
  91. var $lis0 = $(id+'>ul>li');
  92. //$lis.first().addClass('active');
  93. $lis0.mouseover(function(){
  94. index0= $.inArray(this,$lis0);
  95. //$('.shouye>.item').hide();
  96. //$('.shouye>.item:eq('+index+')').show();
  97. play0();
  98. });
  99. $(id).hover(function(){
  100. clearInterval(h0);
  101. },function(){
  102. start_timer0();
  103. })
  104. function start_timer0(){
  105. h0=setInterval(function(){
  106. index0++;
  107. if(index0==len0){
  108. index0=0;
  109. }
  110. play0();
  111. },2000);
  112. }
  113. function play0(){
  114. $items0.removeClass('active');
  115. $lis0.removeClass('active');
  116. var $c_item0=$items0.eq(index0),
  117. color1=$c_item0.data('color');
  118. $c_item0.closest('.con').css({background:color1});
  119. $items0.eq(index0).addClass('active');
  120. $lis0.eq(index0).addClass('active');
  121. }
  122. start_timer0();
  123. play0();
  124. }
  125. // plays("#id");
  126. // 滚动轮播
  127. function gund(id0,id1,id2){
  128. var speed = 30;
  129. var demo0 = document.getElementById(id0);
  130. var demo1 = document.getElementById(id1);
  131. var demo2 = document.getElementById(id2);
  132. demo2.innerHTML = demo1.innerHTML
  133. function Marquee1() {
  134. if (demo2.offsetWidth - demo0.scrollLeft <= 0) demo0.scrollLeft -= demo1.offsetWidth
  135. else demo0.scrollLeft++
  136. }
  137. var MyMar1 = setInterval(Marquee1, speed)
  138. demo0.onmouseover = function () { clearInterval(MyMar1) }
  139. demo0.onmouseout = function () { MyMar1 = setInterval(Marquee1, speed) }
  140. }
  141. // gund('demo0','demo1','demo2'); //方法
  142. // 大图轮播
  143. function big(photo,uls,left,right){
  144. var id = function(el) { return document.getElementById(el); } ,
  145. c = id(photo);
  146. if(c) {
  147. var ul = id(uls),
  148. lis = ul.getElementsByTagName('li'),
  149. itemCount = lis.length,
  150. width = lis[0].offsetWidth; //获得每个img容器的宽度
  151. //正方向轮播
  152. var marquee = function() {
  153. c.scrollLeft += 1920;
  154. ul.appendChild(ul.getElementsByTagName('li')[0]);
  155. c.scrollLeft=0;
  156. },
  157. //反方向轮播
  158. f_marquee=function(){
  159. c.scrollRight += 1920;
  160. ul.insertBefore(ul.getElementsByTagName('li')[1],ul.getElementsByTagName('li')[0]);
  161. c.scrollRight=0;
  162. }
  163. speed = 3000; //数值越大越慢
  164. ul.style.width = width*itemCount + 'px'; //加载完后设置容器长度
  165. //右按钮
  166. var r_lunbo=id(right);
  167. r_lunbo.onclick=function(){
  168. marquee();
  169. }
  170. //左按钮
  171. var l_lunbo=id(left);
  172. l_lunbo.onclick=function(){
  173. f_marquee();
  174. }
  175. //自动轮播
  176. var t = setInterval(marquee, speed);
  177. r_lunbo.onmouseover = function() {
  178. clearInterval(t);
  179. };
  180. r_lunbo.onmouseout = function() {
  181. speed = 2000;//数值越大越慢
  182. t = setInterval(marquee, speed);
  183. };
  184. l_lunbo.onmouseover = function() {
  185. clearInterval(t);
  186. };
  187. l_lunbo.onmouseout = function() {
  188. speed = 2000;//数值越大越慢
  189. t = setInterval(marquee, speed);
  190. };
  191. };
  192. }
  193. // big('photo-list','scroll','btn_left','btn_right'); //方法
  194. function uaredirect(f) {
  195. try {
  196. if (document.getElementById("bdmark") != null) {
  197. return
  198. }
  199. var b = false;
  200. if (arguments[1]) {
  201. var e = window.location.host;
  202. var a = window.location.href;
  203. if (isSubdomain(arguments[1], e) == 1) {
  204. f = f + "/#m/" + a;
  205. b = true
  206. } else {
  207. if (isSubdomain(arguments[1], e) == 2) {
  208. f = f + "/#m/" + a;
  209. b = true
  210. } else {
  211. f = a;
  212. b = false
  213. }
  214. }
  215. } else {
  216. b = true
  217. }
  218. if (b) {
  219. var c = window.location.hash;
  220. if (!c.match("fromapp")) {
  221. if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) {
  222. location.replace(f)
  223. }
  224. }
  225. }
  226. } catch (d) {
  227. }
  228. }
  229. function isSubdomain(c, d) {
  230. this.getdomain = function (f) {
  231. var e = f.indexOf("://");
  232. if (e > 0) {
  233. var h = f.substr(e + 3)
  234. } else {
  235. var h = f
  236. }
  237. var g = /^www\./;
  238. if (g.test(h)) {
  239. h = h.substr(4)
  240. }
  241. return h
  242. };
  243. if (c == d) {
  244. return 1
  245. } else {
  246. var c = this.getdomain(c);
  247. var b = this.getdomain(d);
  248. if (c == b) {
  249. return 1
  250. } else {
  251. c = c.replace(".", "\\.");
  252. var a = new RegExp("\\." + c + "$");
  253. if (b.match(a)) {
  254. return 2
  255. } else {
  256. return 0
  257. }
  258. }
  259. }
  260. };
  261. (function() {
  262. if (!
  263. /*@cc_on!@*/
  264. 0) return;
  265. 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(', ');
  266. var i= e.length;
  267. while (i--){
  268. document.createElement(e[i])
  269. }
  270. })()