From d9b2c4b780340d2d2e8ca1a328034f19092fcddb Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期三, 10 七月 2019 17:57:08 +0800
Subject: [PATCH] 提交breadcrumb功能

---
 WebService/src/main/resources/static/js/core.js |  288 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 279 insertions(+), 9 deletions(-)

diff --git a/WebService/src/main/resources/static/js/core.js b/WebService/src/main/resources/static/js/core.js
index 0d19e32..2051eda 100644
--- a/WebService/src/main/resources/static/js/core.js
+++ b/WebService/src/main/resources/static/js/core.js
@@ -1,32 +1,302 @@
 /**
-鍒濆鍖栧鐞�
+鍒濆鍖栧鐞� vue component
 **/
 (function(window, undefined){
     "use strict";
    var vc = window.vc || {};
+   var _vmOptions = {};
+   var _initMethod = [];
+   var _initEvent = [];
+   var _component = {};
+   var _destroyedMethod = [];
+   var _timers = [];//瀹氭椂鍣�
+
+   _vmOptions = {
+        el:'#component',
+        data:{
+
+        },
+        watch: {
+
+        },
+        methods:{
+
+        },
+        destroyed:function(){
+            window.vc.destroyedMethod.forEach(function(eventMethod){
+                 eventMethod();
+            });
+            //娓呯悊鎵�鏈夊畾鏃跺櫒
+
+            window.vc.timers.forEach(function(timer){
+                clearInterval(timer);
+            });
+
+            _timers = [];
+        }
+
+   };
     vc = {
         version:"v0.0.1",
-        name:"vue component"
+        name:"vue component",
+        author:'java110',
+        vmOptions:_vmOptions,
+        initMethod:_initMethod,
+        initEvent:_initEvent,
+        component:_component,
+        destroyedMethod:_destroyedMethod,
+        timers:_timers
     };
    //閫氱煡window瀵硅薄
    window.vc = vc;
 })(window);
 
 /**
-    寮傛璇锋眰鍚庡彴
+    vc 鍑芥暟鍒濆鍖�
     add by wuxw
 **/
 (function(vc){
     vc.http = {
-        call:function(componentCode,componentMethod,param,options,successCallback,errorCallback){
-        console.log(successCallback)
+        post:function(componentCode,componentMethod,param,options,successCallback,errorCallback){
+                vc.loading('open');
                 Vue.http.post('/callComponent/'+componentCode +"/"+componentMethod, param, options)
                 .then(function(res){
-                    successCallback(res.bodyText);
+                    successCallback(res.bodyText,res);
+                    vc.loading('close');
                 }, function(error){
-                    errorCallback(error);
+                    errorCallback(error.bodyText,error);
+                    vc.loading('close');
                 });
-            }
+        },
+        get:function(componentCode,componentMethod,param,successCallback,errorCallback){
+                //鍔犲叆缂撳瓨鏈哄埗
+                var _getPath = '/'+componentCode +'/' +componentMethod;
+                if(vc.constant.GET_CACHE_URL.includes(_getPath)){
+                    var _cacheData = vc.getData(_getPath);
+                    //娴忚鍣ㄧ紦瀛樹腑鑳借幏鍙栧埌
+                    if(_cacheData != null && _cacheData != undefined){
+                        successCallback(JSON.stringify(_cacheData),{status:200});
+                        return ;
+                    }
+                }
+                vc.loading('open');
+                Vue.http.get('/callComponent/'+componentCode +"/"+componentMethod, param)
+                .then(function(res){
+                    successCallback(res.bodyText,res);
+                    if(vc.constant.GET_CACHE_URL.includes(_getPath) && res.status == 200){
+                         vc.saveData(_getPath,JSON.parse(res.bodyText));
+                    }
+                    vc.loading('close');
+                }, function(error){
+                    errorCallback(error.bodyText,error);
+                    vc.loading('close');
+                });
+        }
 
     };
-})(window.vc);
\ No newline at end of file
+
+    var vmOptions = vc.vmOptions;
+    //缁ф壙鏂规硶,鍚堝苟 _vmOptions 鐨勬暟鎹埌 vmOptions涓�
+    vc.extends = function(_vmOptions){
+        if(typeof _vmOptions !== "object"){
+            throw "_vmOptions is not Object";
+        }
+        //澶勭悊 data 瀵硅薄
+        if(_vmOptions.hasOwnProperty('data')){
+            for(var dataAttr in _vmOptions.data){
+                vmOptions.data[dataAttr] = _vmOptions.data[dataAttr];
+            }
+        }
+        //澶勭悊methods 瀵硅薄
+        if(_vmOptions.hasOwnProperty('methods')){
+            for(var methodAttr in _vmOptions.methods){
+                vmOptions.methods[methodAttr] = _vmOptions.methods[methodAttr];
+            }
+        }
+        //澶勭悊methods 瀵硅薄
+        if(_vmOptions.hasOwnProperty('watch')){
+            for(var watchAttr in _vmOptions.watch){
+                vmOptions.watch[watchAttr] = _vmOptions.watch[watchAttr];
+            }
+        }
+        //澶勭悊_initMethod 鍒濆鍖栨墽琛屽嚱鏁�
+        if(_vmOptions.hasOwnProperty('_initMethod')){
+            vc.initMethod.push(_vmOptions._initMethod);
+        }
+        //澶勭悊_initEvent
+        if(_vmOptions.hasOwnProperty('_initEvent')){
+            vc.initEvent.push(_vmOptions._initEvent);
+        }
+
+         //澶勭悊_initEvent_destroyedMethod
+        if(_vmOptions.hasOwnProperty('_destroyedMethod')){
+            vc.destroyedMethod.push(_vmOptions._destroyedMethod);
+        }
+
+
+    };
+
+
+    //缁戝畾璺宠浆鍑芥暟
+    vc.jumpToPage = function(url){
+          window.location.href = url;
+    };
+    //淇濆瓨鑿滃崟
+    vc.setCurrentMenu = function(_menuId){
+        window.localStorage.setItem('hc_menuId',_menuId);
+    };
+    //鑾峰彇鑿滃崟
+    vc.getCurrentMenu = function(){
+        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'));
+    };
+
+    //淇濆瓨鐢ㄦ埛鑿滃崟
+    vc.saveData = function(_key,_value){
+        window.localStorage.setItem(_key,JSON.stringify(_value));
+    };
+    //鑾峰彇鐢ㄦ埛鑿滃崟
+    vc.getData = function(_key){
+        return JSON.parse(window.localStorage.getItem(_key));
+    };
+
+    //淇濆瓨褰撳墠灏忓尯淇℃伅 _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();
+    };
+
+    //灏唎rg 瀵硅薄鐨勫睘鎬у�艰祴鍊肩粰dst 灞炴�у悕涓轰竴鐩寸殑灞炴��
+    vc.copyObject = function(org,dst){
+        //for(key in Object.getOwnPropertyNames(dst)){
+        for(var key in dst){
+            if (org.hasOwnProperty(key)){
+                dst[key] = org[key]
+            }
+        }
+    };
+    //鑾峰彇url鍙傛暟
+    vc.getParam = function(_key){
+        //杩斿洖褰撳墠 URL 鐨勬煡璇㈤儴鍒嗭紙闂彿 ? 涔嬪悗鐨勯儴鍒嗭級銆�
+        var urlParameters = location.search;
+        //濡傛灉璇ユ眰闈掍腑鏈夎姹傜殑鍙傛暟锛屽垯鑾峰彇璇锋眰鐨勫弬鏁帮紝鍚﹀垯鎵撳嵃鎻愮ず姝よ姹傛病鏈夎姹傜殑鍙傛暟
+        if (urlParameters.indexOf('?') != -1)
+        {
+            //鑾峰彇璇锋眰鍙傛暟鐨勫瓧绗︿覆
+            var parameters = decodeURI(urlParameters.substr(1));
+            //灏嗚姹傜殑鍙傛暟浠�&鍒嗗壊涓瓧绗︿覆鏁扮粍
+            parameterArray = parameters.split('&');
+            //寰幆閬嶅巻锛屽皢璇锋眰鐨勫弬鏁板皝瑁呭埌璇锋眰鍙傛暟鐨勫璞′箣涓�
+            for (var i = 0; i < parameterArray.length; i++) {
+                if(_key == parameterArray[i].split('=')[0]){
+                    return parameterArray[i].split('=')[1];
+                }
+            }
+        }
+
+        return "";
+    };
+    //鏌ヨurl
+    vc.getUrl = function(){
+        //杩斿洖褰撳墠 URL 鐨勬煡璇㈤儴鍒嗭紙闂彿 ? 涔嬪悗鐨勯儴鍒嗭級銆�
+        var urlParameters = location.search;
+        //濡傛灉璇ユ眰闈掍腑鏈夎姹傜殑鍙傛暟锛屽垯鑾峰彇璇锋眰鐨勫弬鏁帮紝鍚﹀垯鎵撳嵃鎻愮ず姝よ姹傛病鏈夎姹傜殑鍙傛暟
+        if(urlParameters.indexOf('?') != -1){
+            return urlParameters.substring(0, urlParameters.indexOf('?'));
+        }
+        return urlParameters;
+    };
+    //瀵硅薄杞琯et鍙傛暟
+    vc.objToGetParam =function(obj){
+         var str = [];
+         for (var p in obj)
+          if (obj.hasOwnProperty(p)) {
+           str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+          }
+         return str.join("&");
+    }
+
+
+
+})(window.vc);
+
+/**
+    vc 瀹氭椂鍣ㄥ鐞�
+**/
+(function(w,vc){
+
+    /**
+        鍒涘缓瀹氭椂鍣�
+    **/
+    vc.createTimer = function(func,sec){
+        var _timer = w.setInterval(func,sec);
+        vc.timers.push(_timer); //杩欓噷灏嗘墍鏈夌殑瀹氭椂鍣ㄤ繚瀛樿捣鏉ワ紝椤甸潰閫�鍑烘椂娓呯悊
+
+        return _timer;
+    };
+    //娓呯悊瀹氭椂鍣�
+    vc.clearTimer = function(timer){
+        clearInterval(timer);
+    }
+
+
+})(window,window.vc);
+
+/**
+    鏃堕棿澶勭悊宸ュ叿绫�
+**/
+(function(vc){
+    function add0(m){return m<10?'0'+m:m }
+    vc.dateFormat = function(shijianchuo){
+      //shijianchuo鏄暣鏁帮紝鍚﹀垯瑕乸arseInt杞崲
+      var time = new Date(parseInt(shijianchuo));
+      var y = time.getFullYear();
+      var m = time.getMonth()+1;
+      var d = time.getDate();
+      var h = time.getHours();
+      var mm = time.getMinutes();
+      var s = time.getSeconds();
+      return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
+    }
+})(window.vc);
+
+
+(function(vc){
+
+    vc.propTypes = {
+        string:"string",//瀛楃涓茬被鍨�
+        array:"array",
+        object:"object",
+        number:"number"
+    }
+
+})(window.vc)
\ No newline at end of file

--
Gitblit v1.8.0