header.vm
7.88 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
#set($homePage = "/main.do")
#set($url_change_dataAuth = "/changeDataAuth.do")
<script type="text/javascript" src="/static/js/modal.js">
</script>
<script type="text/javascript" src="/static/js/tmp.js">
</script>
<script type="text/javascript">
function getMsg(){
$.ajax({
type: "GET",
url: "$!{webUtils.msgUnreadPath}",
dataType: "jsonp",
jsonp: "callback",
success: function(data) {
handleMsg(data.result);
// handleMsg([1, 2, 3, 4, 5]);
}
});
}
function getLocalTime(unix) {
var now = new Date(parseInt(unix));
return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
getMsg();
$("#msg-menu-btn li").click(function () {
$('#msg_list').empty();
getMsg();
});
function handleMsg(msg){
msg.forEach(function(m){
var ctx = '<li class="divider"></li><li style="height: 30px; list-style-type: none;"><div style="line-height: 12px;">' + getLocalTime(m.createdDate) + '</div><div style="line-height: 34px;">' + m.content +'</div></li>';
$('#msg_list').append(ctx);
console.log(ctx);
})
};
var totalCount = 0;
var init = 0;
function sync(){
$.ajax({
type: "GET",
url: "$!{webUtils.messageSyncPath}",
dataType: "jsonp",
jsonp: "callback",
success: function(data) {
handleSyncCount(data.result);
}
});
}
function handleSyncCount(count){
if(init >= 1 && count > totalCount)
$.Tips({title: '一条新消息需要处理', link:'${homePage}?returnUrl=$!{webUtils.messageListPath}'}).show();
init = 1;
if(count > 0) {
totalCount = count;
$('#msg_count').text((totalCount > 99 ? '99+' : totalCount));
}
else
$('#msg_count').text("0");
}
function async(){
$.ajax({
type: "GET",
url: "$!{webUtils.getMessageAsyncPath($!{user.id})}",
dataType: "jsonp",
timeout: 1800000,
jsonp: "callback",
success: function(data) {
handleCount(data.result);
},
complete: function(XMLHttpRequest){
async();
}
});
}
function handleCount(count){
if(count > 0)
$.Tips({title: '一条新消息需要处理', link:'${homePage}?returnUrl=$!{webUtils.messageListPath}'}).show();
totalCount += count;
if(totalCount < 0)
totalCount = 0;
var count = totalCount > 99 ? '99+' : totalCount;
if(totalCount == 0){
$('#msg_count').text("0");
return;
}
if($('#msg_count').length>0){
$('#msg_count').text(count);
}
else
$('#msg_count').text(count);
}
sync();
setInterval('sync()',500000);
//sync();
//async();
</script>
<div id="navbar" class="navbar navbar-default header clearfix">
<div class="navbar-container" id="navbar-container">
<button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler">
<span class="sr-only">Toggle sidebar</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-header pull-left">
<a href="${homePage}" class="navbar-brand">
<small>
一年四季后台管理系统
</small>
</a>
</div>
<div class="navbar-buttons navbar-header pull-right" role="navigation">
<ul class="nav ace-nav">
<li class="light-blue">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
<img class="nav-user-photo" src="$!{webUtils.getAssetsPath("/ace1.3/assets/avatars/user.jpg")}" alt="Jason's Photo" />
<span class="user-info" userId="$!{user.id}">
<small>欢迎你</small>
$!{user.realName}
</span>
<i class="ace-icon fa fa-caret-down"></i>
</a>
<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
<!-- <li>
<a href="#">
<i class="ace-icon fa fa-cog"></i>
配置
</a>
</li> -->
<li>
<a href="/user/show.do?id=$!{user.id}" target="frame3d">
<i class="ace-icon fa fa-user"></i>
用户信息
</a>
</li>
<li>
<a href="/user/preUpdatePwd.do" target="frame3d">
<i class="ace-icon fa fa-user"></i>
修改密码
</a>
</li>
<li class="divider"></li>
<li>
<a href="$!{webUtils.getLocalPath("/loginControl/logout.do")}">
<i class="ace-icon fa fa-power-off"></i>
注销
</a>
</li>
</ul>
</li>
</ul>
</div>
## <a href="${homePage}?returnUrl=$!{webUtils.messageListPath}" id="notice" class="ui-icon message"></a>
<div id="msg-menu-btn" class="navbar-buttons navbar-header pull-right" role="navigation" style="margin-right: 20px;">
<ul class="nav ace-nav">
<li class="light-blue">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
消息
<i class="ace-icon fa fa-caret-down"></i>
</a>
<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close msg-menu"
style="color:#333;width:450px">
<li>
<a target="frame3d">
<div class="media-body">
<h3 class="media-heading">消息中心 (<span id="msg_count"></span>)</h3>
</div>
</a>
</li>
<li ><ul id="msg_list"></ul></li>
<li class="divider"></li>
<li>
<a href="${homePage}?returnUrl=$!{webUtils.messageListPath}">
<center><small>更多</small></center>
</a>
</li>
</ul>
</li>
</ul>
</div>
#foreach($da in $dataAuths)
#if(${da.conf.type} == 'city')
<input type="button" class="btn btn-info pull-right" value="${da.conf.label}:${da.current.value}" onclick="javascript:selectCity(${da.current.name},'${da.conf.type}','${url_change_dataAuth}');"/>
#else
<div class="navbar-buttons navbar-header pull-right" role="navigation" style="margin-right: 20px;">
<ul class="nav ace-nav">
<li class="light-blue">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
${da.conf.label}:${da.current.value}
<i class="ace-icon fa fa-caret-down"></i>
</a>
<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close list-inline"
style="color:#333;width:450px">
#foreach($item in $da.das)
<li><a href="${url_change_dataAuth}?type=${da.conf.type}¤t=${item.dataId}">${item.label}</a></li>
#end
</ul>
</li>
</ul>
</div>
#end
#end
</div><!-- /.navbar-container -->
</div>