Commit 7555b249 authored by 刘丹's avatar 刘丹 Committed by hujun

菜单

parent b2845d47
...@@ -30,13 +30,17 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html'], function (doT, $,t ...@@ -30,13 +30,17 @@ define(['doT', 'jquery', 'text!temp/menu_template_tpl.html'], function (doT, $,t
function menu_bar() { function menu_bar() {
var user_info_obj = localStorage.getItem('user_info'); //读取缓存 var user_info_obj = localStorage.getItem('user_info'); //读取缓存
$ ("#menu_bar").append (template); $ ("#menu_bar").append (template);
if (typeof user_info_obj === 'string') { if (typeof user_info_obj === 'string') {
var user_info = JSON.parse(user_info_obj); var user_info = JSON.parse(user_info_obj);
console.log(user_info);
var temp = document.getElementById ('menu_tpl').innerHTML; var temp = document.getElementById ('menu_tpl').innerHTML;
var doTtmpl = doT.template (temp); var doTtmpl = doT.template (temp);
$ ("#dropdownMenu1").append(user_info['name']); $ ("#dropdownMenu1").append(user_info['name']);
$ ("#menu_bar").html (doTtmpl (user_info['menu'])); $ ("#menu_bar").html (doTtmpl (user_info['menu']));
} else { } else {
$.ajax ({ $.ajax ({
url: '/index/getMenu', url: '/index/getMenu',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
[% for(var item in it){ %] [% for(var item in it){ %]
<li class="dropdown"> <li class="dropdown">
[% if(it[item]["_child"] == undefined || it[item]["_child"].length == 0) { %] [% if(it[item]["_child"] == undefined || it[item]["_child"].length == 0) { %]
<a href="[%= it[item]['name'] %]" >[%= it[item]["title"] %]</a> <a href="[%= it[item]['name'] %]" ><span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span> <span class="span-list">[%= it[item]["title"] %]</span></a>
[% } else { %] [% } else { %]
<a href="" class="dropdown-toggle" data-toggle="dropdown"> <span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span><span class="span-list">[%= it[item]["title"] %]</span> <a href="" class="dropdown-toggle" data-toggle="dropdown"> <span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span><span class="span-list">[%= it[item]["title"] %]</span>
<span class="glyphicon glyphicon-hand-down" aria-hidden="true"></span></a> <span class="glyphicon glyphicon-hand-down" aria-hidden="true"></span></a>
......
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