var shuwon = {
percent: 0,
timers: "",
init: function(e) {
shuwon.backTop();
$("body").append('
');
$(".menu_btn").click(function() {
$(this).toggleClass("active");
$("nav").toggleClass("active");
$(".headerRight").toggleClass("active");
})
$(".closeIcon").click(function() {
$(".menu_btn,nav,.headerRight").removeClass("active");
})
$('.serach .serachIcon').click(function() {
if ($('#serach').val() == '') {
$('.serach input').css('width', '10vw')
} else {
alert($('#serach').val())
}
})
$('.index').click(function() {
$('.serach input').css('width', '0')
$('#serach').val('')
})
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 100,
mobile: true,
live: true
}).init();
$(".serachIcon").click(function() {
$(".searchLight").addClass("active");
})
$(".searchClose").click(function() {
$(".searchLight").removeClass("active");
})
//鎼滅储鏂伴椈
$(".searchBtn").click(function() {
console.log($(".searchGroup input").val());
if ($(".searchGroup input").val() != "") {
window.open("/search.html?keywords=" + $('.searchGroup input').val());
} else {
shuwon.toast(false, "璇疯緭鍏ュ叧閿瓧")
}
});
$('.searchGroup input').bind('keypress', function(event) {
if (event.keyCode == "13") {
if ($('.searchGroup input').val() == "") return;
window.open("/search.html?keywords=" + $('.searchGroup input').val());
}
});
$("header nav ul li .list a,.fnav .a").click(function() {
setTimeout(function() {
shuwon.scrollToPos(50);
}, 100)
})
var p = 0;
var t = 0;
$(window).scroll(function(e) {
p = $(this).scrollTop();
if (t <= p) {
console.log("涓嬫粴")
$("header").addClass("show")
} else {
$("header").removeClass("show")
console.log("涓婃粴")
}
setTimeout(function() { t = p; }, 0);
});
},
index: function() {
let now = 0;
var indexSwiper = new Swiper('.swiper-container.home', {
direction: 'vertical',
speed: 1200,
slidesPerView: 'auto',
mousewheel: true,
paginationClickable: true,
lazy: {
loadPrevNext: true,
loadPrevNextAmount: 1,
},
on: {
slideChange: function() {
if (this.activeIndex != 0) {
$(".header").addClass("active");
} else {
$(".header").removeClass("active");
}
},
slideChangeTransitionStart: function() {
let activeidx = this.activeIndex;
$("#menu a").removeClass('active');
$("#menu a").eq(activeidx).addClass('active');
if (this.activeIndex != 0) {
$("header").addClass("active");
} else {
$("header").removeClass("active");
}
setTimeout(function() {
var z = activeidx;
if (z < now) {
$("header").removeClass("show")
} else {
$("header").addClass("show")
}
now = z;
}, 30);
},
}
})
$("#menu a").eq(0).addClass('active');
$("#menu a").click(function() {
var idx = $(this).index()
$("#menu a").removeClass('active')
$("#menu a").eq(idx).addClass('active')
indexSwiper.slideTo(idx, 800)
})
new Swiper(".bannerSwiper", {
autoplay: {
delay: 5000,
disableOnInteraction: true
},
speed: 1200,
loop: true,
pagination: {
el: ".swiper-pagination"
}
});
shuwon.app_swiper();
var appArrTop = [-180, -30, 120];
var appArrLeft = [-90, -50, -90];
for (var i = 0; i < 3; i++) {
$(".clock_list ul li").eq(i).css({ top: appArrTop[i], left: appArrLeft[i] });
}
var n = 1;
// var clockInter = setInterval(function(){
// n++;
// if(n>2) n = 0;
// loopMove(n);
// },5000)
function loopMove(j) {
$(".clock_list ul li").eq(j).addClass("active").siblings().removeClass("active");
if (j == 0) {
appArrTop = [-30, 120, 200];
appArrLeft = [-50, -90, -200];
}
$(".pro_box ul li").eq(j).addClass("active").siblings().removeClass("active");
$(".box3 .right ul li").eq(j).addClass("active").siblings().removeClass("active");
if (j == 1) {
appArrTop = [-180, -30, 120];
appArrLeft = [-90, -50, -90];
}
if (j == 2) {
appArrTop = [-290, -180, -30];
appArrLeft = [-200, -90, -50];
}
for (var i = 0; i < 3; i++) {
$(".clock_list ul li").eq(i).css({ top: appArrTop[i], left: appArrLeft[i] });
}
}
$(".clock_list ul li .name .icon").hover(function() {
var index = $(this).parent().parent().index();
// loopMove(index);
// clearInterval(clockInter)
$(".clock_list ul li").eq(index).addClass("active").siblings().removeClass("active");
$(".clocks ul li").eq(index).addClass("active").siblings().removeClass("active");
$(".pro_box ul li").eq(index).addClass("active").siblings().removeClass("active");
$(".box3 .right ul li").eq(index).addClass("active").siblings().removeClass("active");
})
var interleaveOffset = 0.5;
var swiperOptions = {
loop: false,
speed: 1000,
delay: 5000,
autoplay: {
disableOnInteraction: false,
},
watchSlidesProgress: true,
on: {
slideChange: function() {
},
setTransition: function(speed) {}
}
};
var appswiper = new Swiper(".homeappSwiper", swiperOptions);
},
about: function() {
$(".laberBox ol li").click(function() {
$(".lightBox").addClass("active");
$(".lightBox .tittle").html($(this).attr("data-title"));
$.get("/apijob.html", {
id: $(this).attr("data-id")
}, function(data) {
if (data.code == "200") {
$(".lightBox .summary-join").html(data.data.content);
}
})
})
$(".close").click(function() {
$(".lightBox").removeClass("active");
})
shuwon.app_swiper();
shuwon.map();
shuwon.scrollToPos(50);
},
product: function() {
new Swiper(".appSwiper", {
pagination: {
el: ".swiper-pagination",
},
});
var cate = $(".c-table").attr("data-id");
var html, html2, html3, html4 = "";
var words = "";
getProductData(cate, words);
function getProductData(id, keywords) {
$('.colgroup').html("");
$('.thead').html("");
$.post("/apipro.html", { id: id, keywords: keywords }, function(data) {
if (data.code == "200") {
html = template('plist', data.data);
html2 = template('list_head', data.data);
html3 = template('thead', data.data);
$('.tbody').html(html);
$('.colgroup').html(html2);
$('.thead').html(html3);
// $('[role="c-table"]').jqTable({
// fixedLeft: 1,
// });
var num = 0;
for (var i = 0; i < data.data.table[0].length; i++) {
num += Number($(".header_tr th").eq(i).attr("width"));
}
$(".table_width").css({ width: num + "px" })
// 璐墿杞
var myData = [];
$(".cart").click(function() {
var list = { "id": "", "code": "", number: 1 };
if ($(this).hasClass("active")) {
shuwon.toast(false, "璇ヤ骇鍝佸凡缁忔坊鍔?)
return;
}
$(this).addClass("active");
list.id = $(this).attr("data-id");
list.code = $(this).attr("data-code");
myData.push(list);
$('.car_table').html("");
getData(myData)
shuwon.toast(true, "娣诲姞鎴愬姛")
})
function getData(arr) {
console.log(arr)
if (arr.length > 0) {
html4 = template('cartable', { list: arr });
$('.car_table').html(html4);
$(".sls").html(arr.length)
$(".carBar").addClass("active")
$(".delete").click(function() {
arr.splice($(this).attr("data-id"), 1);
getData(arr);
})
} else {
$(".cart").removeClass("active");
$(".car_table").html("璇锋坊鍔犺浠蜂骇鍝佹垨鏍峰搧
")
$(".carBar").removeClass("active")
}
$(".car_submit").click(function() {
if ($(".car_submit").hasClass("active")) {
return;
}
$(".car_submit").addClass("active");
if ($(".companys").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欎紒涓氬悕绉?)
return;
}
if ($(".user_name").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勫鍚?)
return;
}
if ($(".user_tel").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勬墜鏈哄彿鐮?)
return;
} else if (!shuwon.regPhone($(".user_tel").val())) {
$(".car_submit").removeClass("active");
shuwon.toast(false, "鎵嬫満鍙风爜鏍煎紡閿欒")
return;
}
$.post("/apixunjia.html", {
email: $(".companys").val(),
name: $(".user_name").val(),
phone: $(".user_tel").val(),
content: myData
}, function(data) {
if (data.code == "200") {
$(".lightBox").removeClass("active");
shuwon.toast(true, "鎻愪氦鎴愬姛")
} else {
shuwon.toast(false, data.message)
$(".car_submit").removeClass("active");
}
})
})
}
}
})
}
getProductNav(cate, words);
function getProductNav(id, keywords) {
$.post("/apipro.html", { id: id, keywords: keywords }, function(data) {
if (data.code == "200") {
var html5 = "";
html5 = template('search_list', { search: data.data.search[0] });
$('.pro_row').html(html5);
var allSearch = [];
var singeSearch = [];
// 璧涢€夋潯浠
$(".de_list .li").click(function() {
singeSearch = [];
$(this).parent().prev().html($(this).text()).addClass("active");
singeSearch.push($(this).attr("data-name"))
singeSearch.push($(this).attr("data-value"))
allSearch[$(this).attr("data-index")] = singeSearch;
getProductData(cate, JSON.stringify(allSearch));
})
$(".de_list .li.clearall").click(function() {
singeSearch = [];
allSearch[$(this).attr("data-index")] = singeSearch;
getProductData(cate, JSON.stringify(allSearch));
$(this).parent().prev().html("璇烽€夋嫨鏁板€?).removeClass("active");
})
}
})
}
$(".carBar").click(function() {
$(".lightBox").addClass("active");
})
$(".car_close,.table_tips").click(function() {
$(".lightBox").removeClass("active");
})
},
productEn: function() {
new Swiper(".appSwiper", {
pagination: {
el: ".swiper-pagination",
},
});
var cate = $(".c-table").attr("data-id");
var html, html2, html3, html4 = "";
var words = "";
getProductData(cate, words);
function getProductData(id, keywords) {
$('.colgroup').html("");
$('.thead').html("");
$.post("/apipro.html", { id: id, keywords: keywords }, function(data) {
if (data.code == "200") {
html = template('plist', data.data);
html2 = template('list_head', data.data);
html3 = template('thead', data.data);
$('.tbody').html(html);
$('.colgroup').html(html2);
$('.thead').html(html3);
// $('[role="c-table"]').jqTable({
// fixedLeft: 1,
// });
var num = 0;
for (var i = 0; i < data.data.table[0].length; i++) {
num += Number($(".header_tr th").eq(i).attr("width"));
}
$(".table_width").css({ width: num + "px" })
// 璐墿杞
var myData = [];
$(".cart").click(function() {
var list = { "id": "", "code": "", number: 1 };
if ($(this).hasClass("active")) {
shuwon.toast(false, "This product has been added")
return;
}
$(this).addClass("active");
list.id = $(this).attr("data-id");
list.code = $(this).attr("data-code");
myData.push(list);
$('.car_table').html("");
getData(myData)
shuwon.toast(true, "Added successfully")
})
function getData(arr) {
console.log(arr)
if (arr.length > 0) {
html4 = template('cartable', { list: arr });
$('.car_table').html(html4);
$(".sls").html(arr.length)
$(".carBar").addClass("active")
$(".delete").click(function() {
arr.splice($(this).attr("data-id"), 1);
getData(arr);
})
} else {
$(".cart").removeClass("active");
$(".car_table").html("Please add product
")
$(".carBar").removeClass("active")
}
$(".car_submit").click(function() {
if ($(".car_submit").hasClass("active")) {
return;
}
$(".car_submit").addClass("active");
if ($(".companys").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter company name")
return;
}
if ($(".user_name").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter your name")
return;
}
if ($(".user_tel").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter your tel")
return;
} else if (!shuwon.regPhone($(".user_tel").val())) {
$(".car_submit").removeClass("active");
shuwon.toast(false, "wrong phone format")
return;
}
$.post("/apixunjia.html", {
email: $(".companys").val(),
name: $(".user_name").val(),
phone: $(".user_tel").val(),
content: myData
}, function(data) {
if (data.code == "200") {
$(".lightBox").removeClass("active");
shuwon.toast(true, "Submitted successfully")
} else {
shuwon.toast(false, data.message)
$(".car_submit").removeClass("active");
}
})
})
}
}
})
}
getProductNav(cate, words);
function getProductNav(id, keywords) {
$.post("/apipro.html", { id: id, keywords: keywords }, function(data) {
if (data.code == "200") {
var html5 = "";
html5 = template('search_list', { search: data.data.search[0] });
$('.pro_row').html(html5);
var allSearch = [];
var singeSearch = [];
// 璧涢€夋潯浠
$(".de_list .li").click(function() {
singeSearch = [];
$(this).parent().prev().html($(this).text()).addClass("active");
singeSearch.push($(this).attr("data-name"))
singeSearch.push($(this).attr("data-value"))
allSearch[$(this).attr("data-index")] = singeSearch;
getProductData(cate, JSON.stringify(allSearch));
})
$(".de_list .li.clearall").click(function() {
singeSearch = [];
allSearch[$(this).attr("data-index")] = singeSearch;
getProductData(cate, JSON.stringify(allSearch));
$(this).parent().prev().html("璇烽€夋嫨鏁板€?).removeClass("active");
})
}
})
}
$(".carBar").click(function() {
$(".lightBox").addClass("active");
})
$(".car_close,.table_tips").click(function() {
$(".lightBox").removeClass("active");
})
},
application: function() {
new Swiper(".appSwiper", {
pagination: {
el: ".swiper-pagination",
},
});
var cate = $(".c-table").attr("data-id");
var html, html2, html3, html4 = "";
$.get("/apiapplication.html", { id: cate }, function(data) {
if (data.code == "200") {
html = template('list', data.data);
html2 = template('list_head', data.data);
html3 = template('thead', data.data);
$('.tbody').html(html);
$('.colgroup').html(html2);
$('.thead').html(html3);
$('[role="c-table"]').jqTable({
fixedLeft: 1,
});
// 璐墿杞
var myData = [];
$(".cart").click(function() {
var list = { "id": "", "code": "", number: 1 };
if ($(this).hasClass("active")) {
shuwon.toast(false, "璇ヤ骇鍝佸凡缁忔坊鍔?)
return;
}
$(this).addClass("active");
list.id = $(this).attr("data-id");
list.code = $(this).attr("data-code");
myData.push(list);
$('.car_table').html("");
getData(myData)
shuwon.toast(true, "娣诲姞鎴愬姛")
})
function getData(arr) {
console.log(arr)
if (arr.length > 0) {
html4 = template('cartable', { list: arr });
$('.car_table').html(html4);
$(".sls").html(arr.length)
$(".carBar").addClass("active")
$(".delete").click(function() {
arr.splice($(this).attr("data-id"), 1);
getData(arr);
})
} else {
$(".cart").removeClass("active");
$(".car_table").html("璇锋坊鍔犺浠蜂骇鍝佹垨鏍峰搧
")
$(".carBar").removeClass("active")
}
$(".car_submit").click(function() {
if ($(".car_submit").hasClass("active")) {
return;
}
$(".car_submit").addClass("active");
if ($(".companys").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欎紒涓氬悕绉?)
return;
}
if ($(".user_name").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勫鍚?)
return;
}
if ($(".user_tel").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勬墜鏈哄彿鐮?)
return;
} else if (!shuwon.regPhone($(".user_tel").val())) {
$(".car_submit").removeClass("active");
shuwon.toast(false, "鎵嬫満鍙风爜鏍煎紡閿欒")
return;
}
$.post("/apixunjia.html", {
email: $(".companys").val(),
name: $(".user_name").val(),
phone: $(".user_tel").val(),
content: myData
}, function(data) {
if (data.code == "200") {
$(".lightBox").removeClass("active");
shuwon.toast(true, "鎻愪氦鎴愬姛")
} else {
shuwon.toast(false, data.message)
$(".car_submit").removeClass("active");
}
})
})
}
}
})
$(".carBar").click(function() {
$(".lightBox").addClass("active");
})
$(".car_close,.table_tips").click(function() {
$(".lightBox").removeClass("active");
})
},
applicationEn: function() {
new Swiper(".appSwiper", {
pagination: {
el: ".swiper-pagination",
},
});
var cate = $(".c-table").attr("data-id");
var html, html2, html3, html4 = "";
// $.get("/apipro.html",{id:cate},function(data){
$.get("/apiapplication.html", { id: cate }, function(data) {
if (data.code == "200") {
html = template('list', data.data);
html2 = template('list_head', data.data);
html3 = template('thead', data.data);
$('.tbody').html(html);
$('.colgroup').html(html2);
$('.thead').html(html3);
$('[role="c-table"]').jqTable({
fixedLeft: 1,
});
// 璐墿杞
var myData = [];
$(".cart").click(function() {
var list = { "id": "", "code": "", number: 1 };
if ($(this).hasClass("active")) {
shuwon.toast(false, "This product has been added")
return;
}
$(this).addClass("active");
list.id = $(this).attr("data-id");
list.code = $(this).attr("data-code");
myData.push(list);
$('.car_table').html("");
getData(myData)
shuwon.toast(true, "Added successfully")
})
function getData(arr) {
console.log(arr)
if (arr.length > 0) {
html4 = template('cartable', { list: arr });
$('.car_table').html(html4);
$(".sls").html(arr.length)
$(".carBar").addClass("active")
$(".delete").click(function() {
arr.splice($(this).attr("data-id"), 1);
getData(arr);
})
} else {
$(".cart").removeClass("active");
$(".car_table").html("Please add product
")
$(".carBar").removeClass("active")
}
$(".car_submit").click(function() {
if ($(".car_submit").hasClass("active")) {
return;
}
$(".car_submit").addClass("active");
if ($(".companys").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter company name")
return;
}
if ($(".user_name").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter your name")
return;
}
if ($(".user_tel").val() == "") {
$(".car_submit").removeClass("active");
shuwon.toast(false, "Please enter your tel")
return;
} else if (!shuwon.regPhone($(".user_tel").val())) {
$(".car_submit").removeClass("active");
shuwon.toast(false, "wrong phone format")
return;
}
$.post("/apixunjia.html", {
email: $(".companys").val(),
name: $(".user_name").val(),
phone: $(".user_tel").val(),
content: myData
}, function(data) {
if (data.code == "200") {
$(".lightBox").removeClass("active");
shuwon.toast(true, "Submitted successfully")
} else {
shuwon.toast(false, data.message)
$(".car_submit").removeClass("active");
}
})
})
}
}
})
$(".carBar").click(function() {
$(".lightBox").addClass("active");
})
$(".car_close,.table_tips").click(function() {
$(".lightBox").removeClass("active");
})
},
report: function() {
shuwon.scrollToPos(50);
var cate = $(".yqs").attr("data-id");
var html, html2, html3, html4 = "";
$.get("/apireport.html", { id: cate }, function(data) {
if (data.code == "200") {
html = template('list', data.data);
html2 = template('list_head', data.data);
html3 = template('thead', data.data);
$('.tbody').html(html);
$('.colgroup').html(html2);
$('.thead').html(html3);
$('[role="c-table"]').jqTable({
fixedLeft: 1,
});
}
})
$(".carBar").click(function() {
$(".lightBox").addClass("active");
})
$(".car_close,.table_tips").click(function() {
$(".lightBox").removeClass("active");
})
},
form: function() {
var type = 1;
if ($(".sub_title b").text() == "璇锋眰婕旂ず") {
type = 1;
} else {
type = 2;
}
$(".submit").click(function() {
if ($(".submit").hasClass("active")) {
return;
}
$(".submit").addClass("active");
if ($(".user_name").val() == "") {
$(".submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勫鍚?)
return;
}
if ($(".user_tel").val() == "") {
$(".submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勬墜鏈哄彿鐮?)
return;
} else if (!shuwon.regPhone($(".user_tel").val())) {
$(".submit").removeClass("active");
shuwon.toast(false, "鎵嬫満鍙风爜鏍煎紡閿欒")
return;
}
if ($(".user_mail").val() == "") {
$(".submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欐偍鐨勯偖绠?)
return;
} else if (!shuwon.regEmail($(".user_mail").val())) {
$(".submit").removeClass("active");
shuwon.toast(false, "閭鏍煎紡閿欒")
return;
}
if ($(".user_msg").val() == "") {
$(".submit").removeClass("active");
shuwon.toast(false, "璇峰~鍐欑暀瑷€淇℃伅")
return;
}
$.post("/apiform.html", {
name: $(".user_name").val(),
phone: $(".user_tel").val(),
email: $(".user_mail").val(),
content: $(".user_msg").val(),
field_1: type
}, function(data) {
if (data.code == "200") {
shuwon.toast(true, "鎻愪氦鎴愬姛")
} else {
shuwon.toast(false, data.message)
$(".submit").removeClass("active");
}
})
})
},
map: function() {
var _point = [
[104.071173, 30.5444],
[104.071173, 30.5444],
]
var map = new BMap.Map("allmap");
for (var i = 0; i <= _point.length - 1; i++) {
var point = new BMap.Point(_point[i][0], _point[i][1]);
var marker = new BMap.Marker(point); // 鍒涘缓鏍囨敞
map.addOverlay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓
}
map.centerAndZoom(point, 15);
var top_left_navigation = new BMap.NavigationControl();
map.addControl(top_left_navigation);
$('.map_list ul li').hover(function(e) {
var i = $(this).index()
$(this).addClass('active').siblings().removeClass('active')
map.centerAndZoom(new BMap.Point(_point[i][0], _point[i][1]), 15);
})
},
app_swiper: function() {
var interleaveOffset = 0.5;
var swiperOptions = {
loop: false,
speed: 1000,
autoplay: false,
grabCursor: true,
watchSlidesProgress: true,
mousewheelControl: false,
keyboardControl: false,
navigation: {
nextEl: ".swiper-button-next.snext",
prevEl: ".swiper-button-prev.sprev"
},
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 = "";
}
console.log(this.activeIndex)
},
slideChange: function() {
$('.TabUl li').eq(this.activeIndex).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.jinguan", swiperOptions);
$('.TabUl li').hover(function() {
$(this).addClass("active").siblings().removeClass("active");
swiper.slideTo(($(this).index()), 1000, 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);
}
}
},
/**
*鏂伴椈鍒楄〃鍒嗛〉
*
* 鏃犻渶浼犲弬
* 鍏煎绉诲姩绔
*
*/
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, // 鏄惁鑳借烦杞€?=涓嶆樉绀猴紙榛樿锛夛紝1=鏄剧ず
showOne: 1, //鍙湁涓€椤垫椂锛屾槸鍚︽樉绀恒€?=涓嶆樉绀?1=鏄剧ず锛堥粯璁わ級
callback: function(num) { //鍥炶皟鍑芥暟
window.location.href = url + num + ".html"
}
})
},
/**
*鏂伴椈鍒楄〃鍒嗛〉
*
* @sucess 鎴愬姛|澶辫触
* 鍏煎绉诲姩绔
*
*/
toast: function(sucess, msg) {
$(".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();