! function (win) { "use strict"; var Sharp = function () { this.version = "1.0.1"; }; Sharp.prototype.reader = function () { sharp.navigation(); sharp.homeSides(); sharp.homeProductTabs(); sharp.homeNewsTab(); sharp.homePattern(); sharp.businessCert(); sharp.productRender(); sharp.solutionRender(); sharp.imageLazyLoad(); //sharp.indexAnimate(); sharp.indexNew(); sharp.rightSead(); sharp.taoliZhuanti(); sharp.productTab(); }; Sharp.prototype.mobileGO = function (url) { var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire"); var browser = navigator.userAgent.toLowerCase(); for (var i = 0; i < mobileAgent.length; i++) { if (browser.indexOf(mobileAgent[i]) != -1) { location.href = url; break; } } } Sharp.prototype.imageLazyLoad = function () { lazyload(); }; //导航选中 Sharp.prototype.navigation = function () { var index = $("#navigation").val(); $(".nav_list>li:eq(" + index + ")").addClass("hover"); } //首页轮播 Sharp.prototype.homeSides = function () { if ($("#swiper").length == 0) return; var index = 0; var preindex = 0; var timer = null; var $imgs = $("#banner img"); var window_width = $(window).width(); var imglength = $("#banner a").length - 1; $("#banner").css({ "height": window_width * 0.3125 }); autoPlay(); function autoPlay() { timer = setInterval(function () { index++; if (index > imglength) { index = 0; preindex = imglength; } scrollLeft(); preindex = index; }, 5000); } //左滑动 function scrollLeft() { $("#btns span").eq(index).addClass("hover").siblings().removeClass("hover"); $imgs.eq(preindex).animate({ left: -window_width }); $imgs.eq(index).stop(true, true).css({ left: window_width }).animate({ left: 0 }); } //右滑动 function scrollRight() { $("#btns span").eq(index).addClass("hover").siblings().removeClass("hover"); $imgs.eq(preindex).animate({ left: window_width }); $imgs.eq(index).stop(true, true).css({ left: -window_width }).animate({ left: 0 }); } // 小圆点悬浮 $("#btns span").hover(function () { clearInterval(timer); index = $(this).index(); if (preindex < index || index == 0 && preindex == imglength) { scrollLeft(); } else if (preindex > index || index == imglength && preindex == 0) { scrollRight(); } preindex = index; }, function () { autoPlay(); }); //图片hover $("#banner img").hover(function () { clearInterval(timer); }, function () { autoPlay(); }); }; //首页产品服务tabs Sharp.prototype.homeProductTabs = function () { var $products = $(".index_product_top li[data-toggle='tab']"); if ($products.length == 0) return; $products.mouseover(function () { var index = $(this).index(); $(this).addClass("hover").siblings("li").removeClass("hover"); var $list = $(".index_product_btm>.index_product_list:eq(" + (--index + 1) + ")"); $list.siblings(".index_product_list").hide(); $list.show(); }); }; //首页新闻切换 Sharp.prototype.homeNewsTab = function () { if ($(".index_new_tab li").length == 0) return; $(".index_new_tab li").mouseenter(function () { var $this = $(this); var index = $this.index(); $this.addClass("hover").siblings("li").removeClass("hover"); $(".index_new_btm").children(".index_new_box:eq(" + index + ")").stop().show().siblings(".index_new_box").hide(); }); }; Sharp.prototype.indexNew = function () { class Lb { constructor(options) { this.lbBox = document.getElementById(options.id); this.lbItems = this.lbBox.querySelectorAll('.lb-item'); this.lbSigns = this.lbBox.querySelectorAll('.lb-sign li'); this.lbCtrlL = this.lbBox.querySelectorAll('.lb-ctrl')[0]; this.lbCtrlR = this.lbBox.querySelectorAll('.lb-ctrl')[1]; // 当前图片索引 this.curIndex = 0; // 轮播盒内图片数量 this.numItems = this.lbItems.length; // 是否可以滑动 this.status = true; // 轮播速度 this.speed = options.speed || 600; // 等待延时 this.delay = options.delay || 3000; // 轮播方向 this.direction = options.direction || 'left'; // 是否监听键盘事件 this.moniterKeyEvent = options.moniterKeyEvent || false; // 是否监听屏幕滑动事件 this.moniterTouchEvent = options.moniterTouchEvent || false; this.handleEvents(); this.setTransition(); } // 开始轮播 start() { const event = { srcElement: this.direction == 'left' ? this.lbCtrlR : this.lbCtrlL }; const clickCtrl = this.clickCtrl.bind(this); // 每隔一段时间模拟点击控件 this.interval = setInterval(clickCtrl, this.delay, event); } // 暂停轮播 pause() { clearInterval(this.interval); } /** * 设置轮播图片的过渡属性 * 在文件头内增加一个样式标签 * 标签内包含轮播图的过渡属性 */ setTransition() { const styleElement = document.createElement('style'); document.head.appendChild(styleElement); const styleRule = `.lb-item {transition: left ${this.speed}ms ease-in-out}` styleElement.sheet.insertRule(styleRule, 0); } // 处理点击控件事件 clickCtrl(event) { if (!this.status) return; this.status = false; if (event.srcElement == this.lbCtrlR) { var fromIndex = this.curIndex, toIndex = (this.curIndex + 1) % this.numItems, direction = 'left'; } else { var fromIndex = this.curIndex; toIndex = (this.curIndex + this.numItems - 1) % this.numItems, direction = 'right'; } this.slide(fromIndex, toIndex, direction); this.curIndex = toIndex; } // 处理点击标志事件 clickSign(event) { if (!this.status) return; this.status = false; const fromIndex = this.curIndex; const toIndex = parseInt(event.srcElement.getAttribute('slide-to')); const direction = fromIndex < toIndex ? 'left' : 'right'; this.slide(fromIndex, toIndex, direction); this.curIndex = toIndex; } // 处理滑动屏幕事件 touchScreen(event) { if (event.type == 'touchstart') { this.startX = event.touches[0].pageX; this.startY = event.touches[0].pageY; } else { // touchend this.endX = event.changedTouches[0].pageX; this.endY = event.changedTouches[0].pageY; // 计算滑动方向的角度 const dx = this.endX - this.startX const dy = this.startY - this.endY; const angle = Math.abs(Math.atan2(dy, dx) * 180 / Math.PI); // 滑动距离太短 if (Math.abs(dx) < 10 || Math.abs(dy) < 10) return; if (angle >= 0 && angle <= 45) { // 向右侧滑动屏幕,模拟点击左控件 this.lbCtrlL.click(); } else if (angle >= 135 && angle <= 180) { // 向左侧滑动屏幕,模拟点击右控件 this.lbCtrlR.click(); } } } // 处理键盘按下事件 keyDown(event) { if (event && event.keyCode == 37) { this.lbCtrlL.click(); } else if (event && event.keyCode == 39) { this.lbCtrlR.click(); } } // 处理各类事件 handleEvents() { // 鼠标移动到轮播盒上时继续轮播 this.lbBox.addEventListener('mouseleave', this.start.bind(this)); // 鼠标从轮播盒上移开时暂停轮播 this.lbBox.addEventListener('mouseover', this.pause.bind(this)); // 点击左侧控件向右滑动图片 this.lbCtrlL.addEventListener('click', this.clickCtrl.bind(this)); // 点击右侧控件向左滑动图片 this.lbCtrlR.addEventListener('click', this.clickCtrl.bind(this)); // 点击轮播标志后滑动到对应的图片 for (let i = 0; i < this.lbSigns.length; i++) { this.lbSigns[i].setAttribute('slide-to', i); this.lbSigns[i].addEventListener('click', this.clickSign.bind(this)); } // 监听键盘事件 if (this.moniterKeyEvent) { document.addEventListener('keydown', this.keyDown.bind(this)); } // 监听屏幕滑动事件 if (this.moniterTouchEvent) { this.lbBox.addEventListener('touchstart', this.touchScreen.bind(this)); this.lbBox.addEventListener('touchend', this.touchScreen.bind(this)); } } /** * 滑动图片 * @param {number} fromIndex * @param {number} toIndex * @param {string} direction */ slide(fromIndex, toIndex, direction) { if (direction == 'left') { this.lbItems[toIndex].className = "lb-item next"; var fromClass = 'lb-item active left', toClass = 'lb-item next left'; } else { this.lbItems[toIndex].className = "lb-item prev"; var fromClass = 'lb-item active right', toClass = 'lb-item prev right'; } this.lbSigns[fromIndex].className = ""; this.lbSigns[toIndex].className = "active"; setTimeout((() => { this.lbItems[fromIndex].className = fromClass; this.lbItems[toIndex].className = toClass; }).bind(this), 50); setTimeout((() => { this.lbItems[fromIndex].className = 'lb-item'; this.lbItems[toIndex].className = 'lb-item active'; this.status = true; // 设置为可以滑动 }).bind(this), this.speed + 50); } } if ($(".lb-box").length > 0) { window.onload = function () { // 轮播选项 const options = { id: 'lb-1', // 轮播盒ID speed: 600, // 轮播速度(ms) delay: 3000, // 轮播延迟(ms) direction: 'left', // 图片滑动方向 moniterKeyEvent: true, // 是否监听键盘事件 moniterTouchEvent: true // 是否监听屏幕滑动事件 }; const lb = new Lb(options); lb.start(); } } }; //首页合作伙伴 Sharp.prototype.homePattern = function () { if ($(".picScroll-left").length == 0) return; $(".picScroll-left").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 5 }); }; //底部营业执照 Sharp.prototype.businessCert = function () { if ($(".footer_btm_box_left a").length > 2) { $(".zoom_btn").click(function () { $(".zoom").show().css("cursor", "zoom-out"); }); $(".zoom").click(function () { $(this).hide(); }); } //底部分享 if ($(".foot_bg").length > 0) { $(".foot_btn").click(function () { $(".foot_web").show(); }) $(".foot_gb").click(function () { $(".foot_web").hide(); }) } }; //底部联系方式 Sharp.prototype.rightSead = function () { if ($("#leftsead").length == 0) return; $("#leftsead a").hover(function () { if ($(this).is(".youhui")) { $(this).children("img.hides").show(); } else { $(this).children("div.hides").show(); $(this).children("img.shows").hide(); $(this).children("div.hides").animate({ marginRight: '0px' }, '0'); } }, function () { if ($(this).is(".youhui")) { $(this).children("img.hides").hide(); } else { $(this).children("div.hides").animate({ marginRight: '-163px' }, 0, function () { $(this).hide(); $(this).next("img.shows").show(); }); } }); $("#top_btn").click(function () { if (scroll == "off") return; $("html,body").animate({ scrollTop: 0 }, 600); }); $(".youhui").mouseover(function () { $(this).children(".2wm").show(); }) $(".youhui").mouseout(function () { $(this).children(".2wm").hide(); }); }; //产品内页 Sharp.prototype.productRender = function () { if ($(".picScroll-left2").length > 0) { $(".picScroll-left2").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 3 }); } if ($(".picScroll-left").length > 0) { $(".picScroll-left").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 5 }); } if ($(".picScroll-left21").length > 0) { $(".picScroll-left21").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 4 }); } if ($(".picScroll-left3").length > 0) { $(".picScroll-left3").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 2 }); } if ($(".picScroll-left31").length > 0) { $(".picScroll-left31").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 2 }); } } //产品列表 Sharp.prototype.productTab = function () { if ($(".product_list_left").length > 0) { $(".product_list_top span").click(function () { $(".product_list_two").hide(); $(this).parent().next().slideToggle(); }) } } //解决方案 Sharp.prototype.solutionRender = function () { if ($(".epc_nl_tab li").length > 0) { $(".epc_nl_tab li").mouseenter(function () { var $this = $(this); var index = $this.index(); $this.addClass("hover").siblings("li").removeClass("hover"); $(".epc_nl_div").children(".epc_nl_div1:eq(" + index + ")").stop().show().siblings(".epc_nl_div1").hide(); }); } if ($(".epc_lc_top_list li").length > 0) { $(".epc_lc_top_list li").mouseenter(function () { var $this = $(this); var index = $this.index(); $this.addClass("hover").siblings("li").removeClass("hover"); $(".epc_lc_btm").children(".epc_lc_btm_box:eq(" + index + ")").stop().show().siblings(".epc_lc_btm_box").hide(); }); } if ($(".jztl").length > 0) { $(".jztl video").attr("poster","/assets/images/jztl_videobg.jpg"); } if ($(".voc").length > 0) { $(".voc video").attr("poster","/assets/images/voc_videobg.jpg"); } } //陶粒专题 Sharp.prototype.taoliZhuanti = function () { if ($(".taoli-products").length > 0) { $(".taoli-products").slide({ mainCell: ".bd ul", effect: "left", autoPlay: true }); } if ($(".kjcx_kjyf_box_list").length > 0) { $(".kjcx_kjyf_box_list").slide({ titCell: ".hd ul", mainCell: ".bd ul", autoPage: true, effect: "left", autoPlay: true, vis: 3}); } if ($(".kjcx_fmzl_box").length > 0) { $(function(){ var swiper2 = new Swiper('.swiper-container3', { effect: 'coverflow', pagination: '.swiper-pagination', slideToClickedSlide:true,//点击对应子元素居中 loop: true, paginationType: 'progress', grabCursor: true, speed:1000, autoplay:700, centeredSlides: true, slidesPerView: 'auto', coverflowEffect: { rotate: 80, stretch: 0, depth: 100, modifier: 1, slideShadows : true } }); }) } if ($(".kjcx").length > 0) { var options = {    useEasing : true,    useGrouping : true,    separator : ',',    decimal : '.',    prefix : '',    suffix : '' }; var demo1 = new CountUp("myTargetElement1", 0, 1121, 0, 1.5, options); var demo3 = new CountUp("myTargetElement3", 0, 445, 0, 1.5, options); var demo2 = new CountUp("myTargetElement2", 0, 10, 0, 1.5, options); var demo4 = new CountUp("myTargetElement4", 0, 5, 0, 1.5, options); var demo5 = new CountUp("myTargetElement5", 0, 16, 0, 1.5, options); var demo6 = new CountUp("myTargetElement6", 0, 53.9, 0, 1.5, options); $(window).scroll(function(){ if($(window).scrollTop()>=100){ demo2.start(); demo4.start(); demo5.start(); demo6.start(); } var show_top = $( ".kjcx_gsal" ).offset().top - 500; if($(window).scrollTop()>=show_top){ demo1.start(); demo3.start(); } }) } } Sharp.prototype.submitform = function (frm, btn) { var $mobile = $("#" + frm).find("input[name='mobile']"); var mobile = $mobile.val(); var reg = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/; //校验手机号和固定电话 if (!reg.test(mobile) || mobile === '') { $("#" + frm).find(".form-tips").html('请输入正确的号码'); } else { var content = $("#" + frm).serialize(); sharp.sendMessage(content, function () { $("#" + frm).find(".form-tips").html('留言成功,万博max体育会尽快联系您'); $("#" + frm).get(0).reset(); }, function () { $("#" + frm).find(".form-tips").html('留言失败,请直接拨打电话'); }); } } Sharp.prototype.json = function (e) { var t, n, r, i = e, s = {}; t = i.split("&"), r = null, n = null; for (var o in t) { var u = t[o].indexOf("="); u !== -1 && (r = t[o].substr(0, u), n = t[o].substr(u + 1), s[r] = n) } return s } //留言 Sharp.prototype.sendMessage = function (formData, success, error) { var refer = document.referrer; var path = location.href; var toEmail ='1129056001@qq.com'; var data = { path: path, refer: refer, content: JSON.stringify(sharp.json(formData)), toEmail: toEmail, source: '国内-百度(hnzkjq.com)', sourceDevice: 'pc', title: document.title, }; $.ajax({ type: "post", async: true, cache: false, dataType: "JSON", contentType: "application/json;charset=utf-8", url: "https://app.hnzkjq.com/api/message/submit", data: JSON.stringify(data), success: function (res) { if (res.type == 200) { success(); $('input[type="button"]').attr("disabled",true); } else { error(); } }, }); } win.sharp = new Sharp(); $(function () { sharp.reader(); }) }(window);