/**
* Created by haox on 2017/1/22.
* 首页js
*/
//Swiper
var Swiper = function(){
this.init();
}
Swiper.prototype.init = function(){
Qfast.add('widgets', {
path: "http://skin.aolaigo.com//js/source/public/terminator2.2.min.js",
type: "js",
requires: ['fx']
});
Qfast(false, 'widgets', function () {
K.tabs({
id: 'indbig', //焦点图包裹id
conId: "indbigcon", //** 大图域包裹id
tabId: "indbigtab",
tabTn: "a",
conCn: '.fcon', //** 大图域配置class
auto: 1, //自动播放 1或0top_banners
effect: 'fade', //效果配置
eType: 'mouseover', //** 鼠标事件
pageBt: true,//是否有按钮切换页码
bns: ['.prevv3', '.nextv3'],//** 前后按钮配置class
interval: 3000 //** 停顿时间
})
})
}
//Seckill option{'endTime': '2017/2/07 18:30'}结束时间
var Seckill = function(option){
this.endTime = option.endTime;
this.timeInterval = null;
this.init();
}
Seckill.prototype.init = function(){
this.lastTimeInit();
this.cxScrollInit();
}
Seckill.prototype.cxScrollInit = function(){
$('#seckill-scroll').cxScroll({'scrollCallback':function(){
$('body,html').trigger("scroll");
},'auto':false});
var dom = $('#seckill-scroll');
dom.find("img.te-lazy-100-scroll").lazyload({
effect: 'fadeIn',
load: function () {
$(this).css({"width":"100%"});
}
});
}
Seckill.prototype.lastTimeInit =function(){
var xthis = this;
xthis.timeInterval = setInterval(function(){
xthis.refreshLastTime(window.diff);
},1000);
}
Seckill.prototype.refreshLastTime = function(diff,countDay){
var delay = (new Date()).getTime() - parseInt(diff);
delay = (new Date(this.endTime)).getTime() - delay;
if(delay>0){
var leftsecond = parseInt(delay / 1000);
var day =countDay?Math.floor(leftsecond / (60 * 60 * 24)):0;
var hour = Math.floor((leftsecond - day * 24 * 60 * 60) / 3600);
if(hour<10){hour="0"+hour };
var minute = Math.floor((leftsecond - day * 24 * 60 * 60 - hour * 3600) / 60);
if(minute<10){minute="0"+minute };
var second = Math.floor(leftsecond - day * 24 * 60 * 60 - hour * 3600 - minute * 60);
if(second<10){second="0"+second };
var html = ' 距离本场结束' +
' '+hour+'' +
' : ' +
''+minute+' ' +
':' +
''+second+'';
}else{
var html = ' 本场已结束' ;
clearInterval(this.timeInterval);
}
$(".Seckill").find('.bar').html(html);
}
//Feature
var Feature = function(){
this.thisOffset = [];
this.init();
}
Feature.prototype.init = function(){
this.shadowInit();
}
//shadowInit
Feature.prototype.shadowInit = function(){
var xthis = this;
$('.brandNew-item').each(function(){
var xOffset = $(this).offset();
xthis.thisOffset.push([
xOffset.top,
xOffset.left+232,
xOffset.top+350,
xOffset.left]);
})
$('.brandNew-item').hover(function(event){
var direct = xthis.checkIndirect([event.clientY + $(document).scrollTop(),event.clientX],$(this).index());
$(this).find(".brandNew-shadow").stop(false,true);
var shadow = $(this).find('.brandNew-shadow');
switch(direct)
{
case "0":
shadow.css({"top":-350,"left":0});
shadow.animate({"top":0});
break;
case "3":
shadow.css({"top":0,"left":-232});
shadow.animate({"left":0});
break;
case "1":
shadow.css({"top":0,"left":232});
shadow.animate({"left":0});
break;
case "2":
shadow.css({"top":350,"left":0});
shadow.animate({"top":0});
break;
default:;
}
},function(event){
$(this).find(".brandNew-shadow").stop(false,true);
var shadow = $(this).find('.brandNew-shadow');
var direct = xthis.checkIndirect([event.clientY + $(document).scrollTop(),event.clientX],$(this).index());
switch(direct)
{
case "0":
shadow.animate({"top":-350});
break;
case "3":
shadow.animate({"left":-232});
break;
case "1":
shadow.animate({"left":232});
break;
case "2":
shadow.animate({"top":350});
break;
default:;
}
})
}
Feature.prototype.checkIndirect = function(position,index){
var tempArr = [
Math.abs(this.thisOffset[index][0] - position[0]),
Math.abs(this.thisOffset[index][1] - position[1]),
Math.abs(this.thisOffset[index][2] - position[0]),
Math.abs(this.thisOffset[index][3] - position[1])];
var tempMin = Math.min.apply(null,tempArr);
for (var i in tempArr){
if(tempArr[i] == tempMin){
return i;
}
}
}
//全屏弹窗 {'isShow': true, 'during': 5000}isShow 是否显示 during延迟时间
var FullPop = function(option){
this.option = option;
this.init();
}
FullPop.prototype.init = function(){
var xthis = this;
if(this.option.isShow && (!$.cookie('fullPopClosed'))){
$(".fullPop-img").load(function(){
$(".FullPop").show();
$(".FullPop>.content").animate({'top':'200px'},1000);
setTimeout(function(){
$(".FullPop").hide();
},xthis.option.during)
$(".fullPop-close").click(function(){
$(".FullPop").hide();
$.cookie('fullPopClosed','true');
})
});
}
}
//底部弹窗 {'isShow': true, 'during': 5000}isShow 是否显示 during延迟时间
var FootPop = function (option){
this.footPop = option;
this.init();
}
FootPop.prototype.init = function(){
if(this.footPop.isShow && (!$.cookie('footPopClosed'))){
$(".FootPop").show();
setTimeout(function(){
$(".FootPop").hide();
},this.footPop.during)
$(".FootPop-close").click(function(){
$(".FootPop").hide();
$.cookie('footPopClosed','true');
})
}
}
//首页楼层选项卡效果左侧栏,楼层动画,楼层滚动
var Index = function(){
this.cardInfo = [];
this.left = $(".Left");
this.isLeft = true;
this.visible=false;
this.init();
}
Index.prototype.init = function(){
var that = this;
this.leftInit();
this.floorInit();
this.cxScrollInit();
$(function () {
that.searchFix();
});
}
Index.prototype.floorInit = function(){
var xthis = this;
var leftLi = xthis.left.find("li");
var windowH =$(window).height();
$('.i-visiable').each(function(){
xthis.cardInfo.push({
"top":$(this).offset().top,
"dom":$(this),
"height":$(this).height()
});
});
function _onResize() {
windowH = $(window).height();
if($(window).width() < 1385){
xthis.isLeft = false;
}else{
xthis.isLeft = true;
}
}
$(window).resize(_onResize);
_onResize();
$(window).scroll(function(){
var scrollTop = $(this).scrollTop() + windowH;
if(scrollTop>1300 && xthis.isLeft){
xthis.addLeft();
}else{
xthis.removeLeft();
}
for(var i=0;i0){
if($('.Stick').offset().top){
var h= $('.Stick').offset().top;
}else{
}
}
var l = $('.top-main-cont').offset().left;
if(h&&s){
if(s>=h){
$('.searchFix').css('display','block');
/* $('.searchFix').append($('.top-select-tit'));*/
$('.top-select').css({'position':'fixed','z-index':'99','top':'3px','left':l+'px'})
.find('.top-select-cont').css('display','none');
$('.top-select-tit').mouseover(function(){
$('.top-select-cont').css('display','block');
})
$('.top-select-cont').mouseover(function(){
$(this).css('display','block');
})
$('.top-select-cont').mouseout(function(){
$(this).css('display','none');
})
$('.p_relative').css('position','static');
$('.itop-sh').css({'position':'fixed','z-index':'99','top':'5px','left':(l+445)+'px'}).find('.itop-sh-list').css('display','none');
$('.shopping-car').css({'position':'fixed','z-index':'99','top':'5px','left':(l+1110)+'px'});
}else{
$('.searchFix').css('display','none');
$('.itop-sh').css({'position':'absolute','top':'30px','left':'355px'}).find('.itop-sh-list').css('display','block');
$('.shopping-car').css({'position':'relative','left':'0px','top':'0px'});
$('.top-select').css({'position':'relative','z-index':'99','top':'0px','left':'0px'}).find('.top-select-cont').css('display','block');
$('.top-select-cont').mouseout(function(){
$(this).css('display','block');
})
$('.p_relative').css('position','relative');
}
}
});
$(window).resize(function(){
$(this).trigger('scroll');
})
window.onbeforeunload = function () {
if (event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey) {
} else {
window.scrollTo('0', '0');
}
}
}
Index.prototype.addLeft = function(){
// this.left.removeClass("l-visiable");
if(this.visible) return;
this.left.animate({left:0},{duration:500,queue:false});
this.visible=true;
}
Index.prototype.removeLeft = function(){
//this.left.addClass("l-visiable");
if(!this.visible) return;
this.left.animate({left:-80},{duration:500,queue:false});
this.visible=false;
}
Index.prototype.leftInit = function(){
var xthis = this;
xthis.left.find('li').click(function(){
xthis.goto(xthis.cardInfo[$(this).attr('index')].top);
})
}
Index.prototype.goto = function(dis){
dis = dis - 80;
$('body,html').animate({scrollTop:dis}, 800);
}
Index.prototype.cxScrollInit = function(){
var scrollCallback = function (){
$("body,html").trigger("scroll");
}
$(".floor").find('.cxScroll').each(function(){
var xthis = $(this);
xthis.cxScroll({'scrollCallback':scrollCallback,'auto':false});
xthis.find("img.te-lazy-100-scroll").lazyload({
effect: 'fadeIn',
load: function () {
$(this).css({"width":"100%"});
}
});
})
};
var swiperSignal = getSignal(function(){
new Swiper();
return true;
});
var seckillSignal = getSignal(function(option){
new Seckill(option);
return true;
});
var featureSignal = getSignal(function(){
new Feature();
return true;
});
var indexSignal = getSignal(function(){
new Index();
return true;
});
var footPopSignal = getSignal(function(option){
new FootPop(option);
return true;
});
var fullPopSignal = getSignal(function(option){
new FullPop(option);
return true;
});