Bladeren bron

每5分钟10秒 重连socket

lincl 3 jaren geleden
bovenliggende
commit
6d3d7ca9bb
1 gewijzigde bestanden met toevoegingen van 16 en 3 verwijderingen
  1. 16 3
      mini-pro-web/src/views/machine/index.vue

+ 16 - 3
mini-pro-web/src/views/machine/index.vue

@ -161,6 +161,7 @@ export default {
			this.init(1)
		}
		window.SetPrintPage = this.SetPrintPage
		window.vm = this
	},
  	methods: {
		onPrev(){
@ -462,13 +463,13 @@ export default {
						duration: 0,
						forbidClick: true, // 禁用背景点击
						loadingType: 'loading',
						message: "读取医保卡失败",
						message: "读取医保卡超时",
						onClose: ()=>{
							this.onPrev()
						}
					});
				} else {
					this.$toast('读取医保卡失败')
					this.$toast('读取医保卡超时')
				}
			}, 10 * 1000)
@ -521,6 +522,7 @@ export default {
		close: function() {
			console.log("socket已经关闭")
			if(!this.forceClose){
				this.forceClose  = false
				this.reconnect = true
				this.$loading('服务器异常断开,正在重连..')
				console.log("socket已经关闭")
@ -539,7 +541,18 @@ export default {
					mess: "",
				}
				this.socket.send(JSON.stringify(obj));
			}, 60 * 1000)
			}, 30 * 1000)
			if(this.reconnectInterval){
				clearInterval(this.reconnectInterval)
			}
			this.reconnectInterval = setInterval(()=>{
				if(this.socket){
					this.forceClose = true
					this.socket.close()
				}
				this.init()
			}, 5 * 60 * 1000 + 5000)
		},
		sendDeviceInfo: function() {
			var obj = {