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
| /**
| 菜单 处理
| **/
| (function(vc){
| var vm = new Vue({
| el:'#menu-nav',
| data:{
| menus:[]
| },
| mounted:function(){
| this.getMenus();
| },
| methods:{
| getMenus:function(){
|
| var _tmpMenus = vc.getMenus();
| //浏览器缓存中能获取到
| if(_tmpMenus != null && _tmpMenus != undefined){
| this.menus = _tmpMenus;
| return ;
| }
|
| var param = {
| params:{
| msg:this.message
| }
|
| }
| //发送get请求
| vc.http.get('menu',
| 'getMenus',
| param,
| function(json,res){
| var _menus = JSON.parse(json);
| var _currentMenusId = vc.getCurrentMenu() == null?_menus[0].id:vc.getCurrentMenu();
| vm.menus = vm.refreshMenuActive(_menus,_currentMenusId);
| vc.setMenus(vm.menus);
| },function(errInfo,error){
| console.log('请求失败处理');
| }
| );
| },
| refreshMenuActive:function(jsonArray,_id){
| for(var menuIndex =0 ; menuIndex < jsonArray.length;menuIndex ++){
| if(_id === jsonArray[menuIndex].id){
| if(jsonArray[menuIndex].active === true){
| //如果当前本身是打开状态,说明 需要关闭
| jsonArray[menuIndex].active=false;
| continue;
| }
| jsonArray[menuIndex].active=true;
| continue;
| }
| jsonArray[menuIndex].active=false;
| }
|
| return jsonArray;
| },
| switchMenu:function(_id){
| //设置菜单ID
| vc.setCurrentMenu(_id);
| vm.menus = vm.refreshMenuActive(vm.menus,_id);
| }
| },
|
| });
|
| })(window.vc)
|
|