// GetZTreeListNew, // 缓存管理对象 const cacheManager = { // 封装带缓存的AJAX请求 fetchData: function(key, url, params={},forceRefresh = false) { const self = this; var storageData = localStorage.getItem(key) // 否则发起AJAX请求 return new Promise((resolve, reject) => { if (storageData) { // 否则发起AJAX请求 const parsedData = JSON.parse(storageData); resolve(parsedData); } else { // 模拟AJAX请求 params.token = $.cookie("token") $.ajax({ type: "get", url: huayi.config.callcenter_url + url, dataType: 'json', async: false, data:params , success: function (data) { if (data.state && data.state.toLowerCase() == "success") { localStorage.setItem(key, JSON.stringify(data)); resolve(data); } if (data.rows && data.rows.length >0 ) { localStorage.setItem(key, JSON.stringify(data)); resolve(data); } } }); } }); }, // 清除指定缓存 clearCache: function(key) {}, // 检查缓存是否存在 hasCache: function(key) {} }; //cacheManager.fetchData('GetZTreeListNew',"Dictionary/GetZTreeListNew",{pid: 38 }).then(data => { // console.log('信息加载完成', 'success',data); // }).catch(error => { // console.log('加载失败' + error.message, 'GetZTreeListNew'); // });