var shuwon = {
percent: 0,
timers: "",
init: function(e) {
$("body").append('
');
$("body").append('
');
$(".submitBtn").click(function() {
// if ($(this).hasClass("active")) return;
// $(this).addClass("active");
var root='';
$.post(root+"/H/Message/last_add2",$(".agag").serialize(),function(data){
if(data.status==1){
layer.alert(data.info,{icon:1});
$(':input','.agag')
.not(':button, :submit, :reset, :hidden')
.val('')
.removeAttr('checked')
.removeAttr('selected');
}else{
layer.alert(data.info,{icon:0});
return false;
}
},"json")
// if ($(".userCompany").val() == "") {
// $(".userCompany").addClass("warning");
// $(".submitBtn").removeClass("active");
// shuwon.toast('璇峰~鍐欏叕鍙稿悕绉?, false);
// 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('璇峰~鍐欐偍鐨?1浣嶆墜鏈哄彿鐮?, false);
// return;
// } else if (!shuwon.regPhone($(".userTel").val())) {
// $(".userTel").addClass("warning");
// $(".submitBtn").removeClass("active");
// shuwon.toast('鍙风爜杈撳叆閿欒锛岃閲嶆柊杈撳叆', false);
// return;
// }
// if ($(".userMsg").val() == "") {
// $(".userMsg").addClass("warning");
// $(".submitBtn").removeClass("active");
// shuwon.toast('璇风畝瑕佸~鍐欐偍鐨勯渶姹?, false);
// return;
// }
// $.post("/apiform.html", {
// name: $(".userName").val(),
// phone: $(".userTel").val(),
// field_1: $(".userCompany").val(),
// content: $(".userMsg").val(),
// field_2: "铚€缇庡畼缃慶om"
// }, function(data) {
// if (data.code == "200") {
// shuwon.toast('鎻愪氦鎴愬姛锛屾垜浠細灏藉揩鑱旂郴鎮ㄥ敺', true);
// $(".submitBtn p").html("淇℃伅宸叉彁浜?)
// } else {
// shuwon.toast(data.message, false);
// }
// })
})
shuwon.backTop();
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 100,
mobile: true,
live: true
}).init();
$(".lazy").lazyload({
effect: "fadeIn"
});
$(".menu_btn").click(function(){
$(".navBar").toggleClass("active");
$(this).toggleClass("active");
})
$(".navBar .mask").click(function(){
$(".navBar").removeClass("active");
$(".menu_btn").removeClass("active");
})
},
index: function() {
new Swiper('.banner-swiper', {
speed: 1000,
slidesPerView: 1,
autoplay: {
disableOnInteraction: false,
delay: 4000
},
loop: true,
});
new Swiper('.testSwiper', {
speed: 1000,
slidesPerView: 1,
loop: true,
autoplay: {
delay: 5000
},
autoHeight: true,
pagination: {
el: '.testSwiper .swiper-pagination',
},
});
var st1 = $(".bgs1").offset().top;
var st2 = $(".bgs2").offset().top;
var st3 = $(".bgs3").offset().top;
var st4 = $(".bgs4").offset().top;
var speed = 0.1;
$(window).scroll(function() {
var sTop = $(window).scrollTop();
parallaxBg($(".bgs1"), sTop, st1, speed);
parallaxBg($(".bgs2"), sTop, st2, speed);
parallaxBg($(".bgs3"), sTop, st3, speed);
parallaxBg($(".bgs4"), sTop, st3, speed);
});
function parallaxBg(ele, sTop, startTop, speed) {
if ($(window).width() > 768) {
ele.css({
"background-position": "0px " + (sTop - startTop) * -speed + "px"
})
}
}
},
mobile:function(){
$('.dowebok').liMarquee({scrollamount: 20});
new Swiper('.testSwiper', {
speed: 1000,
slidesPerView: 1,
loop: true,
autoplay: {
delay: 5000
},
autoHeight: false,
pagination: {
el: '.testSwiper .swiper-pagination',
},
});
new Swiper('.swiper-container.caseNav', {
slidesPerView: 'auto',
spaceBetween: 10,
});
new Swiper('.swiper-container.serviceSwiper', {
watchSlidesProgress : true, //鏌ョ湅slide鐨刾rogress
resistanceRatio : 0, //绂佹杈圭紭绉诲姩
on: {
init: function(){
slides = this.slides
for(i=0; i< slides.length; i++){
slide = slides.eq(i)
slide.css('zIndex', 100-i); //璁剧疆slide鐨剒-index灞傜骇
}
},
resize: function(swiper){
swiper.update()
},
setTranslate: function(){
slides = this.slides
offsetAfter = this.width*0.75 //姣忎釜slide鐨勪綅绉诲€
for(i=0; i< slides.length; i++){
slide = slides.eq(i)
progress = slides[i].progress
if(progress <= 0){ //鍙宠竟slide浣嶇Щ
slide.transform('translate3d('+(progress)*offsetAfter+'px, 0, 0) scale('+(1 - Math.abs(progress)/20)+')');
slide.css('opacity',(progress+3)); //鏈€鍙宠竟slide閫忔槑
}
if(progress > 0){
slide.transform('rotate('+ (-progress)*5+'deg)'); //宸﹁竟slide鏃嬭浆
slide.css('opacity',1 - progress); //宸﹁竟slide閫忔槑
}
}
},
setTransition: function(swiper, transition) {
for (var i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i)
slide.transition(transition);
}
},
},
});
},
h5: function() {
$(window).scroll(function() {
var sTop = $(window).scrollTop();
if($(window).width()>768){
$(".h5Ball .bg").css({
"top": sTop * -0.1 + "px"
})
}
})
// $(".earthNav a").hover(function(){
// $(this).addClass("active").siblings().removeClass("active");
// $(".screenImg ul li").eq($(this).index()).addClass("active").siblings().removeClass("active");
// })
var ttxs = document.getElementById('shuwon')
$('.ptn').click(function (e) {
if ($(this).hasClass("active")) {
ttxs.pause()
$(".ptn").removeClass("active");
} else {
ttxs.play()
$(".ptn").addClass("active");
}
})
if ($(window).width() <768) {
console.log("dd")
$("#shuwon").attr({"controls":"controls"});
}
},
seo: function() {
new Swiper('.swiper-container.seoSwiper', {
speed: 800,
direction: 'vertical',
mousewheel: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
on: {
init: function() {
swiperAnimateCache(this);
swiperAnimate(this);
},
slideChangeTransitionEnd: function() {
swiperAnimate(this);
}
}
});
},
getQueryVariable: function(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
},
caseApi: function(type) {
},
case: function() {
new Swiper('.swiper-container.caseNav', {
slidesPerView: 'auto',
spaceBetween: 10,
});
$(".commonTitle").addClass("active");
},
app: function() {
const $circle = document.querySelector('.card__circle');
const $smallCircle = document.querySelector('.card__smallCircle');
const $year = document.querySelector('.card__year');
const $card = document.querySelector('.card');
const $cardOrangeShine = document.querySelector('.card__orangeShine');
// const $cardThankYou = document.querySelector('.card__thankyou');
const $cardComet = document.querySelector('.card__cometOuter');
const generateTranslate = (el, e, value) => {
el.style.transform = `translate(${e.clientX * value}px, ${e.clientY * value}px)`;
};
// http://stackoverflow.com/a/1480137
const cumulativeOffset = element => {
var top = 0,
left = 0;
do {
top += element.offsetTop || 0;
left += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return {
top: top,
left: left
};
};
document.onmousemove = event => {
const e = event || window.event;
const x = (e.pageX - cumulativeOffset($card).left - $(window).width() / 2 / 2) * -1 / 100;
const y = (e.pageY - cumulativeOffset($card).top - $(window).width() / 2 / 2) * -1 / 100;
const matrix = [
[1, 0, 0, -x * 0.00005],
[0, 1, 0, -y * 0.00005],
[0, 0, 1, 1],
[0, 0, 0, 1]
];
generateTranslate($smallCircle, e, 0.03);
// generateTranslate($cardThankYou, e, 0.03);
generateTranslate($cardOrangeShine, e, 0.09);
generateTranslate($circle, e, 0.05);
// generateTranslate($year, e, 0.03);
generateTranslate($cardComet, e, 0.05);
$card.style.transform = `matrix3d(${matrix.toString()})`;
};
},
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: 5000,
disableOnInteraction: false,
},
spaceBetween: 30,
loop: true,
effect: 'fade',
speed: 500,
lazy: {
loadPrevNext: true,
},
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() {
$(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");
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(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鐨刡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();