xujing 5 年前
父节点
当前提交
d904ec41f7
共有 3 个文件被更改,包括 16 次插入5 次删除
  1. 4
    4
      config/prod.js
  2. 5
    1
      src/app.js
  3. 7
    0
      src/utils/im.js

+ 4
- 4
config/prod.js 查看文件

3
     NODE_ENV: '"production"'
3
     NODE_ENV: '"production"'
4
   },
4
   },
5
   defineConstants: {
5
   defineConstants: {
6
-    // HOST: '"http://192.168.0.218:8080"',
7
-    // WSS_HOST: '"ws://192.168.0.218:8080"',
8
-    HOST: '"https://dev.jinchengjiaye.com"',//测试
9
-    WSS_HOST: '"wss://dev.jinchengjiaye.com"',
6
+    HOST: '"http://192.168.2.54:8080"',
7
+    WSS_HOST: '"ws://192.168.2.54:8080"',
8
+    // HOST: '"https://dev.jinchengjiaye.com"',//测试
9
+    // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10
     // HOST: '"https://lt.pawoma.cn"',
10
     // HOST: '"https://lt.pawoma.cn"',
11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
12
     Version:'V3.5.5_2019-12-24'
12
     Version:'V3.5.5_2019-12-24'

+ 5
- 1
src/app.js 查看文件

152
 
152
 
153
   componentDidHide() {
153
   componentDidHide() {
154
     // ready.close()
154
     // ready.close()
155
-    // socket.closeSocket()
155
+    socket.closeSocket()
156
   }
156
   }
157
 
157
 
158
   componentDidShow() {
158
   componentDidShow() {
174
         }
174
         }
175
       })
175
       })
176
     })
176
     })
177
+
178
+    socket.reconnect()
177
   }
179
   }
180
+  
178
   componentDidMount() {
181
   componentDidMount() {
179
     // console.info('app componentDidMount')
182
     // console.info('app componentDidMount')
180
   }
183
   }
184
+
181
   componentWillMount(params) {
185
   componentWillMount(params) {
182
     // console.info('app componentWillMount', params)
186
     // console.info('app componentWillMount', params)
183
     this.initData()
187
     this.initData()

+ 7
- 0
src/utils/im.js 查看文件

13
   }
13
   }
14
 
14
 
15
   reconnect() {
15
   reconnect() {
16
+    if (!this.option) return;
17
+    if (this.socketOpen) return;
16
     if (this.lockReconnect) return;
18
     if (this.lockReconnect) return;
19
+
17
     this.lockReconnect = true;
20
     this.lockReconnect = true;
18
     clearTimeout(this.timer)
21
     clearTimeout(this.timer)
19
     console.log('reconnect')
22
     console.log('reconnect')
54
     this.wss.onClose(res => {
57
     this.wss.onClose(res => {
55
       console.log('已关闭', res)
58
       console.log('已关闭', res)
56
       close && close(res)
59
       close && close(res)
60
+      this.socketOpen = false
57
 
61
 
58
       // 手动关闭的就不要重启了 
62
       // 手动关闭的就不要重启了 
59
       if (!this.selfClose) {
63
       if (!this.selfClose) {
64
     this.wss.onError(err => {
68
     this.wss.onError(err => {
65
       console.log('打印错误', err)
69
       console.log('打印错误', err)
66
       fail && fail(err)
70
       fail && fail(err)
71
+      this.socketOpen = false
72
+      
67
       if (!this.selfClose) {
73
       if (!this.selfClose) {
68
         this.reconnect()
74
         this.reconnect()
69
       }
75
       }
91
         code: 1000,
97
         code: 1000,
92
         reason: '退出页面'
98
         reason: '退出页面'
93
       })
99
       })
100
+      this.socketOpen = false
94
       console.log('已退出 scoket')
101
       console.log('已退出 scoket')
95
     } else {
102
     } else {
96
       console.error('scoket 没有启动')
103
       console.error('scoket 没有启动')