|
@@ -39,15 +39,12 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
@@ -39,15 +39,12 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
39
|
}
|
39
|
}
|
|
40
|
if(!fouce && cachetime!=0){//优先使用缓存
|
40
|
if(!fouce && cachetime!=0){//优先使用缓存
|
|
41
|
let getCache= cache(cache_key);
|
41
|
let getCache= cache(cache_key);
|
|
|
|
42
|
+ //console.log('getCache.'+getCache,cache_key);
|
|
42
|
if(getCache!=-99999){
|
43
|
if(getCache!=-99999){
|
|
43
|
return new Promise((success,fail)=>{
|
44
|
return new Promise((success,fail)=>{
|
|
44
|
- if(true){
|
|
|
|
45
|
- getCache.isCache=true;
|
|
|
|
46
|
- console.log(cache_key+'\nuse cache',getCache);
|
|
|
|
47
|
- success(getCache);
|
|
|
|
48
|
- }else{
|
|
|
|
49
|
- fail();
|
|
|
|
50
|
- }
|
45
|
+ getCache.isCache=true;
|
|
|
|
46
|
+ console.log(cache_key+'\nuse cache',getCache);
|
|
|
|
47
|
+ success(getCache);
|
|
51
|
})
|
48
|
})
|
|
52
|
}
|
49
|
}
|
|
53
|
}
|
50
|
}
|
|
@@ -78,7 +75,7 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
@@ -78,7 +75,7 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0, |
|
78
|
console.log('request.api==>',host+cache_key+'\nrequest.success',res.data);
|
75
|
console.log('request.api==>',host+cache_key+'\nrequest.success',res.data);
|
|
79
|
// return;
|
76
|
// return;
|
|
80
|
if(res.data){
|
77
|
if(res.data){
|
|
81
|
- if(cachetime!=0 && res.data.ret==200 && res.data.data){
|
78
|
+ if(cachetime!=0 && res.data.ret==200){
|
|
82
|
cache(cache_key,res.data,cachetime);//.then().catch();
|
79
|
cache(cache_key,res.data,cachetime);//.then().catch();
|
|
83
|
}
|
80
|
}
|
|
84
|
if(res.data.ret!==200){
|
81
|
if(res.data.ret!==200){
|
|
@@ -166,7 +163,7 @@ function cache(key,val=-99999,timeout=-1){ |
|
@@ -166,7 +163,7 @@ function cache(key,val=-99999,timeout=-1){ |
|
166
|
}
|
163
|
}
|
|
167
|
let res=wx.getStorageSync(key);
|
164
|
let res=wx.getStorageSync(key);
|
|
168
|
let time=Date.parse(new Date())/1000;
|
165
|
let time=Date.parse(new Date())/1000;
|
|
169
|
- if(res && (res.timeout==-1 || res.timeout>time) && res.data.data){
|
166
|
+ if(res && (res.timeout==-1 || res.timeout>time) && res.data){
|
|
170
|
return res.data;
|
167
|
return res.data;
|
|
171
|
}else{
|
168
|
}else{
|
|
172
|
return -99999
|
169
|
return -99999
|