var shuwon = {
percent: 0,
timers: "",
init: function(e) {
$("body").append('
');
$(".menu_btn").click(function() {
$(this).toggleClass("active");
$(".navigator").toggleClass("active");
})
$(".closeIcon").click(function() {
$(".menu_btn,.navigator").removeClass("active");
})
shuwon.backTop();
$(window).scroll(function() {
var scrollTop = $(window).scrollTop();
if (scrollTop > 100) {
$(".header").addClass("open")
} else {
$(".header").removeClass("open")
}
});
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 100,
mobile: true,
live: true
}).init();
$(".nav ul li").hover(function() {
$(this).hasClass("has") ? $(".header").addClass("active") : $(".header").removeClass(
"active")
$(".navBar ul li").eq($(this).index()).addClass("active").siblings().removeClass("active");
})
$(".header").hover(function() {}, function() {
$(".header").removeClass("active")
})
$(".gpxx").click(function() {
window.open(
"http://www.cninfo.com.cn/new/disclosure/stock?stockCode=300440&orgId=9900023898#latestAnnouncement"
)
})
$(".first-li").click(function() {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(this).next().removeClass("active");
} else {
$(".first-li,.second-li").removeClass("active");
$(this).addClass("active");
$(this).next().addClass("active");
}
})
},
loading: function() {
shuwon.timers = setInterval(function() {
shuwon.percent++;
if (shuwon.percent > 99) {
shuwon.index();
return;
}
// console.log(shuwon.percent)
$(".lineL span,.lineR span").css({
width: shuwon.percent + "%"
});
$(".loadLogo span").html(shuwon.percent + " %");
}, 30)
},
index: function() {
// $(".loadLogo span").html("100 %")
// clearInterval(shuwon.timers);
// $(".loadBox").addClass("active");
new Swiper('.swiper-container.idx-banner', {
navigation: {
nextEl: '.swiperBtn .next',
prevEl: '.swiperBtn .prev',
},
pagination: {
el: '.idx-banner .swiper-pagination',
clickable: true,
},
setWrapperSize: true,
paginationClickable: !0,
speed: 1600,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
loop: true,
effect: "fade",
paginationBulletRender: function(index, className) {
if (index < 9) {
return '0' + (index + 1) + ''
} else {
return '' + (index + 1) + ''
}
},
})
shuwon.tech();
new Swiper('.swiper-container.newSwiper', {
slidesPerView: 3,
spaceBetween: 0,
scrollbar: {
el: '.newSwiper .swiper-scrollbar',
},
breakpoints: {
//当宽度大于等于320
320: {
slidesPerView: 1,
spaceBetween: 0,
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 0,
},
},
});
$(".swiper-slide.first").css({
height: $(".newSwiper .swiper-wrapper").height()
});
window.onresize = function() {
$(".swiper-slide.first").css({
height: $(".newSwiper .swiper-wrapper").height()
});
}
shuwon.wordMove($('.li1'))
$(".xzj ul li").hover(function() {
grallyMove($(this).index(), $(this).attr("data-url"));
}, function() {
TweenMax.fromTo('.maskBall', 1, {
y: 600
}, {
y: 600
});
})
// var _id = 0;
// setInterval(function(){
// _id ++;
// if(_id>2){
// _id = 0;
// }
// grallyMove(_id,$(".xzj ul li").eq(_id).attr("data-url"));
// },5000)
function grallyMove(id, url) {
$(".xzj ul li").eq(id).addClass("active").siblings().removeClass("active");
$(".nro ul li").eq(id).addClass("active").siblings().removeClass("active");
setTimeout(function() {
$(".jjPic").css({
"background-image": "url(" + url + ")"
})
}, 300)
TweenMax.fromTo('.maskBall', 1, {
y: 600
}, {
y: -1800
});
}
new Swiper(".mySwiper", {
navigation: {
nextEl: ".mySwiper .swiper-button-next",
prevEl: ".mySwiper .swiper-button-prev",
},
pagination: {
el: ".mySwiper .swiper-pagination",
},
});
if ($(window).width() <= 768) {
var _w = 0;
setInterval(function() {
_w+=0.3;
if(_w>200) _w = 0;
$(".word-center1").css({"marginLeft":-_w+"vw"})
},20)
var _w2 = 0;
setInterval(function() {
_w2+=0.3;
if(_w2>200) _w2 = 0;
$(".word-center2").css({"marginLeft":-_w2+"vw"})
},20)
var _w3 = 0;
setInterval(function() {
_w3+=0.3;
if(_w3>200) _w3 = 0;
$(".word-center3").css({"marginLeft":-_w3+"vw"})
},20)
}
},
wordMove: function(nodes) {
if (nodes.length > 0) {
nodes.each(function() {
setTransition()
})
}
function setTransition() {
var width = $(window).width(),
wrap = nodes,
transform = 0;
function fn() {
requestAnimationFrame(fn);
transform += 1;
if (transform + 1 >= width) {
transform = 0
}
wrap.css({
"-webkit-transform": "translateX(" + -transform + "px) translateY(-50%)"
})
}
if (width * 2 > window.innerWidth) {
fn()
}
}
},
banner: function() {
slides = $('.banner .swiper-slide');
Img = [];
slides.each(function(index, element) {
Img[index] = new Image();
Img[index].src = slides.eq(index).attr('data-poster');
slidesLength = index
//使用附加文本替换virtualTranslate,避免鼠标滚轮失效
$("#txt").append('' + slides.eq(index).html() + '
')
});
tweenObj = {
translate: 0
};
var canvas = document.getElementById("shows");
ctx = canvas.getContext("2d");
window.onload = function() {
var mySwiper = new Swiper('.banner .swiper-container', {
watchSlidesProgress: true,
virtualTranslate: true,
mousewheel: false,
grabCursor: true,
autoplay: {
delay: 5000,
disableOnInteraction: true,
},
pagination: {
el: '.banner .swiper-pagination',
clickable: true,
},
speed: 700, //限制滚轴时间间隔
on: {
init: function() {
resize(this);
/*预加载动画*/
tl = new TimelineMax();
tl.to(".tip-bg", 0.5, {
width: '100%'
})
.set(".tiptxt", {
autoAlpha: 0
})
.to(".tip-bg", 0.5, {
x: '101%'
}, "+=0.2")
.to(".preload-bg", 0.5, {
x: '101%'
}, "-=0.1")
.set("#preload", {
autoAlpha: 0
})
},
resize: function() {
resize(this);
},
setTranslate: function() {
draw(this, 1);
},
},
});
}
function resize(swiper) {
clientWidth = $(window).width();
clientHeight = $(window).height();
// 每一个显示块的宽度
blockWidth = clientWidth / 5
// 使用的图片大小 720/1280=0.5625
// 图片裁剪区域
if (clientHeight / clientWidth > 0.5625) {
cutWidth = 720 * clientWidth / clientHeight
cutX = (1280 - cutWidth) / 2
cutHeight = 720
cutY = 0
} else {
cutHeight = 1280 * clientHeight / clientWidth
cutY = (720 - cutHeight) / 2
cutWidth = 1280
cutX = 0
}
canvas.width = clientWidth;
canvas.height = clientHeight;
draw(swiper);
}
function draw(swiper, speed) {
if (typeof(speed) == "undefined") {
speed = 0.3;
}
TweenMax.killAll();
TweenMax.to(tweenObj, speed, {
tlanslate: swiper.translate,
ease: Power4.easeOut,
onUpdate: function() {
//如果超出显示范围添加黑色背景
if (swiper.progress < 0 || swiper.progress > 1) {
ctx.fillStyle = "#000000";
ctx.fillRect(0, 0, clientWidth, clientHeight);
}
tlanslate = tweenObj.tlanslate
for (i = 0; i <= slidesLength; i++) {
percent = -tlanslate / clientWidth - i
if (Math.abs(percent) <= 1) {
n2scale = 2 - Math.abs(percent) * 2
if (n2scale > 1) {
n2scale = 1
}
n1scale = 1 - Math.abs(percent) * 2
if (n1scale < 0) {
n1scale = 0
}
//画5个块,裁剪出位移差
ctx.drawImage(Img[i], cutX + cutWidth * percent * 0.2 + cutWidth / 5 *
Math.abs(percent) * 2, cutY, cutWidth / 5 * n1scale, cutHeight,
(clientWidth * i + tlanslate) * 0.6 + blockWidth * (1 -
n1scale), 0, blockWidth * n1scale, clientHeight);
ctx.drawImage(Img[i], cutX + cutWidth / 5 - cutWidth * percent * 0.1 +
cutWidth / 5 - cutWidth / 5 * n2scale, cutY, cutWidth / 5 *
n2scale, cutHeight, (clientWidth * i + tlanslate) * 0.6 +
blockWidth + blockWidth - blockWidth * n2scale, 0, blockWidth *
n2scale, clientHeight);
ctx.drawImage(Img[i], cutX + cutWidth / 5 * 2 - cutWidth * percent *
0.4, cutY, cutWidth / 5, cutHeight, (clientWidth * i +
tlanslate) * 0.6 + blockWidth * 2, 0, blockWidth,
clientHeight);
ctx.drawImage(Img[i], cutX + cutWidth / 5 * 3 - cutWidth * percent *
0.1, cutY, cutWidth / 5 * n2scale, cutHeight, (clientWidth * i +
tlanslate) * 0.6 + blockWidth * 3, 0, blockWidth * n2scale,
clientHeight);
ctx.drawImage(Img[i], cutX + cutWidth / 5 * 4 + cutWidth * percent *
0.2, cutY, cutWidth / 5 * n1scale, cutHeight, (clientWidth * i +
tlanslate) * 0.6 + blockWidth * 4, 0, blockWidth * n1scale,
clientHeight);
}
//设置文字相对位置,右边缩进0.8,左边加大1.2倍
modifer = 1
if (i > -tlanslate / clientWidth) {
modifer = 0.8
}
if (i < -tlanslate / clientWidth) {
modifer = 1.2
}
swiper.$el.find('.box').eq(i).transform('translate3d(' + (tlanslate /
clientWidth + i) * clientWidth * modifer + 'px, 0, 0)');
}
}
})
}
},
about: function() {
$(".fancybox").fancybox();
new Swiper('.swiper-container.hisSwiper', {
slidesPerView: 3,
spaceBetween: 30,
grabCursor: true,
speed: 500,
pagination: {
el: '.swiper-pagination.fine-pagi',
type: 'progressbar',
},
navigation: {
nextEl: '.hisBox .swiper-button-next',
prevEl: '.hisBox .swiper-button-prev',
},
breakpoints: {
//当宽度大于等于320
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1.5,
spaceBetween: 20
},
1200: {
slidesPerView: 4,
spaceBetween: 50
},
},
});
new Swiper('.swiper-container.pzSwiper', {
slidesPerView: 2,
spaceBetween: 30,
grabCursor: true,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
speed: 500,
pagination: {
el: '.pzSwiper .swiper-pagination',
},
breakpoints: {
//当宽度大于等于320
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1.5,
spaceBetween: 10
},
},
});
$(".fancybox").fancybox();
// var container = $('.hotList'); /* 初始化布局*/
// container.imagesLoaded(function () {
// container.masonry({
// itemSelector: '.item',
// percentPosition: true,
// isAnimated: true
// });
// });
// container.imagesLoaded(function () {
// new Masonry(document.getElementById('proimg'), { itemSelector: 'item', percentPosition: true, isAnimated: true });
// });
$(".navFocus a").click(function() {
$(this).addClass("active").siblings().removeClass("active");
$(".singeBox .sp").eq($(this).index()).addClass("active").siblings().removeClass("active");
})
$(".czBtn").click(function() {
$(".lightBox").addClass("active");
})
$(".backWd").click(function() {
$(".lightBox").removeClass("active");
})
var url = window.location.href;
function obj(url, n) {
var urlAry = url.split('?')[n].split('&');
var urlObj = {};
urlAry.map(item => {
item = item.split('=');
urlObj[item[0]] = item[1]
})
return urlObj
}
function urlParse(url) {
var urlObj1 = obj(url, 1); //1个?传参
if (url.split('?').length < 3) {
return urlObj1;
}
var urlObj2 = obj(url, 2); //两个?传参
return Object.assign(urlObj1, urlObj2)
}
$('html,body').animate({
scrollTop: $("#" + urlParse(url).menu + "").offset().top - 60
}, 0);
$(".navFocus a").eq(urlParse(url).id).addClass("active").siblings().removeClass("active")
$(".singeBox .sp").eq(urlParse(url).id).addClass("active").siblings().removeClass("active");
},
solution: function() {
var soSwiper = new Swiper('.swiper-container.soluSwiper', {
slidesPerView: 1,
spaceBetween: 0,
navigation: {
nextEl: '.soluSwiper .swiper-button-next',
prevEl: '.soluSwiper .swiper-button-prev',
},
pagination: {
el: '.soluSwiper .swiper-pagination',
type: 'fraction',
},
on: {
slideChange: function() {
$(".sloganNav a").removeClass("active");
if (this.activeIndex == 0) {
$(".sloganNav.so0 a").eq(0).addClass("active");
loadSolutionPage("471999484402860032");
} else if (this.activeIndex == 1) {
$(".sloganNav.so1 a").eq(0).addClass("active");
loadSolutionPage("471999395437477888");
} else if (this.activeIndex == 2) {
$(".sloganNav.so2 a").eq(0).addClass("active");
loadSolutionPage("471999350797500416");
}
// $('.TabUl li').eq(this.activeIndex).addClass("active").siblings().removeClass("active");
},
}
});
$(".sloganNav a").click(function() {
$(".sloganNav a").removeClass("active");
$(this).addClass("active").siblings().removeClass("active");
loadSolutionPage($(this).attr("data-id"));
})
loadSolutionPage(shuwon.getUrlParam("cate"));
function loadSolutionPage(cate) {
$(".xqTitle b").html("");
// 智慧车辆隐藏国铁
if (cate == "471999425577746432") {
$(".navFocus a").eq(0).hide();
$(".navFocus a").eq(1).addClass("active");
} else if (cate == "471999350797500416") {
console.log("2")
$(".navFocus a").eq(1).hide();
$(".navFocus a").eq(0).addClass("active");
} else {
console.log("3")
$(".navFocus a").eq(1).show();
$(".navFocus a").eq(2).show();
}
if (cate == "471999454749130752") {
$(".sloganNav.so0 a").eq(1).addClass("active").siblings().removeClass("active");
}
if (cate == "471999425577746432") {
$(".sloganNav.so0 a").eq(2).addClass("active").siblings().removeClass("active");
}
if (cate == "471999395437477888") {
$(".xqTitle").addClass("s1");
$(".xqTitle").removeClass("s2");
soSwiper.slideTo(1, 1000, false);
} else if (cate == "471999350797500416") {
$(".xqTitle").addClass("s2");
$(".xqTitle").removeClass("s1");
soSwiper.slideTo(2, 1000, false);
} else {
$(".xqTitle").removeClass("s1");
$(".xqTitle").removeClass("s2");
soSwiper.slideTo(0, 1000, false);
}
$.get("/apisolution.html", {
cate: cate
}, function(data) {
if (data.code == "200") {
$(".navFocus a").eq(0).addClass("active").siblings().removeClass("active");
if (data.data.solution != null) {
$(".pxTitle").html(data.data.solution.title);
$(".pxDes").html(data.data.solution.content);
$(".solutionImg").css({
"background-image": "url(" + data.data.solution.cover + ")"
})
}
if (data.data.advantage.length != 0) {
html = template('ld', data.data);
$(".soluCase ul").html(html);
}
if (data.data.advantage.length >= 6) {
$(".soluCase").addClass("six");
} else {
$(".soluCase").removeClass("six");
}
if (data.data.guotie.length != 0) {
html2 = template('s1', data.data);
$(".ss1 .swiper-wrapper").html(html2);
$(".ss1").addClass("active");
$(".ss2").removeClass("active");
ss1();
}
if (data.data.chenggui.length != 0) {
html3 = template('s2', data.data);
$(".ss2 .swiper-wrapper").html(html3);
$(".ss2").addClass("active");
$(".ss1").removeClass("active");
$(".navFocus a").eq(1).addClass("active").siblings().removeClass("active");
ss2();
}
$(".navFocus a").click(function() {
$(this).addClass("active").siblings().removeClass("active");
if ($(this).index() == 0) {
$(".ss1").addClass("active");
$(".ss2").removeClass("active");
ss1();
} else {
$(".ss2").addClass("active");
$(".ss1").removeClass("active");
ss2();
}
})
}
})
}
function ss1() {
new Swiper('.swiper-container.ss1', {
slidesPerView: 2,
spaceBetween: 30,
centeredSlides: false,
loop: false,
speed: 500,
autoplay: {
delay: 50000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss1 .swiper-button-next',
prevEl: '.ss1 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
}
function ss2() {
new Swiper('.swiper-container.ss2', {
slidesPerView: 2,
spaceBetween: 30,
centeredSlides: false,
loop: false,
speed: 500,
autoplay: {
delay: 50000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss2 .swiper-button-next',
prevEl: '.ss2 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
}
},
getUrlParam: function(cat) {
var reg = new RegExp("(^|&)" + cat + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return "471999484402860032"; //返回参数值
},
tech: function() {
var options = {
useEasing: true,
useGrouping: true,
separator: ',',
decimal: '.',
prefix: '',
suffix: ''
};
var guonei = new CountUp("guonei", 0, $("#guonei").text(), 0, 2.5, options);
var chenggui = new CountUp("chenggui", 0, $("#chenggui").text(), 0, 2.5, options);
var qian = new CountUp("qian", 0, $("#qian").text(), 0, 2.5, options);
var interleaveOffset = 0.3;
new Swiper('.swiper-container.homeSwiper', {
direction: 'vertical',
speed: 1000,
slidesPerView: 'auto',
watchSlidesProgress: true,
mousewheel: true,
pagination: {
el: '.homeSwiper>.swiper-pagination',
clickable: true,
},
on: {
init: function() {
swiperAnimateCache(this);
swiperAnimate(this);
},
transitionEnd: function() {
swiperAnimate(this);
},
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(0," + innerTranslate + "px,0)";
}
},
touchStart: function() {
var swiper = this;
for (var i = 0; i < swiper.slides.length; i++) {
swiper.slides[i].style.transition = "";
}
},
slideChange: function() {
this.activeIndex != 0 ? $(".header").addClass("open") : $(".header")
.removeClass("open");
if (this.activeIndex == 2) {
setTimeout(function() {
guonei.start();
chenggui.start();
qian.start();
}, 1500)
}
console.log(this.activeIndex)
if (this.activeIndex >= 5) {
$(".tips").addClass("active");
} else {
$(".tips").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";
}
}
},
})
},
cooperation: function() {
shuwon.map();
$(".submitBtn").click(function() {
if ($(this).hasClass("active")) return;
if ($(".userName").val() == "") {
$(".userName").addClass("warning");
$(".submitBtn").removeClass("active");
shuwon.toast('请填写您的姓名', false);
return;
}
if ($(".userTel").val() == "") {
$(".userTel").addClass("warning");
$(".submitBtn").removeClass("active");
shuwon.toast('请填写您的11位手机号码', false);
return;
} else if (!shuwon.regPhone($(".userTel").val())) {
$(".userTel").addClass("warning");
$(".submitBtn").removeClass("active");
shuwon.toast('号码输入错误,请重新输入', false);
return;
}
$.post("/apiform.html", {
name: $(".userName").val(),
phone: $(".userTel").val(),
_csrf: $("#_csrf").val()
}, function(data) {
if (data.code == "200") {
shuwon.toast('提交成功,我们会尽快联系您唷', true);
$(".submitBtn b").html("信息已提交")
} else {
shuwon.toast(data.message, false);
}
})
})
},
product: function() {
new Swiper('.swiper-container.ss1', {
slidesPerView: 1.8,
spaceBetween: 30,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss1 .swiper-button-next',
prevEl: '.ss1 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
new Swiper('.swiper-container.ss2', {
slidesPerView: 1.8,
spaceBetween: 30,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss2 .swiper-button-next',
prevEl: '.ss2 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
new Swiper('.swiper-container.ss3', {
slidesPerView: 1.8,
spaceBetween: 30,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss3 .swiper-button-next',
prevEl: '.ss3 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
new Swiper('.swiper-container.ss4', {
slidesPerView: 1.8,
spaceBetween: 30,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss4 .swiper-button-next',
prevEl: '.ss4 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
new Swiper('.swiper-container.ss5', {
slidesPerView: 1.8,
spaceBetween: 30,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss5 .swiper-button-next',
prevEl: '.ss5 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
},
yunwei: function() {
new Swiper('.swiper-container.ss3', {
slidesPerView: 1.8,
spaceBetween: 0,
centeredSlides: true,
loop: true,
speed: 500,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
navigation: {
nextEl: '.ss3 .swiper-button-next',
prevEl: '.ss3 .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 10
},
//当宽度大于等于768
768: {
slidesPerView: 1,
spaceBetween: 10
},
},
});
},
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的fade切换
*
* 无需传参
* 兼容移动端
*
*/
swiperFade: function() {
new Swiper('.swiper-container.swiperNomal', {
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
spaceBetween: 30,
loop: true,
effect: 'fade',
speed: 500,
pagination: {
el: '.swiper-pagination.dot',
clickable: true,
renderBullet: function(index, className) {
return '0' + (index + 1) + '';
},
},
navigation: {
nextEl: '.btnBox .next',
prevEl: '.btnBox .prev',
},
});
},
/**
*采用swiper的banner切换
*
* 无需传参
* 兼容移动端
*
*/
swiperBanner: function() {
var interleaveOffset = 0.5;
var swiperOptions = {
loop: true,
speed: 1000,
autoplay: true,
grabCursor: true,
watchSlidesProgress: true,
mousewheelControl: true,
keyboardControl: true,
navigation: {
nextEl: ".swiperBanner .swiper-button-next",
prevEl: ".swiperBanner .swiper-button-prev"
},
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);
$('.jgs a').click(function() {
$(this).addClass("active").siblings().removeClass("active");
swiper.slideTo(($(this).index() + 1), 1000, false);
})
},
/**
*回到顶部
*
* 无需传参
* 兼容移动端
*
*/
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("map");
var point = new BMap.Point(104.281995, 31.140276);
map.centerAndZoom(point, 14);
var top_left_control = new BMap.ScaleControl({
anchor: BMAP_ANCHOR_TOP_LEFT
})
var top_left_navigation = new BMap.NavigationControl();
var pt = new BMap.Point(104.281995, 31.140276);
var myIcon = new BMap.Icon("./assets/images/common/mapIcon.png?v=1", new BMap.Size(51, 51));
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");
new Paging('page', {
nowPage: Number(curPage), // 当前页码
pageNum: total, // 总页码
buttonNum: pageSize, //要展示的页码数量
canJump: 0, // 是否能跳转。0=不显示(默认),1=显示
showOne: 1, //只有一页时,是否显示。0=不显示,1=显示(默认)
callback: function(num) { //回调函数
window.location.href = url + num + ".html"
}
})
},
/**
*新闻列表分页
*
* @sucess 成功|失败
* 兼容移动端
*
*/
toast: function(msg, 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的banner切换
*
* 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 {正确:true,错误:false}
*
*/
regPhone: function(phone) {
reg = /^(13|15|17|18|19|14)[0-9]{9}$/;
return reg.test(phone);
},
/**
*验证身份证号码
*
* @phone:身份证号码
* @return {正确:true,错误:false}
*
*/
regID: function(IDcard) {
reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
return reg.test(IDcard);
},
/**
*验证邮箱号码
*
* @Email:身份证号码
* @return {正确:true,错误:false}
*
*/
regEmail: function(Email) {
reg = /^\w+\@+[0-9a-zA-Z]+\.(com|com.cn|edu|hk|cn|net)$/;
return reg.test(Email);
},
/**
*验证是否是中文
*
* @name:文字
* @return {正确:true,错误:false}
*
*/
regZh: function(name) {
reg = /^[\u4E00-\u9FA5A-Za-z]+$/;
return reg.test(name);
},
/**
*验证纯数字
*
* @number:数字
* @return {正确:true,错误:false}
*
*/
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();