home.js
7.78 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
253
254
255
256
257
258
259
260
261
$(document).ready(function() {
//隐藏/显示藏品列表
$('.hide_entrust').hide();
var entrustShowCount = 0;
$('#entrust_down').click(function() {
entrustShowCount++;
$('.hide_entrust').toggle(
function() {
if (entrustShowCount % 2 == 0) {
location.href = '#entrust_anchor';
$('#entrust_down').html('更多<img src="/resource/images/newHomePage/expand.png" width="27" height="13" />');
} else {
$('#entrust_down').html('隐藏<img src="/resource/images/newHomePage/collapse.png" width="27" height="13" />');
}
}
);
});
$("#howinvolve01").rotate({
bind: {
mouseover: function(){
$(this).rotate({
angle: 0,
animateTo: 360,
easing: $.easing.easeInOutExpo
});
}
}
});
$('#demo1').slideBox({
hideClickBar : false
});
// $("#slider3").Xslider({
// unitdisplayed:1, //必需项;
// affect: 'fade',
// auto: true,
// space: 5000,
// trigger: 'mouseover', //触发事件 注意用mouseover代替hover
// conbox: '.conbox', //内容容器id或class
// ctag: 'li', //内容标签 默认为<a>
// switcher: '.switcher', //切换触发器id或class
// stag: 'a', //切换器标签 默认为a
// current: 'cur', //当前切换器样式名称
// rand: false ,//是否随机指定默认幻灯
// });
function DY_scroll(wraper, prev, next, img, speed, orr) {
var wraper = $(wraper);
var prev = $(prev);
var next = $(next);
var img = $(img).find('ul');
var w = img.find('li').outerWidth(true);
var s = speed;
next.click(function() {
//if (img.find('li').length < 6) return;
img.stop().animate({
'margin-left': -w
}, function() {
img.find('li').eq(0).appendTo(img);
img.css({
'margin-left': 0
});
});
});
prev.click(function() {
// if (img.find('li').length < 5) return;
img.stop().find('li:last').prependTo(img);
img.css({
'margin-left': -w
});
img.animate({
'margin-left': 0
});
});
//if (img.find('li').length > 5) {
if (orr == true) {
var gdtime = setInterval(function() {
next.click();
}, s * 500);
wraper.hover(function() {
clearInterval(gdtime);
}, function() {
gdtime = setInterval(function() {
next.click();
}, s * 500);
});
}
//}
}
DY_scroll('.cpml-list', '.next', '.prev', '.img-list', 6, false); // true为自动播放,不加此参数或false就默认不自动
var rollspeed = 100;
var freshTimer = 60*1000;
var scrollTcimerID;
var sdiv = $("#scrollContentContainer");
var d2 = $("#exchangeInfoDiv");
var exchangeInfoUl=$('#exchangeInfoUl');
var exchangeInfoUl1=$('#exchangeInfoUl1');
var redstyle='style="color: #d0111a;"';
var bluestyle='style="color: #009e0a;"';
function appendList(ul, items, num) {
if(!items||items.length==0){
return;
}
var num = num || items.length - 1;
ul.find('li:gt(' + num + ')').remove()
//var ulelement = $(ul);
var lilist=new Array();
$.each(items, function(n, item) {
//var oNewli = $("<li></li>").addClass("quotationcol");
var listr = '';
var mclose_price = parseFloat(item.mclose_price); //昨收盘
var last_price = parseFloat(item.last_price); //最新价
var trend = (last_price - mclose_price) / mclose_price * 100;
var business_balance = parseFloat(item.business_balance); //成交金额
business_balance = (business_balance / 10000).toMoney(2, "", ",");
if (isNaN(trend)) {
trend = 0;
}
last_price=last_price.toFixed(2);
if (trend > 0) {
//style = ' style="color: #d0111a;"';
listr = listr + '<span>' + item.mch_code+'</span>' + '<span>' + item.mch_name +'</span>' + '<span '+redstyle+'>' + last_price+'</span>';
}else{
listr = listr + '<span>' + item.mch_code+'</span>' + '<span>' + item.mch_name +'</span>' + '<span '+bluestyle+'>' + last_price+'</span>';
}
lilist.push('<li class="quotationcol">'+listr+"</li>");
// oNewli.append($(listr));
// ulelement.append(oNewli);
});
var lilistStr=lilist.join('');
ul.html(lilistStr);
return lilistStr;
}
function refreshExchangeInfo() {
var timerID = window.setInterval(getExchangeInfo,freshTimer);
}
function startScrollDiv() {
if (scrollTcimerID)
stopScrollDiv();
scrollTcimerID = window.setInterval(scrollDiv, rollspeed);
startTime = new Date().getTime();
}
function scrollDiv() {
var h = d2.height();
if (d2.get(0).offsetHeight - sdiv.height() - sdiv.scrollTop() <= 0) {
sdiv.scrollTop(0);
endTime = new Date().getTime();
var time = endTime - startTime;
if(time >= freshTimer) {
exchangeInfoUl.html(exchangeInfoUl1.html());
startTime = new Date().getTime();
endTime = startTime;
}
} else {
sdiv.scrollTop(sdiv.scrollTop() + 1);
}
}
function stopScrollDiv() {
if (scrollTcimerID)
try {
window.clearInterval(scrollTcimerID);
} catch (e) {
}
}
$('#ensurePopup').click(function() {
location.href="/user/position";
});
function toArticle(){
}
function startExchangeInfo(){
var exchangeBody = getExchangeInfo();
exchangeInfoUl.html(exchangeBody);
exchangeInfoUl1.hide();
refreshExchangeInfo();
startScrollDiv();
}
/*添加行情信息*/
//startExchangeInfo();
//sdiv.hover(stopScrollDiv, startScrollDiv).mouseout();
function getExchangeInfo() {
var exchangeStr="";
$.ajax({
url: "/trade/exchaneInfo",
type: "get",
dataType: "json",
async: false,
success: function(result) {
exchangeStr=appendList(exchangeInfoUl1, result.data);
},
error:function(error){
}
});
return exchangeStr;
}
});
/**倒计时*/
$(function() {
function updateTimeDomValue() {
//截止时间(月份 - 1)
var endTime = new Date(2015, 9, 12, 15, 00, 00);
var time_diff = (endTime.getTime() - new Date().getTime()) / 1000;
if (time_diff <= 0) {
$('.countdown').html('0天0时0分0秒');
if (interval) {
clearInterval(interval);
}
}
var dayStr = $("#day").text();
var hourStr = $("#hour").text();
var minuteStr = $("#minute").text();
var secondStr = $("second").text();
var day = Math.floor(time_diff / (60 * 60 * 24));
var hour = Math.floor((time_diff - day * 24 * 60 * 60) / 3600);
var minute = Math.floor((time_diff - day * 24 * 60 * 60 - hour * 3600) / 60);
var second = Math.floor(time_diff - day * 24 * 60 * 60 - hour * 3600 - minute * 60);
updateDomText("#day", day, dayStr);
updateDomText("#hour", hour, hourStr);
updateDomText("#minute", minute, minuteStr);
updateDomText("#second", second, secondStr);
}
function updateDomText(id, time, timeStr) {
if (parseInt(timeStr) != time) {
if (time < 10) {
$(id).text("" + time);
} else {
$(id).text("" + time);
}
}
}
updateTimeDomValue();
var interval = setInterval(updateTimeDomValue, 1000);
});