From 263d34e9027ed2fe109b257fc9db77af3f3a1b5e Mon Sep 17 00:00:00 2001
From: 吴学文 <wuxuewen@wuxuewendeMacBook-Pro.local>
Date: 星期六, 08 六月 2019 11:50:20 +0800
Subject: [PATCH] 车位出售周期为空导致空指针异常处理

---
 WebService/src/main/resources/components/menu/menu.js |   57 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/WebService/src/main/resources/components/menu/menu.js b/WebService/src/main/resources/components/menu/menu.js
index 03a9160..a244d2b 100644
--- a/WebService/src/main/resources/components/menu/menu.js
+++ b/WebService/src/main/resources/components/menu/menu.js
@@ -12,34 +12,71 @@
        },
        methods:{
            getMenus:function(){
+
+                var _tmpMenus = vc.getMenus();
+                //娴忚鍣ㄧ紦瀛樹腑鑳借幏鍙栧埌
+                if(_tmpMenus != null && _tmpMenus != undefined){
+                    this.menus = _tmpMenus;
+                    return ;
+                }
+
                var param = {
-                   msg:this.message
+                    params:{
+                        msg:this.message
+                    }
+
                }
                //鍙戦�乬et璇锋眰
-               vc.http.call('menu',
+               vc.http.get('menu',
                             'getMenus',
                              param,
-                             {
-                                emulateJSON:true
-                             },function(json){
-                                vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
-                             },function(){
+                             function(json,res){
+                                var _menus = JSON.parse(json);
+                                _menus.sort(function(a,b){
+                                       return a.seq - b.seq
+                                });
+                                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,offset){
+           refreshMenuActive:function(jsonArray,_id){
                 for(var menuIndex =0 ; menuIndex < jsonArray.length;menuIndex ++){
-                    if(offset == menuIndex){
+
+                    if(jsonArray[menuIndex].hasOwnProperty('childs')){
+                        var _childs = jsonArray[menuIndex].childs;
+                        _childs.sort(function(_child,_newChild){
+                            return _child.seq - _newChild.seq
+                        });
+                        jsonArray[menuIndex].childs = _childs;
+                    }
+
+                    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);
+                vc.setMenus(vm.menus);
            }
-       }
+       },
 
     });
 

--
Gitblit v1.8.0