| | |
| | | }); |
| | | }, |
| | | 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'); |
| | | }); |
| | | }, |
| | | upload:function(componentCode,componentMethod,param,options,successCallback,errorCallback){ |
| | | vc.loading('open'); |
| | | Vue.http.post('/callComponent/upload/'+componentCode +"/"+componentMethod, param, options) |
| | | .then(function(res){ |
| | | successCallback(res.bodyText,res); |
| | | vc.loading('close'); |
| | |
| | | errorCallback(error.bodyText,error); |
| | | vc.loading('close'); |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | }; |
| | | |
| | |
| | | return JSON.parse(window.localStorage.getItem('hc_menus')); |
| | | }; |
| | | |
| | | //保存菜单状态 |
| | | vc.setMenuState = function(_menuState){ |
| | | window.localStorage.setItem('hc_menu_state',_menuState); |
| | | }; |
| | | //获取菜单状态 |
| | | vc.getMenuState = function(){ |
| | | return window.localStorage.getItem('hc_menu_state'); |
| | | }; |
| | | |
| | | //保存用户菜单 |
| | | 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)); |
| | |
| | | } |
| | | } |
| | | }; |
| | | //扩展 现有的对象 没有的属性扩充上去 |
| | | vc.extendObject = function(org,dst){ |
| | | for(var key in dst){ |
| | | if (!org.hasOwnProperty(key)){ |
| | | dst[key] = org[key] |
| | | } |
| | | } |
| | | }; |
| | | //获取url参数 |
| | | vc.getParam = function(_key){ |
| | | //返回当前 URL 的查询部分(问号 ? 之后的部分)。 |
| | |
| | | |
| | | return ""; |
| | | }; |
| | | //查询url |
| | | vc.getUrl = function(){ |
| | | //返回当前 URL 的查询部分(问号 ? 之后的部分)。 |
| | | var urlParameters = location.pathname; |
| | | return urlParameters; |
| | | }; |
| | | //对象转get参数 |
| | | vc.objToGetParam =function(obj){ |
| | | var str = []; |
| | |
| | | str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); |
| | | } |
| | | return str.join("&"); |
| | | } |
| | | //空判断 true 为非空 false 为空 |
| | | vc.notNull = function(_paramObj){ |
| | | if(_paramObj == null || _paramObj == undefined || _paramObj.trim() == ''){ |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | var s = time.getSeconds(); |
| | | return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s); |
| | | } |
| | | |
| | | })(window.vc); |
| | | |
| | | |