|
@@ -1,55 +1,55 @@
|
|
|
-import { Notify } from 'vant'
|
|
|
-import { getLocalOpenId } from './check-patient-id'
|
|
|
-import { url8083, url8085 } from './dev-prod'
|
|
|
-
|
|
|
-let count = 0
|
|
|
-
|
|
|
-let webSocket = null
|
|
|
-
|
|
|
-export function closeWebSocket() {
|
|
|
- if (webSocket !== null) {
|
|
|
- webSocket.close()
|
|
|
- webSocket = null
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-export function initWebSocket() {
|
|
|
- if (webSocket === null) {
|
|
|
- count += 1
|
|
|
- const openId = getLocalOpenId()
|
|
|
- if (count % 2 === 1) {
|
|
|
- webSocket = new WebSocket(url8083 + openId)
|
|
|
- } else {
|
|
|
- webSocket = new WebSocket(url8085 + openId)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- webSocket.onopen = function () {
|
|
|
- count = 0
|
|
|
- console.log('WebSocket连接成功')
|
|
|
- }
|
|
|
-
|
|
|
- webSocket.onmessage = function (e) {
|
|
|
- Notify({
|
|
|
- type: 'primary',
|
|
|
- message: e.data,
|
|
|
- duration: 3000,
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- webSocket.onclose = function () {
|
|
|
- webSocket = null
|
|
|
- if (count >= 60) {
|
|
|
- console.log('重连WebSocket超过最大次数,已放弃。')
|
|
|
- return
|
|
|
- }
|
|
|
- setTimeout(() => {
|
|
|
- initWebSocket()
|
|
|
- }, 10 * 1000)
|
|
|
- }
|
|
|
-
|
|
|
- webSocket.onerror = function () {
|
|
|
- webSocket = null
|
|
|
- console.error('WebSocket连接发生错误')
|
|
|
- }
|
|
|
-}
|
|
|
+// import { Notify } from 'vant'
|
|
|
+// import { getLocalOpenId } from './check-patient-id'
|
|
|
+// import { url8083, url8085 } from './dev-prod'
|
|
|
+
|
|
|
+// let count = 0
|
|
|
+
|
|
|
+// let webSocket = null
|
|
|
+
|
|
|
+// export function closeWebSocket() {
|
|
|
+// if (webSocket !== null) {
|
|
|
+// webSocket.close()
|
|
|
+// webSocket = null
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// export function initWebSocket() {
|
|
|
+// if (webSocket === null) {
|
|
|
+// count += 1
|
|
|
+// const openId = getLocalOpenId()
|
|
|
+// if (count % 2 === 1) {
|
|
|
+// webSocket = new WebSocket(url8083 + openId)
|
|
|
+// } else {
|
|
|
+// webSocket = new WebSocket(url8085 + openId)
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// webSocket.onopen = function () {
|
|
|
+// count = 0
|
|
|
+// console.log('WebSocket连接成功')
|
|
|
+// }
|
|
|
+
|
|
|
+// webSocket.onmessage = function (e) {
|
|
|
+// Notify({
|
|
|
+// type: 'primary',
|
|
|
+// message: e.data,
|
|
|
+// duration: 3000,
|
|
|
+// })
|
|
|
+// }
|
|
|
+
|
|
|
+// webSocket.onclose = function () {
|
|
|
+// webSocket = null
|
|
|
+// if (count >= 60) {
|
|
|
+// console.log('重连WebSocket超过最大次数,已放弃。')
|
|
|
+// return
|
|
|
+// }
|
|
|
+// setTimeout(() => {
|
|
|
+// initWebSocket()
|
|
|
+// }, 10 * 1000)
|
|
|
+// }
|
|
|
+
|
|
|
+// webSocket.onerror = function () {
|
|
|
+// webSocket = null
|
|
|
+// console.error('WebSocket连接发生错误')
|
|
|
+// }
|
|
|
+// }
|