Commit be35e38c authored by xishifeng's avatar xishifeng

tab切换记录处理

parent 92159c0f
...@@ -239,3 +239,7 @@ a:hover{ ...@@ -239,3 +239,7 @@ a:hover{
max-width: 750px; max-width: 750px;
height: 600px; height: 600px;
} }
.menu-sub-alink.active-a{
background-color: #ff9419!important;
}
...@@ -26,9 +26,15 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function ...@@ -26,9 +26,15 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function
}); });
} }
menu_bar(); menu_bar(function(){
//回调部分
var _hash = location.pathname.replace('/admin.php/', '/');
var _tempObj = $('[data-href="'+_hash+'"]');
_tempObj.addClass('active-a').siblings().removeClass('active-a');
_tempObj.closest('.dropdown-menu').prev().attr('aria-expanded', true).parents().addClass('open').siblings().removeClass('open');
});
function menu_bar() { function menu_bar(fn) {
var user_info_obj = JSON.parse(decodeURIComponent(sessionStorage.getItem('pcUserInfo'))); //读取缓存 var user_info_obj = JSON.parse(decodeURIComponent(sessionStorage.getItem('pcUserInfo'))); //读取缓存
...@@ -39,7 +45,9 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function ...@@ -39,7 +45,9 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function
var doTtmpl = doT.template (temp); var doTtmpl = doT.template (temp);
$ ("#dropdownMenu1").append(user_info_obj['name']); $ ("#dropdownMenu1").append(user_info_obj['name']);
$ ("#menu_bar").html (doTtmpl (user_info_obj['menu'])); $ ("#menu_bar").html (doTtmpl (user_info_obj['menu']));
//回调
fn && fn();
} else { } else {
$.ajax ({ $.ajax ({
url: '/index/getMenu', url: '/index/getMenu',
...@@ -48,11 +56,12 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function ...@@ -48,11 +56,12 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function
data: "", data: "",
dataType: 'json', dataType: 'json',
success: function (data) { success: function (data) {
var _indexMain = sessionStorage.getItem('menuMainIndex');
var _indexSub = sessionStorage.getItem('menuSubIndex');
var temp = document.getElementById ('menu_tpl').innerHTML; var temp = document.getElementById ('menu_tpl').innerHTML;
var doTtmpl = doT.template (temp); var doTtmpl = doT.template (temp);
$ ("#menu_bar").html (doTtmpl (data.data.menu)); $ ("#menu_bar").html (doTtmpl (data.data.menu));
//回调
fn && fn();
} }
}); });
...@@ -68,8 +77,6 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function ...@@ -68,8 +77,6 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html', 'layer'], function
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var _this = $(this); var _this = $(this);
sessionStorage.setItem('menuMainIndex',_this.parent().index());
sessionStorage.setItem('menuSubIndex',_this.closest('.menu-main-li').index());
window.open(_this.data('href'));//改为在新标签页打开 window.open(_this.data('href'));//改为在新标签页打开
//location.href = _this.data('href'); //location.href = _this.data('href');
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment