index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. $(document).ready(function(){
  2. //轮播图
  3. // window.onresize = function() {
  4. // // window.location.reload();
  5. // console.log("1");
  6. // };
  7. "use strict";
  8. window.onresize = function() {
  9. window.location.reload();
  10. };
  11. var slideShow = $(".slideShow"), //获取最外层框架的名称
  12. ul = slideShow.find("ul"),
  13. showNumber = slideShow.find(".showNav span"),//获取按钮
  14. oneWidth = slideShow.find("ul li").eq(0).width(); //获取每个图片的宽度
  15. // console.log(oneWidth);
  16. var timer = null; //定时器返回值,主要用于关闭定时器
  17. var iNow = 0; //iNow为正在展示的图片索引值,当用户打开网页时首先显示第一张图,即索引值为0
  18. showNumber.on("click", function () { //为每个按钮绑定一个点击事件
  19. $(this).addClass("active").siblings().removeClass("active"); //按钮点击时为这个按钮添加高亮状态,并且将其他按钮高亮状态去掉
  20. var index = $(this).index(); //获取哪个按钮被点击,也就是找到被点击按钮的索引值
  21. iNow = index;
  22. ul.animate({
  23. // "left": -oneWidth * iNow, //注意此处用到left属性,所以ul的样式里面需要设置position: relative; 让ul左移N个图片大小的宽度,N根据被点击的按钮索引值iNOWx确定
  24. "left": -oneWidth * iNow, //注意此处用到left属性,所以ul的样式里面需要设置position: relative; 让ul左移N个图片大小的宽度,N根据被点击的按钮索引值iNOWx确定
  25. });
  26. // console.log(iNow);
  27. // console.log(-oneWidth * iNow);
  28. });
  29. timer = setInterval(function () { //打开定时器
  30. iNow++; //让图片的索引值次序加1,这样就可以实现顺序轮播图片
  31. if (iNow > showNumber.length - 1) { //当到达最后一张图的时候,让iNow赋值为第一张图的索引值,轮播效果跳转到第一张图重新开始
  32. iNow = 0;
  33. }
  34. showNumber.eq(iNow).trigger("click"); //模拟触发数字按钮的click
  35. }, 5000); //2000为轮播的时间
  36. // })
  37. $(".container_nav a").click(function(e){
  38. e.preventDefault();
  39. $(this).addClass("selected");
  40. $(this).siblings().removeClass("selected");
  41. var c = $(this).html();
  42. // alert(a);
  43. if(c == "跟单"){
  44. // alert("跟单");
  45. // console.log("跟单");
  46. $(".nav_contain>div:first-child").addClass("active");
  47. $(".nav_contain>div:not(:first-child)").removeClass("active");
  48. }else if(c == "工艺"){
  49. // alert("工艺");
  50. // console.log("工艺");
  51. $(".nav_contain div:nth-child(2)").addClass("active");
  52. $(".nav_contain div:not(:nth-child(2))").removeClass("active");
  53. }else if(c == "质检"){
  54. // alert("质检");
  55. // console.log("质检")
  56. $(".nav_contain div:nth-child(3)").addClass("active");
  57. $(".nav_contain div:not(:nth-child(3))").removeClass("active");
  58. }else if(c == "加工"){
  59. // alert("加工");
  60. // console.log("加工")
  61. $(".nav_contain div:nth-child(4)").addClass("active");
  62. $(".nav_contain div:not(:nth-child(4))").removeClass("active");
  63. }else if(c == "物流"){
  64. // alert("物流");
  65. // console.log("物流")
  66. $(".nav_contain div:nth-child(5)").addClass("active");
  67. $(".nav_contain div:not(:nth-child(5))").removeClass("active");
  68. }
  69. });
  70. //中英文之间的转化
  71. $("#eng").click(function(){
  72. $(".footer_title p:first-child").html("Fujian Shengteng Knltting Textlle Co.,Ltd.");
  73. $(".footer_top li:first-child").html("Contacts:LINXUEGUI (General Manager)");
  74. $(".footer_top li:nth-child(2)").html("Tel:+86 0591-28761238");
  75. $(".footer_top li:nth-child(3)").html("Mobile:13599097555");
  76. $(".footer_top li:last-child").html("Fax:+86 0591-28761296");
  77. $(".footer_bottom li:first-child").html("E-mail:fjshengteng@163.com");
  78. $(".footer_bottom li:last-child").html("Add:shenjutengda,Songxia Town,Changle City,Fujian Province,China");
  79. $(this).css("background","#5E97F5");
  80. $("#chn").css("background","transparent");
  81. });
  82. $("#chn").click(function(){
  83. $(".footer_title p:first-child").html("福建升腾针纺有限公司");
  84. $(".footer_top li:first-child").html("联系人:林雪贵(总经理)");
  85. $(".footer_top li:nth-child(2)").html("手机号码:13599097555");
  86. $(".footer_top li:nth-child(3)").html("电话:0591-28761238");
  87. $(".footer_top li:last-child").html("传真:0591-28761296");
  88. $(".footer_bottom li:first-child").html("邮箱:fjshengteng@163.com");
  89. $(".footer_bottom li:last-child").html("公司地址:福建省长乐市松下镇龙纺工业区");
  90. $(this).css("background","#5E97F5");
  91. $("#eng").css("background","transparent");
  92. });
  93. $(".swiper-slide").mouseover(function(){
  94. //放大图片
  95. $(this).css({"transform":"scale(1.1)","transition":"all .2s linear"});
  96. }).mouseout(function(){
  97. //恢复正常
  98. $(this).css({"transform":"scale(1)","transition":"all .2s linear"});
  99. });
  100. var swiper = new Swiper('.swiper-container', {
  101. slidesPerView: 4.6,
  102. spaceBetween: 30,
  103. pagination: {
  104. el: '.swiper-pagination',
  105. clickable: true,
  106. },
  107. });
  108. });