index.js
7.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/**
* @author zzf
*/
//浏览器宽度变化页面的变化
$(function(){
var winW = (($(window).width() - 1200)/2);
var site = function(){
var winX = ((winW - 56) - (winW - ($(window).width() - 1200)/2));
if(winX > 0){
$('.site ').css('right', winX);
}else{
$('.site ').css('right', 0);
};
};
$(window).resize(site);
site();
$("img").lazyload();
$('.imglist_w').dilislider({
// 默认配置
affect: 'fade', //效果 有scrollx|scrolly|fade|none
speed: 3000, //动画速度
space: 6000, //时间间隔
auto: true, //自动滚动
trigger: 'mouseover', //触发事件 注意用mouseover代替hover
conbox: 'ul', //内容容器id或class
ctag: 'li', //内容标签 默认为<a>
switcher: '.tab-a', //切换触发器id或class
stag: 'a', //切换器标签 默认为a
current:'on', //当前切换器样式名称
rand:false //是否随机指定默认幻灯图片
});
//$('.imglist_w li').css('width', $('.ban-tab').width());
//首页新闻隐藏显示
$(".pack-box em").click(function(){
if(! $(this).hasClass("on")){
$(this).addClass("on");
$(this).parent().addClass("reveal");
$(this).next(".pack-a").hide();
$(this).nextAll(".pack-mo").show();
}else{
$(this).removeClass("on");
$(this).parent().removeClass("reveal");
$(this).next(".pack-a").show();
$(this).nextAll(".pack-mo").hide();
};
});
$(".pack-a").bind("click",function(){
$(".pack-box em").click();
});
//资讯、公告展示区
$(".pack-mo-tr2 span a").bind("hover",function(){
var i = $(".pack-mo-tr2 span a").index(this);
$(".pack-mo-tr2 span a").removeClass("on");
$(this).addClass("on");
$(".pack-mo-tr2 ul").hide();
$(".pack-mo-tr2 ul").eq(i).show();
});
//加入进货栏
$(".un-boxlist li a").dhover(
function(){
$(this).find(".shine").stop();
$(this).find(".shine").css('left', '-160px').animate({"left": '160px'}, 500);
$(this).next('.info').stop().animate({"top":"130px"});
return false;
},
function(){
$(this).next('.info').stop().animate({"top":"170px"});
return false;
}
);
//页面定位以及显示
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$('.site-list a').click(function(){
var key = $(this).attr('href');
key = key.split('#')[1];
var sll = $('#'+key).offset().top - 80;
$body.animate({scrollTop: sll}, 1000);key
return false;
});
function indexSerIcon(obj_tree,obj_dom){
if(obj_tree!=''){
_dom=$(obj_tree);
_dom.find(obj_dom).bind("mouseover",function(){
if(!($(this).is(":animated"))){
$(this).animate({"marginTop":"-25px","opacity":"hide"},200).animate({"marginTop":"20px","opacity":"hide"},0).animate({"marginTop":"0","opacity":"show"},200).animate({"marginTop":"-0px"},200);
}
});
}
};
indexSerIcon(".serve-tr2","img");
//滚动事件监听
var isHFixed = true;
var box_left = 13;
$(window).scroll(function (){
var _scl = $(window).scrollTop();
if(_scl == 0){
$('.site-list a.a-top').hide(300);
}else{
$('.site-list a.a-top').show(300);
}
if(_scl > 0 && isHFixed){
isHFixed = false;
$('.h-fixed').css({'position':'fixed', 'border-bottom':'1px solid #DDDDDD', 'height':'30px', 'box-shadow':'0 1px 5px rgba(0, 0, 0, 0.1)', 'z-index':9999})
.find('.header-mo').css({'height':'55px', 'padding-top':'5px'}).find('.mo-fn1').find('a').css({'width':'120px', 'height':'40px', 'margin-top':'4px'});
$('.h-fixed').animate({'height':'90px'}, 250, function(){
box_left = $('.a-tit').offset().left;
//$('.header-mo .mo-fn3 span.a-tit').css({'position':'fixed', 'left':box_left+'px'});
});
$(".autocomplete-suggestions").css({'position':'fixed','top':'80px'});
}else if(_scl == 0){
isHFixed = true;
$('.h-fixed').css({'position':'relative', 'border-bottom':'none', 'height':'140px', 'box-shadow':'none', 'z-index':999})
.find('.header-mo').css({'height':'78px', 'padding-top':'32px'}).find('.mo-fn1').find('a').css({'width':'150px', 'height':'50px', 'margin-top':'0px'});
box_left = 13;
//$('.header-mo .mo-fn3 span.a-tit').css({'position':'absolute', 'left':box_left+'px'});
$(".autocomplete-suggestions").css({'position':'absolute','top':'107px'});
};
switch(true){
case (_scl <= $('.wid-hover').eq(0).offset().top && _scl > 900) :
showAct(1);
break;
case (_scl <= $('.wid-hover').eq(1).offset().top && _scl > $('.wid-hover').eq(0).offset().top):
showAct(2);
break;
case (_scl <= $('.wid-hover').eq(2).offset().top && _scl > $('.wid-hover').eq(1).offset().top):
showAct(3);
break;
case (_scl <= $('.wid-hover').eq(3).offset().top && _scl > $('.wid-hover').eq(2).offset().top):
showAct(4);
break;
case (_scl <= $('.wid-hover').eq(4).offset().top && _scl > $('.wid-hover').eq(3).offset().top):
showAct(5);
break;
case (_scl <= $('.wid-hover').eq(5).offset().top && _scl > $('.wid-hover').eq(4).offset().top):
showAct(6);
break;
default:
showAct(0);
};
function showAct (key){
$('.wid-hover').eq(key).addClass('showed');
$('.site-list li a').removeClass('act');
$('.sl-a'+key+' a').addClass('act');
};
});
//加入购物车动画
// 元素以及其他一些变量
var eleFlyElement = $('#shopping-am')[0], eleShopCart = $('.a-tit')[0];
var numberItem = 0;
// 抛物线运动
var myParabola = funParabola(eleFlyElement, eleShopCart, {
speed: 700,
curvature: 0.0005,
complete: function() {
eleFlyElement.style.visibility = "hidden";
$('.mo-fn3 b').html('('+(++numberItem)+')');
shake('a-tit');
}
});
// 绑定点击事件
if (eleFlyElement && eleShopCart) {
$('.add-shopping').click(function(event) {
// 滚动大小
$('#shopping-am').find('img').attr('src', $(this).prev().attr('src'));
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft || 0,
scrollTop = document.documentElement.scrollTop || document.body.scrollTop || 0;
eleFlyElement.style.left = event.clientX + "px";
eleFlyElement.style.top = event.clientY + "px";
eleFlyElement.style.visibility = "visible";
// 需要重定位
myParabola.position().move();
return false;
});
}
function shake(o){
var $panel = $("."+o);
if($panel.css('position') == 'absolute'){
box_left = 13;
}else{
box_left = $panel.offset().left;
};
$panel.css({'left': box_left});
for(var i=1; 3 >= i; i++){
$panel.animate({left:box_left+(1*i)},50);
$panel.animate({left:box_left-(1*i)},50);
if(i == 3){
$panel.animate({left:box_left},50);
};
}
}
function ifloat(n){
var tag = $('.'+n);
tag.hover(function(){
if ($(this).find('i').css('top')=='0px'){
$(this).find('i').animate({top:'-3px'}, 200);
}
},function(){
$(this).find('i').animate({top:'0px'}, 200);
});
}
ifloat('m-left li')
$('.un-pref-left').live('mouseover', function(){
Tools.amHover($(this).parent().parent().find('.un-title em'), 'bounce');
});
$('.a-pic').hover(function(){
$(this).find('.a-pri').animate({marginTop : '-45px', left : '80px'}, 'fast');
$(this).find('.a-pri .rmb').animate({opacity : '1'}, 'normal');
$(this).find('img').animate({top : '-10px'}, 'fast');
},function(){
$(this).find('.a-pri').animate({marginTop : '-18px', left : '0px'}, 'fast');
$(this).find('.a-pri .rmb').animate({opacity : '0'}, 'normal');
$(this).find('img').animate({top : '0px'}, 'fast');
});
$('.a-pic-1').hover(function(){
$(this).find('.a-tt-1').animate({marginTop : '-31px'}, 'fast');
$(this).find('.a-pri-1').animate({left : '0px'}, 'fast');
$(this).find('img').animate({top : '-10px'}, 'fast');
},function(){
$(this).find('.a-tt-1').animate({marginTop : '10px'}, 'fast');
$(this).find('.a-pri-1').animate({left : '-12px'}, 'fast');
$(this).find('img').animate({top : '0px'}, 'fast');
});
});