Showing
1 changed file
with
6 additions
and
5 deletions
| @@ -15,8 +15,9 @@ class rpcm { | @@ -15,8 +15,9 @@ class rpcm { | ||
| 15 | tasks = {} | 15 | tasks = {} |
| 16 | 16 | ||
| 17 | check(key) { | 17 | check(key) { |
| 18 | - let nt = parseInt((new Date() / 1000)) | 18 | + let nt = new Date().getTime() |
| 19 | if (this.tasks[key]) { | 19 | if (this.tasks[key]) { |
| 20 | + //console.log('resSetIntervalnt',nt , this.tasks[key].timeout) | ||
| 20 | if (nt <= this.tasks[key].timeout) { | 21 | if (nt <= this.tasks[key].timeout) { |
| 21 | return true | 22 | return true |
| 22 | } | 23 | } |
| @@ -27,7 +28,7 @@ class rpcm { | @@ -27,7 +28,7 @@ class rpcm { | ||
| 27 | get(key) { | 28 | get(key) { |
| 28 | return new Promise((success, fail) => { | 29 | return new Promise((success, fail) => { |
| 29 | let resSetInterval=setInterval(()=>{ | 30 | let resSetInterval=setInterval(()=>{ |
| 30 | - //console.log('resSetInterval',this.tasks[key]) | 31 | + console.log('resSetInterval',key,this.tasks[key]) |
| 31 | if(this.tasks[key].type=='success'){ | 32 | if(this.tasks[key].type=='success'){ |
| 32 | wx.hideLoading(); | 33 | wx.hideLoading(); |
| 33 | success(this.tasks[key].res) | 34 | success(this.tasks[key].res) |
| @@ -44,13 +45,13 @@ class rpcm { | @@ -44,13 +45,13 @@ class rpcm { | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | set(key,type='',res=null) { | 47 | set(key,type='',res=null) { |
| 47 | - let nt = parseInt((new Date() / 1000)) | 48 | + let nt = new Date().getTime() |
| 48 | this.tasks[key] = { | 49 | this.tasks[key] = { |
| 49 | - timeout: nt + 1000 | 50 | + timeout: nt + 5000 |
| 50 | } | 51 | } |
| 51 | if(type){ | 52 | if(type){ |
| 52 | this.tasks[key]['type']=type | 53 | this.tasks[key]['type']=type |
| 53 | - this.tasks[key]['res']=res | 54 | + this.tasks[key]['res']=JSON.parse(JSON.stringify(res)) |
| 54 | } | 55 | } |
| 55 | } | 56 | } |
| 56 | } | 57 | } |
-
Please register or login to post a comment