var shuwon = { percent: 0, timers: "", init: function(e) { shuwon.backTop(); util.toastInit(); $(document).ready(function() { var p = 0, t = 0; $(window).scroll(function(e) { p = $(this).scrollTop(); if (p > 0) { $("header").addClass("active2") } else { $("header").removeClass("active2").addClass("active") } }); }); $('.backTops').click(function() { $('body,html').animate({ scrollTop: 0 }, 500); }) $("header").hover(function() { $('.header').addClass('headerActive') }, function() { $('.header').removeClass('headerActive') }) $(function () { $('.sp_nav').click(function () { $('.sp_nav').toggleClass('sp_nav_se'); $('.sjj_nav').toggleClass('nav_show'); $('.mengBan').toggleClass('nav_show2'); }); $('.sp_flex .sjj_nav .close').click(function () { $('.sp_nav').toggleClass('sp_nav_se'); $('.sjj_nav').toggleClass('nav_show'); $('.mengBan').toggleClass('nav_show2'); }); $('.sjj_nav ul li i').click(function () { $(this).parent().children('ul').slideToggle().parent().siblings().children('ul').slideUp(); $(this).toggleClass('sjj_nav_i_se'); $(this).parent().siblings().find('i').removeClass('sjj_nav_i_se'); $(this).parent('li').addClass("active").siblings().removeClass("active"); }); $('.sp_nav_xjb').html(' '); }); }, index: function() { var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 0, mobile: true, live: true }).init(); var rellax = new Rellax('.rellax') var form = document.getElementById('form'); $('.subimt').click(function () { if (form.name.value == '') { util.toast({ string: '璇疯緭鍏ユ偍鐨勫鍚?, type: 'warning' }); return false; } if (form.phone.value == '') { util.toast({ string: '璇疯緭鍏ユ偍鐨勮仈绯绘柟寮?, type: 'warning' }); return false; } if (form.email.value == '') { util.toast({ string: '璇疯緭鍏ユ偍鐨勯偖绠卞彿鐮?, type: 'warning' }); return false; } if (form.content.value == '') { util.toast({ string: '璇疯緭鍏ョ暀瑷€鍐呭', type: 'warning' }); return false; } shuwon.getDataForApi('post', '/apiform.html', { name: form.name.value, phone: form.phone.value, email: form.email.value, content: form.content.value, '_csrf-frontend': $('#csrf').val() }, function (res) { if(res.code == '200') { util.toast({ string: '鎻愪氦鎴愬姛', type: 'success' }); form.name.value = ''; form.phone.value = ''; form.email.value = ''; form.content.value = ''; } else { util.toast({ string: res.message, type: 'error' }); } }) }) }, mouseCircle: function() { var target = document.querySelector('.circle-box') target.classList.add('active') var isFollow = true; document.addEventListener('mousemove', function(event) { var x = event.clientX, y = event.clientY; if (isFollow) { TweenMax.to(target, .1, { x: x, y: y, force3D: true }) } }, false) document.addEventListener('mouseenter', function() { target.classList.add('active') }, false) }, mouseCircle2: function() { if (shuwon.percent == 0) { $('.circle-box').css('display', 'none') $('.circle-box2').css('display', 'block') var target = document.querySelector('.circle-box2') target.classList.add('active') var isFollow = true; document.addEventListener('mousemove', function(event) { var x = event.clientX, y = event.clientY; if (isFollow) { TweenMax.to(target, .1, { x: x - 50, y: y - 10, force3D: true }) } }, false) document.addEventListener('mouseenter', function() { target.classList.add('active') }, false) } else { $('.circle-box').css('display', 'block') $('.circle-box2').css('display', 'none') var target = document.querySelector('.circle-box') target.classList.add('active') var isFollow = true; document.addEventListener('mousemove', function(event) { var x = event.clientX, y = event.clientY; if (isFollow) { TweenMax.to(target, .1, { x: x, y: y, force3D: true }) } }, false) document.addEventListener('mouseenter', function() { target.classList.add('active') }, false) } }, nomoralBanner: function() { $(".index__hero__visual__pager__page").eq(0).addClass("active"); var t = $(".index__hero__visual__images__image"), a = t.length, d = 0; var timer = setInterval(function() { next() }, 5000); function next() { d = ++d > a - 1 ? 0 : d; e() } function prev() { d = --d < 0 ? a - 1 : d; e() } $(".index__hero__visual__pager__page").click(function() { d = $(this).index(); e() }); function e() { clearInterval(timer); $(".index__hero__visual").attr("data-position", d); $(".index__hero__visual__pager__page").eq(d).addClass("active").siblings().removeClass("active"); timer = setInterval(function() { next() }, 5000) } }, videoList: function() { var myVideo = document.getElementById("video"); $(".videoList ul li").click(function() { myVideo.setAttribute("src", $(this).attr("data-url")); $(".lightBox").addClass("active"); myVideo.play(); }) $(".videoCloseBtn").click(function() { $(".lightBox").removeClass("active"); myVideo.pause(); }) }, /** *閲囩敤swiper鐨刦ade鍒囨崲 * * 鏃犻渶浼犲弬 * 鍏煎绉诲姩绔 * */ swiperFade: function() { new Swiper('.swiper-container.swiperNomal', { autoplay: { delay: 3000, disableOnInteraction: false, }, spaceBetween: 30, loop: true, effect: 'fade', speed: 500, pagination: { el: '.swiperNomal .swiper-pagination', clickable: true, renderBullet: function(index, className) { return '0' + (index + 1) + ''; }, }, navigation: { nextEl: '.btnBox .next', prevEl: '.btnBox .prev', }, }); }, /** *閲囩敤swiper鐨刡anner鍒囨崲 * * 鏃犻渶浼犲弬 * 鍏煎绉诲姩绔 * */ swiperBanner: function() { var interleaveOffset = 0.5; var swiperOptions = { loop: true, speed: 1000, autoplay: true, grabCursor: true, watchSlidesProgress: true, mousewheelControl: true, keyboardControl: true, navigation: { nextEl: ".swiper-button-next.next", prevEl: ".swiper-button-prev.prev" }, pagination: { el: '.swiper-pagination.bannerDot', }, on: { progress: function() { var swiper = this; for (var i = 0; i < swiper.slides.length; i++) { var slideProgress = swiper.slides[i].progress; var innerOffset = swiper.width * interleaveOffset; var innerTranslate = slideProgress * innerOffset; swiper.slides[i].querySelector(".slide-inner").style.transform = "translate3d(" + innerTranslate + "px, 0, 0)"; } }, touchStart: function() { var swiper = this; for (var i = 0; i < swiper.slides.length; i++) { swiper.slides[i].style.transition = ""; } }, slideChange: function() { $('.jgs a').eq(this.activeIndex - 1).addClass("active").siblings().removeClass("active"); }, setTransition: function(speed) { var swiper = this; for (var i = 0; i < swiper.slides.length; i++) { swiper.slides[i].style.transition = speed + "ms"; swiper.slides[i].querySelector(".slide-inner").style.transition = speed + "ms"; } } } }; var swiper = new Swiper(".swiper-container.swiperBanner", swiperOptions); }, /** *鍥炲埌椤堕儴 * * 鏃犻渶浼犲弬 * 鍏煎绉诲姩绔 * */ backTop: function() { $("body").append('
'); $(window).scroll(function() { var sTop = $(window).scrollTop(); if (sTop > 500) { $(".backTop").addClass("active"); } else { $(".backTop").removeClass("active"); } }); $(".backTop").click(function() { $('body,html').animate({ scrollTop: 0 }, 500); }) }, /** *姘寸汗鍔ㄦ晥 * * 鏃犻渶浼犲弬 * 鍏煎绉诲姩绔 * */ wave: function(ele, color) { var unit = 100, canvas, context, canvas2, context2, height, width, xAxis, yAxis, draw; canvas = document.getElementById(ele); canvas.width = document.documentElement.clientWidth; canvas.height = 150; context = canvas.getContext("2d"); height = canvas.height; width = canvas.width; xAxis = Math.floor(height / 2); yAxis = 0; draw(); function draw() { context.clearRect(0, 0, width, height); drawWave(color, 1, 3, 0); draw.seconds = draw.seconds + .009; draw.t = draw.seconds * Math.PI; setTimeout(draw, 35); }; draw.seconds = 0; draw.t = 0; function drawWave(color, alpha, zoom, delay) { context.fillStyle = color; context.globalAlpha = alpha; context.beginPath(); drawSine(draw.t / 0.5, zoom, delay); context.lineTo(width + 10, height); context.lineTo(0, height); context.closePath() context.fill(); } function drawSine(t, zoom, delay) { var x = t; var y = Math.sin(x) / zoom; context.moveTo(yAxis, unit * y + xAxis); for (i = yAxis; i <= width + 10; i += 10) { x = t + (-yAxis + i) / unit / zoom; y = Math.sin(x - delay) / 3; context.lineTo(i, unit * y + xAxis); } } }, map: function() { var map = new BMap.Map("allmap"); var point = new BMap.Point(105.43048, 28.894874); map.centerAndZoom(point, 18); var top_left_control = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT }) var top_left_navigation = new BMap.NavigationControl(); var pt = new BMap.Point(105.43048, 28.894874); var myIcon = new BMap.Icon(".assets/images/common/mapIcon.png?v=1", new BMap.Size(60, 60)); var marker2 = new BMap.Marker(pt, { icon: myIcon }); map.addOverlay(marker2); map.addControl(top_left_control); map.addControl(top_left_navigation); }, /** *鏂伴椈鍒楄〃鍒嗛〉 * * 鏃犻渶浼犲弬 * 鍏煎绉诲姩绔 * */ page: function() { var total = Math.ceil($("#page").attr("data-total") / $("#page").attr("data-size")); var curPage = $("#page").attr("data-page"); var pageSize = $("#page").attr("data-size"); var url = $("#page").attr("data-cat"); var year = $("#page").attr("data-year"); new Paging('page', { nowPage: Number(curPage), // 褰撳墠椤电爜 pageNum: total, // 鎬婚〉鐮 buttonNum: pageSize, //瑕佸睍绀虹殑椤电爜鏁伴噺 canJump: 0, // 鏄惁鑳借烦杞€?=涓嶆樉绀猴紙榛樿锛夛紝1=鏄剧ず showOne: 1, //鍙湁涓€椤垫椂锛屾槸鍚︽樉绀恒€?=涓嶆樉绀?1=鏄剧ず锛堥粯璁わ級 callback: function(num) { //鍥炶皟鍑芥暟 if(year !== '') { window.location.href = url + num + '/' + year + ".html" + window.location.search } else { window.location.href = url + num + ".html" + window.location.search } } }) }, page2: function() { var total = Math.ceil($("#page").attr("data-total") / $("#page").attr("data-size")); var curPage = $("#page").attr("data-page"); var pageSize = $("#page").attr("data-size"); var url = $("#page").attr("data-cat"); new Paging('page', { nowPage: Number(curPage), // 褰撳墠椤电爜 pageNum: total, // 鎬婚〉鐮 buttonNum: pageSize, //瑕佸睍绀虹殑椤电爜鏁伴噺 canJump: 0, // 鏄惁鑳借烦杞€?=涓嶆樉绀猴紙榛樿锛夛紝1=鏄剧ず showOne: 1, //鍙湁涓€椤垫椂锛屾槸鍚︽樉绀恒€?=涓嶆樉绀?1=鏄剧ず锛堥粯璁わ級 callback: function(num) { //鍥炶皟鍑芥暟 window.location.href = url + num + ".html" } }) }, /** *鏂伴椈鍒楄〃鍒嗛〉 * * @sucess 鎴愬姛|澶辫触 * 鍏煎绉诲姩绔 * */ toast: function(sucess) { $(".toast").addClass("active").find("span").html(msg); if (!sucess) { $(".toast").addClass("warning"); } else { $(".toast").addClass("success"); } setTimeout(function() { $(".toast").removeClass("active") $(".toast").removeClass("warning") $(".toast").removeClass("success"); }, 2500) }, /** *閲囩敤swiper鐨刡anner鍒囨崲 * * url:瑙嗛鎾斁璺緞 * 鍏煎绉诲姩绔 * */ videoList: function(url) { var myVideo = document.getElementById("video"); myVideo.setAttribute("src", url); $(".lightBox").addClass("active"); myVideo.play(); $(".videoCloseBtn").click(function() { $(".lightBox").removeClass("active"); myVideo.pause(); }) }, /** *瀹氫綅鍒版煇涓厓绱犱綅缃 * * @y:鍋忕Щ鐨勯珮搴 */ scrollToPos: function(_y) { var hash = window.location.hash; var pos = hash.substring(hash.indexOf('#') + 1); if (pos != '') getPos(pos); function getPos(ele) { $('html,body').animate({ scrollTop: $("." + ele + "").offset().top - _y }, 400); } }, /** *楠岃瘉鎵嬫満鍙风爜 * * @phone:鎵嬫満鍙风爜 * @return {姝g‘锛歵rue,閿欒锛歠alse} * */ regPhone: function(phone) { reg = /^(13|15|17|18|19|14)[0-9]{9}$/; return reg.test(phone); }, /** *楠岃瘉韬唤璇佸彿鐮 * * @phone:韬唤璇佸彿鐮 * @return {姝g‘锛歵rue,閿欒锛歠alse} * */ regID: function(IDcard) { reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return reg.test(IDcard); }, /** *楠岃瘉閭鍙风爜 * * @Email:韬唤璇佸彿鐮 * @return {姝g‘锛歵rue,閿欒锛歠alse} * */ regEmail: function(Email) { reg = /^\w+\@+[0-9a-zA-Z]+\.(com|com.cn|edu|hk|cn|net)$/; return reg.test(Email); }, /** *楠岃瘉鏄惁鏄腑鏂 * * @name:鏂囧瓧 * @return {姝g‘锛歵rue,閿欒锛歠alse} * */ regZh: function(name) { reg = /^[\u4E00-\u9FA5A-Za-z]+$/; return reg.test(name); }, /** *楠岃瘉绾暟瀛 * * @number:鏁板瓧 * @return {姝g‘锛歵rue,閿欒锛歠alse} * */ regNumber: function(number) { reg = /^[0-9]*$/; return reg.test(number); }, /** *鑾峰彇鏁版嵁 * * @param {String} url 浼犲叆鐨勬暟鎹帴鍙 * @param {Object} para 浼犲叆鐨勫弬鏁 * @param {Object} callback 杩斿洖 */ getDataForApi: function(type, url, para, callback) { $.ajax({ type: type, data: para, url: window.location.protocol + '//' + window.location.host + url, dataType: 'json', success: function(data) { callback(data) }, error: function(e) { console.log(e, "鏁版嵁鍔犺浇閿欒") } }) }, } shuwon.init();