trade.js
2.01 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
/**
* 行情信息
*/
$(function() {
// 30秒刷新一次行情
setInterval(trade.search, 1000 * 30);
});
var trade = function() {
var timer;
return {
search : function() {
$('#data-grid').datagrid({
url : '/trade/exchaneInfo'
});
},
mclosePrice : function(value, row) {
return parseFloat(value).toFixed(2);
},
openPrice : function(value, row) {
return parseFloat(value).toFixed(2);
},
lastPrice : function(value, row) {
return parseFloat(value).toFixed(2);
},
trend : function(value, row) {
var mclose_price = parseFloat(row.mclose_price);
var last_price = parseFloat(row.last_price); // 最新价
var trend = (last_price - mclose_price) / mclose_price * 100;
if (last_price < 0.05) {
trend = 0;
}
if (isNaN(trend)) {
trend = 0;
}
if (trend > 0) {
style = ' style="color: #d0111a;"';
} else if (trend < 0) {
style = ' style="color: #009e0a;"';
}
return trend.toFixed(2) + "%";
},
businessAmount : function(value, row) {
return parseFloat(value).toFixed(2);
},
highPrice : function(value, row) {
return parseFloat(value).toFixed(2);
},
lowPrice : function(value, row) {
return parseFloat(value).toFixed(2);
},
businessBalance : function(value) {
return (parseFloat(value) / 10000).toFixed(2);
},
otcentrustInfo : function(otcCode) {
$('#info-grid').datagrid({
url : '/trade/otcentrustInfo?otcCode=' + otcCode
});
$("#otc-dialog").dialog("open");
// 10秒刷新一次委托单详情
timer=setInterval(function() {
$('#info-grid').datagrid({
url : '/trade/otcentrustInfo?otcCode=' + otcCode
});
}, 1000 * 10);
},
closeInterval:function(){
clearInterval(timer);
},
otcInfo : function(value, row) {
return "<a href='#' onclick='trade.otcentrustInfo(" + row.mch_code
+ ")'>查看委托详情单</a>";
},
otcProp : function(value, row) {
if (value == '0B0') {
return '买入';
}
if (value == '0S0') {
return '卖出';
}
}
}
}();