wuxw лет назад: 7
Родитель
Сommit
2c8771fbb8

+ 45 - 22
WebService/src/main/java/com/java110/web/components/NavComponent.java

@@ -1,6 +1,5 @@
 package com.java110.web.components;
 package com.java110.web.components;
 
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.IPageData;
 import com.java110.web.smo.INavServiceSMO;
 import com.java110.web.smo.INavServiceSMO;
@@ -20,14 +19,21 @@ public class NavComponent {
     @Autowired
     @Autowired
     private INavServiceSMO navServiceSMOImpl;
     private INavServiceSMO navServiceSMOImpl;
 
 
-    public ResponseEntity<String> getNavData(IPageData pd){
 
 
-        String result = "{'noticeSize':10," +
-                "'moreNoticeUrl':'/moreNotice','notices':[" +
-                "{'msg':'新系统开发测试','date':'2019-03-19'}," +
-                "{'msg':'权限检查测试','date':'2019-03-21'}," +
-                "{'msg':'系统欲开发测试','date':'2019-03-20'}" +
-                "]}";
+    /**
+     * 查询通知信息
+     *
+     * @param pd 页面封装数据
+     * @return 通知信息
+     */
+    public ResponseEntity<String> getNavData(IPageData pd) {
+
+        String result = "{'noticeSize':10,"
+                + "'moreNoticeUrl':'/moreNotice','notices':["
+                + "{'msg':'新系统开发测试','date':'2019-03-19'},"
+                + "{'msg':'权限检查测试','date':'2019-03-21'},"
+                + "{'msg':'系统欲开发测试','date':'2019-03-20'}"
+                + "]}";
 
 
         JSONObject nav = JSONObject.parseObject(result);
         JSONObject nav = JSONObject.parseObject(result);
 
 
@@ -37,36 +43,51 @@ public class NavComponent {
 
 
     /**
     /**
      * 退出登录
      * 退出登录
-     * @param pd
-     * @return
+     *
+     * @param pd 页面封装对象
+     * @return 页面对象ResponseEntity
      */
      */
-    public ResponseEntity<String> logout(IPageData pd){
+    public ResponseEntity<String> logout(IPageData pd) {
         ResponseEntity<String> responseEntity = null;
         ResponseEntity<String> responseEntity = null;
-        try{
-            responseEntity =  navServiceSMOImpl.doExit(pd);
-        }catch (Exception e){
+        try {
+            responseEntity = navServiceSMOImpl.doExit(pd);
+        } catch (Exception e) {
             responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
             responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
-        }finally {
+        } finally {
             return responseEntity;
             return responseEntity;
         }
         }
     }
     }
 
 
     /**
     /**
      * 获取用户信息
      * 获取用户信息
-     * @param pd
-     * @return
+     *
+     * @param pd 页面封装对象
+     * @return 页面对象ResponseEntity
      */
      */
-    public ResponseEntity<String> getUserInfo(IPageData pd){
+    public ResponseEntity<String> getUserInfo(IPageData pd) {
         ResponseEntity<String> responseEntity = null;
         ResponseEntity<String> responseEntity = null;
-        try{
-            responseEntity =  navServiceSMOImpl.getUserInfo(pd);
-        }catch (Exception e){
+        try {
+            responseEntity = navServiceSMOImpl.getUserInfo(pd);
+        } catch (Exception e) {
             responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
             responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
-        }finally {
+        } finally {
             return responseEntity;
             return responseEntity;
         }
         }
     }
     }
 
 
+    /**
+     * 查询已经入住的小区
+     *
+     * @param pd 页面封装对象
+     * @return 小区信息 [{community:"123123",name:"测试1小区"},{community:"223123",name:"测试2小区"}]
+     */
+    public ResponseEntity<String> getCommunitys(IPageData pd) {
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = navServiceSMOImpl.listMyCommunity(pd);
+
+        return responseEntity;
+    }
+
 
 
     public INavServiceSMO getNavServiceSMOImpl() {
     public INavServiceSMO getNavServiceSMOImpl() {
         return navServiceSMOImpl;
         return navServiceSMOImpl;
@@ -75,4 +96,6 @@ public class NavComponent {
     public void setNavServiceSMOImpl(INavServiceSMO navServiceSMOImpl) {
     public void setNavServiceSMOImpl(INavServiceSMO navServiceSMOImpl) {
         this.navServiceSMOImpl = navServiceSMOImpl;
         this.navServiceSMOImpl = navServiceSMOImpl;
     }
     }
+
+
 }
 }

+ 16 - 6
WebService/src/main/java/com/java110/web/smo/INavServiceSMO.java

@@ -12,15 +12,25 @@ public interface INavServiceSMO {
 
 
     /**
     /**
      * 用户退出
      * 用户退出
-     * @param pd
-     * @return
+     *
+     * @param pd 页面封装数据
+     * @return ResponseEntity对象
      */
      */
-    public ResponseEntity<String> doExit(IPageData pd);
+    ResponseEntity<String> doExit(IPageData pd);
 
 
     /**
     /**
      * 获取用户信息
      * 获取用户信息
-     * @param pd
-     * @return
+     *
+     * @param pd 页面封装数据
+     * @return ResponseEntity对象
      */
      */
-    public ResponseEntity<String> getUserInfo(IPageData pd);
+    ResponseEntity<String> getUserInfo(IPageData pd);
+
+    /**
+     * 查询入驻小区
+     *
+     * @param pd 页面封装数据
+     * @return ResponseEntity对象
+     */
+    ResponseEntity<String> listMyCommunity(IPageData pd);
 }
 }

+ 1 - 1
WebService/src/main/java/com/java110/web/smo/impl/CommunityServiceSMOImpl.java

@@ -28,7 +28,7 @@ import org.thymeleaf.util.StringUtils;
 @Service("communityServiceSMOImpl")
 @Service("communityServiceSMOImpl")
 public class CommunityServiceSMOImpl extends BaseComponentSMO implements ICommunityServiceSMO {
 public class CommunityServiceSMOImpl extends BaseComponentSMO implements ICommunityServiceSMO {
 
 
-    private final static Logger logger = LoggerFactory.getLogger(CommunityServiceSMOImpl.class);
+    private static Logger logger = LoggerFactory.getLogger(CommunityServiceSMOImpl.class);
 
 
     @Autowired
     @Autowired
     private RestTemplate restTemplate;
     private RestTemplate restTemplate;

+ 61 - 10
WebService/src/main/java/com/java110/web/smo/impl/NavServiceSMOImpl.java

@@ -1,9 +1,12 @@
 package com.java110.web.smo.impl;
 package com.java110.web.smo.impl;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.constant.ServiceConstant;
 import com.java110.common.constant.ServiceConstant;
+import com.java110.common.constant.StatusConstant;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.IPageData;
 import com.java110.web.core.BaseComponentSMO;
 import com.java110.web.core.BaseComponentSMO;
+import com.java110.web.smo.ICommunityServiceSMO;
 import com.java110.web.smo.INavServiceSMO;
 import com.java110.web.smo.INavServiceSMO;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -21,13 +24,18 @@ import org.springframework.web.client.RestTemplate;
  */
  */
 @Service("navServiceSMOImpl")
 @Service("navServiceSMOImpl")
 public class NavServiceSMOImpl extends BaseComponentSMO implements INavServiceSMO {
 public class NavServiceSMOImpl extends BaseComponentSMO implements INavServiceSMO {
-    private final static Logger logger = LoggerFactory.getLogger(NavServiceSMOImpl.class);
+    private static Logger logger = LoggerFactory.getLogger(NavServiceSMOImpl.class);
 
 
     @Autowired
     @Autowired
     private RestTemplate restTemplate;
     private RestTemplate restTemplate;
 
 
+
+    @Autowired
+    private ICommunityServiceSMO communityServiceSMOImpl;
+
     /**
     /**
      * 用户退出
      * 用户退出
+     *
      * @param pd
      * @param pd
      * @return
      * @return
      */
      */
@@ -35,24 +43,29 @@ public class NavServiceSMOImpl extends BaseComponentSMO implements INavServiceSM
     public ResponseEntity<String> doExit(IPageData pd) {
     public ResponseEntity<String> doExit(IPageData pd) {
         ResponseEntity<String> responseEntity = null;
         ResponseEntity<String> responseEntity = null;
         JSONObject exitInfo = new JSONObject();
         JSONObject exitInfo = new JSONObject();
-        exitInfo.put("token",pd.getToken());
-        responseEntity = this.callCenterService(restTemplate,pd,exitInfo.toJSONString(), ServiceConstant.SERVICE_API_URL+"/api/user.service.logout", HttpMethod.POST);
+        exitInfo.put("token", pd.getToken());
+        responseEntity = this.callCenterService(restTemplate, pd, exitInfo.toJSONString(),
+                ServiceConstant.SERVICE_API_URL + "/api/user.service.logout", HttpMethod.POST);
 
 
         return responseEntity;
         return responseEntity;
     }
     }
 
 
     /**
     /**
      * 获取用户信息
      * 获取用户信息
+     *
      * @param pd
      * @param pd
      * @return
      * @return
      */
      */
     @Override
     @Override
     public ResponseEntity<String> getUserInfo(IPageData pd) {
     public ResponseEntity<String> getUserInfo(IPageData pd) {
-        Assert.hasLength(pd.getUserId(),"用户未登录请先登录");
+        Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
         /*ResponseEntity<String> responseEntity = null;
         /*ResponseEntity<String> responseEntity = null;
-        responseEntity = this.callCenterService(restTemplate,pd,"", ServiceConstant.SERVICE_API_URL+"/api/query.user.userInfo?userId="+pd.getUserId(), HttpMethod.GET);
+        responseEntity = this.callCenterService(restTemplate,pd,"",
+        ServiceConstant.SERVICE_API_URL+"/api/query.user.userInfo?userId="+pd.getUserId(), HttpMethod.GET);
         // 过滤返回报文中的字段,只返回name字段
         // 过滤返回报文中的字段,只返回name字段
-        //{"address":"","orderTypeCd":"Q","serviceCode":"","responseTime":"20190401194712","sex":"","localtionCd":"","userId":"302019033054910001","levelCd":"00","transactionId":"-1","dataFlowId":"-1","response":{"code":"0000","message":"成功"},"name":"996icu","tel":"18909780341","bId":"-1","businessType":"","email":""}
+        //{"address":"","orderTypeCd":"Q","serviceCode":"","responseTime":"20190401194712","sex":"",
+        "localtionCd":"","userId":"302019033054910001","levelCd":"00","transactionId":"-1","dataFlowId":"-1",
+        "response":{"code":"0000","message":"成功"},"name":"996icu","tel":"18909780341","bId":"-1","businessType":"","email":""}
 
 
         if(responseEntity.getStatusCode() == HttpStatus.OK){
         if(responseEntity.getStatusCode() == HttpStatus.OK){
             JSONObject tmpUserInfo = JSONObject.parseObject(responseEntity.getBody().toString());
             JSONObject tmpUserInfo = JSONObject.parseObject(responseEntity.getBody().toString());
@@ -61,13 +74,51 @@ public class NavServiceSMOImpl extends BaseComponentSMO implements INavServiceSM
             responseEntity = new ResponseEntity<String>(resultUserInfo.toJSONString(),HttpStatus.OK);
             responseEntity = new ResponseEntity<String>(resultUserInfo.toJSONString(),HttpStatus.OK);
         }*/
         }*/
         ResponseEntity<String> responseEntity = null;
         ResponseEntity<String> responseEntity = null;
-        responseEntity = super.getUserInfo(pd,restTemplate);
-        if(responseEntity.getStatusCode() == HttpStatus.OK){
+        responseEntity = super.getUserInfo(pd, restTemplate);
+        if (responseEntity.getStatusCode() == HttpStatus.OK) {
             JSONObject tmpUserInfo = JSONObject.parseObject(responseEntity.getBody().toString());
             JSONObject tmpUserInfo = JSONObject.parseObject(responseEntity.getBody().toString());
             JSONObject resultUserInfo = new JSONObject();
             JSONObject resultUserInfo = new JSONObject();
-            resultUserInfo.put("name",tmpUserInfo.getString("name"));
-            responseEntity = new ResponseEntity<String>(resultUserInfo.toJSONString(),HttpStatus.OK);
+            resultUserInfo.put("name", tmpUserInfo.getString("name"));
+            responseEntity = new ResponseEntity<String>(resultUserInfo.toJSONString(), HttpStatus.OK);
         }
         }
         return responseEntity;
         return responseEntity;
     }
     }
+
+
+    @Override
+    public ResponseEntity<String> listMyCommunity(IPageData pd) {
+        ResponseEntity<String> responseEntity = communityServiceSMOImpl.listMyCommunity(pd);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return responseEntity;
+        }
+
+        JSONArray communitys = JSONArray.parseArray(responseEntity.getBody());
+
+        JSONArray newCommunitys = new JSONArray();
+
+        //只返回小区ID和小区名称 并且是在用的
+        JSONObject tempCommunity = null;
+        JSONObject newCommunity = null;
+        for (int communityIndex = 0; communityIndex < communitys.size(); communityIndex++) {
+            tempCommunity = communitys.getJSONObject(communityIndex);
+
+            if (!StatusConstant.STATUS_CD_VALID.equals(tempCommunity.getString("statusCd"))) {
+                continue;
+            }
+            newCommunity = new JSONObject();
+            newCommunity.put("communityId", tempCommunity.getString("communityId"));
+            newCommunity.put("name", tempCommunity.getString("name"));
+            newCommunitys.add(newCommunity);
+        }
+        responseEntity = new ResponseEntity<String>(newCommunitys.toJSONString(), HttpStatus.OK);
+        return responseEntity;
+    }
+
+    public ICommunityServiceSMO getCommunityServiceSMOImpl() {
+        return communityServiceSMOImpl;
+    }
+
+    public void setCommunityServiceSMOImpl(ICommunityServiceSMO communityServiceSMOImpl) {
+        this.communityServiceSMOImpl = communityServiceSMOImpl;
+    }
 }
 }

+ 5 - 2
WebService/src/main/resources/components/login/login.js

@@ -8,7 +8,7 @@
             }
             }
         },
         },
         _initMethod:function(){
         _initMethod:function(){
-
+            vc.component.clearCacheData();
         },
         },
         _initEvent:function(){
         _initEvent:function(){
              vc.component.$on('errorInfoEvent',function(_errorInfo){
              vc.component.$on('errorInfoEvent',function(_errorInfo){
@@ -24,7 +24,10 @@
                      });
                      });
         },
         },
         methods:{
         methods:{
-            doLogin(){
+            clearCacheData:function(){
+                vc.clearCacheData();
+            },
+            doLogin:function(){
                 vc.http.post(
                 vc.http.post(
                             'login',
                             'login',
                             'doLogin',
                             'doLogin',

+ 9 - 0
WebService/src/main/resources/components/menu/menu.js

@@ -12,6 +12,14 @@
        },
        },
        methods:{
        methods:{
            getMenus:function(){
            getMenus:function(){
+
+                var _tmpMenus = vc.getMenus();
+                //浏览器缓存中能获取到
+                if(_tmpMenus != null && _tmpMenus != undefined){
+                    this.menus = _tmpMenus;
+                    return ;
+                }
+
                var param = {
                var param = {
                     params:{
                     params:{
                         msg:this.message
                         msg:this.message
@@ -26,6 +34,7 @@
                                 var _menus = JSON.parse(json);
                                 var _menus = JSON.parse(json);
                                 var _currentMenusId = vc.getCurrentMenu() == null?_menus[0].id:vc.getCurrentMenu();
                                 var _currentMenusId = vc.getCurrentMenu() == null?_menus[0].id:vc.getCurrentMenu();
                                 vm.menus = vm.refreshMenuActive(_menus,_currentMenusId);
                                 vm.menus = vm.refreshMenuActive(_menus,_currentMenusId);
+                                vc.setMenus(vm.menus);
                              },function(errInfo,error){
                              },function(errInfo,error){
                                 console.log('请求失败处理');
                                 console.log('请求失败处理');
                              }
                              }

+ 15 - 1
WebService/src/main/resources/components/nav/nav.html

@@ -8,12 +8,26 @@
         </form>
         </form>
     </div>
     </div>
     <ul class="nav navbar-top-links navbar-right">
     <ul class="nav navbar-top-links navbar-right">
+        <li class="nav-item dropdown">
+            <a class="nav-link dropdown-toggle"
+               data-toggle="dropdown"
+               href="#"
+               role="button"
+               aria-haspopup="true"
+               aria-expanded="false">
+                {{navCommunityInfo._currentCommunity.name}}
+                <span class="caret"></span>
+            </a>
+            <div class="dropdown-menu" v-for="currentCommunity in navCommunityInfo.communityInfos">
+                <a class="dropdown-item" href="changeCommunity(currentCommunity)">{{currentCommunity.name}}</a>
+            </div>
+        </li>
         <li style="padding: 20px">
         <li style="padding: 20px">
             <span class="m-r-sm text-muted welcome-message">欢迎访问HC小区管理系统,{{userName}}!</span>
             <span class="m-r-sm text-muted welcome-message">欢迎访问HC小区管理系统,{{userName}}!</span>
         </li>
         </li>
         <li class="dropdown">
         <li class="dropdown">
             <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
             <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
-                <i class="fa fa-bell"></i>  <span class="label label-primary">{{nav.noticeSize}}</span>
+                <i class="fa fa-bell"></i> <span class="label label-primary">{{nav.noticeSize}}</span>
             </a>
             </a>
             <ul class="dropdown-menu dropdown-alerts">
             <ul class="dropdown-menu dropdown-alerts">
                 <li v-for="notice in nav.notices">
                 <li v-for="notice in nav.notices">

+ 49 - 0
WebService/src/main/resources/components/nav/nav.js

@@ -7,8 +7,15 @@
         data:{
         data:{
             nav:{},
             nav:{},
             userName:"",
             userName:"",
+            navCommunityInfo:{
+                _currentCommunity:{
+
+                },
+                communityInfos:[]
+            }
         },
         },
         mounted:function(){
         mounted:function(){
+            this.getNavCommunity();
             this.getNavData();
             this.getNavData();
             this.getUserInfo();
             this.getUserInfo();
         },
         },
@@ -70,6 +77,48 @@
                                 console.log('请求失败处理');
                                 console.log('请求失败处理');
                              }
                              }
                            );
                            );
+            },
+            getNavCommunity:function(){
+                var _tmpCurrentCommunity = vc.getCurrentCommunity();
+                //浏览器缓存中能获取到
+                if(_tmpCurrentCommunity != null && _tmpCurrentCommunity != undefined){
+                    this.navCommunityInfo._currentCommunity = _tmpCurrentCommunity;
+                    this.navCommunityInfo.communityInfos = vc.getCommunitys();
+
+                    return ;
+                }
+
+                //说明缓存中没有数据
+                //发送get请求
+                /**
+                    [{community:"123123",name:"测试1小区"},{community:"223123",name:"测试2小区"}]
+                **/
+               vc.http.get('nav',
+                            'getCommunitys',
+                             '',
+                             function(json,res){
+                                if(res.status == 200){
+                                    vm.navCommunityInfo.communityInfos = JSON.parse(json);
+
+                                    if(vm.navCommunityInfo.communityInfos == null || vm.navCommunityInfo.communityInfos.length == 0){
+                                          vm.navCommunityInfo._currentCommunity ={
+                                                name:"还没有入驻小区"
+                                          };
+                                          return;
+                                    }
+
+                                    vm.navCommunityInfo._currentCommunity = vm.navCommunityInfo.communityInfos[0];
+                                    vc.setCurrentCommunity(vm.navCommunityInfo._currentCommunity);
+                                    vc.setCommunitys(vm.navCommunityInfo.communityInfos);
+                               }
+                             },function(){
+                                console.log('请求失败处理');
+                             }
+                           );
+
+            },
+            changeCommunity:function(_community){
+                 vc.setCurrentCommunity(_community);
             }
             }
         }
         }
 
 

+ 1 - 1
WebService/src/main/resources/components/validate-code/validate-code.js

@@ -21,7 +21,7 @@
                 }
                 }
             },
             },
             methods:{
             methods:{
-                generateCode(){
+                generateCode:function(){
                     var param = {
                     var param = {
                         params:{
                         params:{
                             _uId:'123'
                             _uId:'123'

+ 41 - 2
WebService/src/main/resources/static/js/core.js

@@ -125,11 +125,50 @@
     //保存菜单
     //保存菜单
     vc.setCurrentMenu = function(_menuId){
     vc.setCurrentMenu = function(_menuId){
         window.localStorage.setItem('hc_menuId',_menuId);
         window.localStorage.setItem('hc_menuId',_menuId);
-    }
+    };
     //获取菜单
     //获取菜单
     vc.getCurrentMenu = function(){
     vc.getCurrentMenu = function(){
         return window.localStorage.getItem('hc_menuId');
         return window.localStorage.getItem('hc_menuId');
-    }
+    };
+
+    //保存用户菜单
+    vc.setMenus = function(_menus){
+        window.localStorage.setItem('hc_menus',JSON.stringify(_menus));
+    };
+    //获取用户菜单
+    vc.getMenus = function(){
+        return JSON.parse(window.localStorage.getItem('hc_menus'));
+    };
+
+    //保存当前小区信息 _communityInfo : {"communityId":"123213","name":"测试小区"}
+    vc.setCurrentCommunity = function(_currentCommunityInfo){
+        window.localStorage.setItem('hc_currentCommunityInfo',JSON.stringify(_currentCommunityInfo));
+    };
+
+    //获取当前小区信息
+    // @return   {"communityId":"123213","name":"测试小区"}
+    vc.getCurrentCommunity = function(){
+        return JSON.parse(window.localStorage.getItem('hc_currentCommunityInfo'));
+    };
+
+    //保存当前小区信息 _communityInfos : [{"communityId":"123213","name":"测试小区"}]
+    vc.setCommunitys = function(_communityInfos){
+        window.localStorage.setItem('hc_communityInfos',JSON.stringify(_communityInfos));
+    };
+
+    //获取当前小区信息
+    // @return   {"communityId":"123213","name":"测试小区"}
+    vc.getCommunitys = function(){
+        return JSON.parse(window.localStorage.getItem('hc_communityInfos'));
+    };
+
+    //删除缓存数据
+    vc.clearCacheData = function(){
+        window.localStorage.clear();
+    };
+
+
+
 })(window.vc);
 })(window.vc);
 
 
 /**
 /**