|
...
|
...
|
@@ -39,15 +39,12 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
|
|
}
|
|
|
|
if(!fouce && cachetime!=0){//优先使用缓存
|
|
|
|
let getCache= cache(cache_key);
|
|
|
|
//console.log('getCache.'+getCache,cache_key);
|
|
|
|
if(getCache!=-99999){
|
|
|
|
return new Promise((success,fail)=>{
|
|
|
|
if(true){
|
|
|
|
getCache.isCache=true;
|
|
|
|
console.log(cache_key+'\nuse cache',getCache);
|
|
|
|
success(getCache);
|
|
|
|
}else{
|
|
|
|
fail();
|
|
|
|
}
|
|
|
|
getCache.isCache=true;
|
|
|
|
console.log(cache_key+'\nuse cache',getCache);
|
|
|
|
success(getCache);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -78,7 +75,7 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
|
|
console.log('request.api==>',host+cache_key+'\nrequest.success',res.data);
|
|
|
|
// return;
|
|
|
|
if(res.data){
|
|
|
|
if(cachetime!=0 && res.data.ret==200 && res.data.data){
|
|
|
|
if(cachetime!=0 && res.data.ret==200){
|
|
|
|
cache(cache_key,res.data,cachetime);//.then().catch();
|
|
|
|
}
|
|
|
|
if(res.data.ret!==200){
|
|
...
|
...
|
@@ -166,7 +163,7 @@ function cache(key,val=-99999,timeout=-1){ |
|
|
|
}
|
|
|
|
let res=wx.getStorageSync(key);
|
|
|
|
let time=Date.parse(new Date())/1000;
|
|
|
|
if(res && (res.timeout==-1 || res.timeout>time) && res.data.data){
|
|
|
|
if(res && (res.timeout==-1 || res.timeout>time) && res.data){
|
|
|
|
return res.data;
|
|
|
|
}else{
|
|
|
|
return -99999
|
...
|
...
|
|