home.js
4.5 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
/**
* 创建html
*
* @param e
* @param id
* @param tp_id
*/
function createRatioHtml(e, id, tp_id)
{
var html = $("template#"+tp_id).html();//.replace(/__ID__/g, id);
e.append(html);
}
/**
* 设置显示的值
*
* @param e
* @param data
* @param type
*/
function setRatioText(e, data, type)
{
e.find('.count').text(data['count']).animate({opacity:"1"}, 500);
var day = e.find('.' + type);
day.find('.ratio').text(data[type]['ratio']).addClass(data[type]['color']).animate({opacity:"1"}, 500);
var count = data[type]['count'];
var count_color = '';
if (count > 0) {
count = '+' + count;
count_color = 'red';
} else {
count = '--';
}
day.find('.box-rate-count').text(count).addClass(count_color).animate({opacity:"1"}, 500);
day.animate({opacity:"1"}, 500);
}
/**
* 获取用户统计增长率
*
* @param role
* @param prefix
*/
function getUserRatio(role, prefix)
{
// 异步加载数据
var url ="/" +prefix+"/statistic/growth-rate?type="+role;
$.ajax({
url: url,
type: "get",
dataType : "json",
success: function (data) {
var e = $('#'+role);
setRatioText(e, data, 'day');
setRatioText(e, data, 'week');
setRatioText(e, data, 'month');
user_count += data['count'];
$("#user-count").text(user_count);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
e.find('.count').animate({opacity:"1"}, 500);
e.find('.day').animate({opacity:"1"}, 500);
e.find('.week').animate({opacity:"1"}, 500);
e.find('.month').animate({opacity:"1"}, 500);
//关闭加载层
layer.closeAll('loading');
}
});
}
/**
* 获取用户统计增长率
*
* @param type
*/
function getGrowthRate(type, prefix)
{
// 异步加载数据
var url = "/" +prefix+"/statistic/growth-rate?type="+type;
$.ajax({
url: url,
type: "get",
dataType : "json",
success: function (data) {
var e = $('#'+type);
setRatioText(e, data, 'day');
setRatioText(e, data, 'week');
setRatioText(e, data, 'month');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
e.find('.count').animate({opacity:"1"}, 500);
//e.find('.day').animate({opacity:"1"}, 500);
//e.find('.week').animate({opacity:"1"}, 500);
//e.find('.month').animate({opacity:"1"}, 500);
//关闭加载层
layer.closeAll('loading');
}
});
}
/**
* 获取资源统计增长率
*
* @param type
*/
function getResourceRate(type, prefix)
{
// 异步加载数据
var url = "/" +prefix+"/statistic/growth-rate?type="+type;
$.ajax({
url: url,
type: "get",
dataType : "json",
success: function (data) {
var e = $('#'+type);
setRatioText(e, data, 'day');
setRatioText(e, data, 'week');
setRatioText(e, data, 'month');
// e.find('.count').text(data['count']).animate({opacity:"1"}, 500);
// e.find('.day').text(data['day']['ratio']).addClass(data['day']['color']).animate({opacity:"1"}, 500);
// e.find('.week').text(data['week']['ratio']).addClass(data['week']['color']).animate({opacity:"1"}, 500);
// e.find('.month').text(data['month']['ratio']).addClass(data['month']['color']).animate({opacity:"1"}, 500);
// e.show();
// e.css('visibility','visible');//元素显示
resource_count += data['count'];
$("#resource-count").text(resource_count);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
e.find('.count').animate({opacity:"1"}, 500);
e.find('.day').animate({opacity:"1"}, 500);
e.find('.week').animate({opacity:"1"}, 500);
e.find('.month').animate({opacity:"1"}, 500);
//关闭加载层
layer.closeAll('loading');
}
});
}
function showLockPasswordSetPage( id )
{
layer.open(
{
type: 2,
title: '设置密码',
shadeClose: true,
// zIndex:9999,
shade: 0.8,
area: ['700px', '450px'],
content: 'tenants/'+id+'/password-set-page', //iframe的url
iframe: {
src:'tenants/'+id+'/password-set-page',
scrolling:'no'
}
}
);
}