header.html
2.12 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
<div class="header-wrap">
<div class="header">
<div class="header-nav">
<span class="header-nav-item"><a href="/html/merchant/index.html">商户管理</a></span>
<span class="header-nav-item"><a href="/html/employee/index.html">员工管理</a></span>
<span class="header-nav-item"><a href="/html/role/index.html">角色管理</a></span>
</div>
<div class="header-user">
<ul class="layui-nav">
<li class="layui-nav-item">
<a href="">
<img src="//t.cn/RCzsdCq" class="layui-nav-img" />
<span id="curMerchantName"></span>
</a>
<dl class="layui-nav-child">
<!-- <dd><a href="javascript:;">修改信息</a></dd> -->
<dd><a href="javascript:;" id="logout">退出</a></dd>
</dl>
</li>
</ul>
</div>
</div>
<div class="bread-crumb"></div>
</div>
<script>
layui.use(['element', 'request', 'helper'], function () {
var element = layui.element
var helper = layui.helper
element.init()
highlight()
bindEvents()
var href = location.href.split('/')
var isDxternal = isAppend()
if (isDxternal && href[href.length - 1] != 'login.html') {
var user = helper.store.get('user')
$('#curMerchantName').text(user.merchantName)
}
})
function highlight() {
var $ = layui.$
var _path = getPath()[0]
var _href = '/html/' + _path
$('.header-nav-item').each(function (i, e) {
var _hr = $(e).find('a').attr('href')
if (_hr.indexOf(_href) !== -1) {
// if (_hr.startsWith(_href)) {
$(e).addClass('active').siblings().removeClass('active')
return false
}
})
}
function bindEvents() {
$ = layui.$
request = layui.request
$('#logout').click(function () {
var sessionId = layui.store.get('token')
request({
sessionId: sessionId,
method: 'entmicro.api.example.logout'
}, function (result) {
goLogin()
})
})
}
function getPath() {
var _href = location.href.split('/')
var _path = _href.slice(_href.length - 2, _href.length)
return _path
}
</script>