ytj 6 years ago
parent
commit
d3764d40fb
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      src/pages/system/newOrder/newOrderList/index.vue

+ 5
- 1
src/pages/system/newOrder/newOrderList/index.vue View File

144
     Object.keys(this.websockets).forEach((key) => {
144
     Object.keys(this.websockets).forEach((key) => {
145
       console.log(key, this.websockets[key])
145
       console.log(key, this.websockets[key])
146
       this.websockets[key].close()
146
       this.websockets[key].close()
147
+      clearInterval(this.websockets[key].interval)
147
     })
148
     })
148
     this.websockets = {}
149
     this.websockets = {}
149
     next()
150
     next()
312
         this.websockets[wsRealPath].onopen = console.log
313
         this.websockets[wsRealPath].onopen = console.log
313
         this.websockets[wsRealPath].onmessage = this.websocketonmessage
314
         this.websockets[wsRealPath].onmessage = this.websocketonmessage
314
         this.websockets[wsRealPath].onclose = this.reloadWebSocket
315
         this.websockets[wsRealPath].onclose = this.reloadWebSocket
315
-        setInterval(() => this.websockets[wsRealPath].send(10), 120000)
316
+        this.websockets[wsRealPath].interval = setInterval(() => this.websockets[wsRealPath].send(10), 120000)
316
       }
317
       }
317
     },
318
     },
318
     reloadWebSocket (e) {
319
     reloadWebSocket (e) {
319
       console.log(e.currentTarget.url)
320
       console.log(e.currentTarget.url)
321
+      Object.keys(this.websockets).forEach((key) => {
322
+        clearInterval(this.websockets[key].interval)
323
+      })
320
       if (this.needReload) { // 此变量判断是否需要重连
324
       if (this.needReload) { // 此变量判断是否需要重连
321
         this.websockets = {}
325
         this.websockets = {}
322
         this.initWebSocket()
326
         this.initWebSocket()