修改
This commit is contained in:
parent
28d363d0eb
commit
1efff531ba
@ -37,8 +37,24 @@
|
||||
hr: '',
|
||||
timetext: this.formatDate(Date.now()),
|
||||
measureTime: this.formatDate(Date.now()),
|
||||
uploadType: undefined,
|
||||
timeoutObj: null,
|
||||
socketOpen: false,
|
||||
SOCKETURL: '',
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
bound(uni.getStorageSync('userinfo').cardNo).then(res => {
|
||||
if (res.code == 200) {
|
||||
res.data.forEach(e => {
|
||||
if (e.deviceType == 1) {
|
||||
this.SOCKETURL = `ws://112.6.122.71:8009/fd/webSocket/${e.sn}`
|
||||
this.scoket();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
formatDate(timestamp) {
|
||||
const now = new Date(parseInt(timestamp))
|
||||
@ -55,11 +71,78 @@
|
||||
timeconfirm(time) {
|
||||
this.timetext = time
|
||||
},
|
||||
scoket() {
|
||||
const that = this
|
||||
this.socketOpen = false
|
||||
try {
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
uni.onSocketOpen(res => {
|
||||
console.log('webScoket连接已打开', res);
|
||||
that.socketOpen = true
|
||||
that.reset()
|
||||
})
|
||||
|
||||
uni.onSocketError(err => {
|
||||
console.log('webScoket连接打开失败', err);
|
||||
if (err && err.code != 1000) {
|
||||
setTimeout(() => {
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
})
|
||||
|
||||
uni.onSocketClose(err => {
|
||||
console.log('webScoket连接关闭', err);
|
||||
if (err && err.code !== 1000) {
|
||||
setTimeout(() => {
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
})
|
||||
uni.onSocketMessage(res => {
|
||||
console.log("webScoket监听收到的信息", res);
|
||||
this.uploadType = 2
|
||||
this.hr = JSON.parse(res.data).pulse
|
||||
this.$forceUpdate()
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
// 心跳响应
|
||||
reset() {
|
||||
let that = this
|
||||
clearInterval(that.timeoutObj);
|
||||
that.timeoutObj = setInterval(() => {
|
||||
uni.sendSocketMessage({
|
||||
data: 'ping',
|
||||
success(res) {
|
||||
console.log('正在发送心跳');
|
||||
},
|
||||
fail(err) {
|
||||
console.log('心跳发送失败,重新连接...');
|
||||
console.log(this.SOCKETURL)
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: this.SOCKETURL
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 60000)
|
||||
},
|
||||
submit() {
|
||||
if (this.hr) {
|
||||
let data = {
|
||||
hr: this.hr,
|
||||
uploadType: 1,
|
||||
uploadType: this.uploadType ? this.uploadType : 1,
|
||||
identity: uni.getStorageSync('userinfo').cardNo,
|
||||
measureTime: this.timetext,
|
||||
}
|
||||
@ -91,7 +174,12 @@
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
if (this.socketOpen) {
|
||||
uni.closeSocket();
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -211,4 +299,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@ -49,6 +49,9 @@
|
||||
import {
|
||||
savebp
|
||||
} from '@/api/examinationapi/add.js'
|
||||
import {
|
||||
bound,
|
||||
} from '@/api/examinationapi/add.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -57,8 +60,24 @@
|
||||
hr: '',
|
||||
timetext: this.formatDate(Date.now()),
|
||||
measureTime: this.formatDate(Date.now()),
|
||||
uploadType: undefined,
|
||||
timeoutObj: null,
|
||||
socketOpen: false,
|
||||
SOCKETURL: '',
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
bound(uni.getStorageSync('userinfo').cardNo).then(res => {
|
||||
if (res.code == 200) {
|
||||
res.data.forEach(e => {
|
||||
if (e.deviceType == 1) {
|
||||
this.SOCKETURL = `ws://112.6.122.71:8009/fd/webSocket/${e.sn}`
|
||||
this.scoket();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
formatDate(timestamp) {
|
||||
const now = new Date(parseInt(timestamp))
|
||||
@ -75,6 +94,75 @@
|
||||
timeconfirm(time) {
|
||||
this.timetext = time
|
||||
},
|
||||
scoket() {
|
||||
const that = this
|
||||
this.socketOpen = false
|
||||
try {
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
uni.onSocketOpen(res => {
|
||||
console.log('webScoket连接已打开', res);
|
||||
that.socketOpen = true
|
||||
that.reset()
|
||||
})
|
||||
|
||||
uni.onSocketError(err => {
|
||||
console.log('webScoket连接打开失败', err);
|
||||
if (err && err.code != 1000) {
|
||||
setTimeout(() => {
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
})
|
||||
|
||||
uni.onSocketClose(err => {
|
||||
console.log('webScoket连接关闭', err);
|
||||
if (err && err.code !== 1000) {
|
||||
setTimeout(() => {
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
})
|
||||
uni.onSocketMessage(res => {
|
||||
console.log("webScoket监听收到的信息", res);
|
||||
this.uploadType = 2
|
||||
this.dbp = JSON.parse(res.data).dbp
|
||||
this.sbp = JSON.parse(res.data).sbp
|
||||
this.hr = JSON.parse(res.data).pulse
|
||||
this.$forceUpdate()
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
// 心跳响应
|
||||
reset() {
|
||||
let that = this
|
||||
clearInterval(that.timeoutObj);
|
||||
that.timeoutObj = setInterval(() => {
|
||||
uni.sendSocketMessage({
|
||||
data: 'ping',
|
||||
success(res) {
|
||||
console.log('正在发送心跳');
|
||||
},
|
||||
fail(err) {
|
||||
console.log('心跳发送失败,重新连接...');
|
||||
console.log(this.SOCKETURL)
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: this.SOCKETURL
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 60000)
|
||||
},
|
||||
submit() {
|
||||
if (this.ruls(this.dbp) && this.ruls(this.sbp) && this.ruls(this.hr)) {
|
||||
let data = {
|
||||
@ -83,7 +171,7 @@
|
||||
hr: this.hr,
|
||||
identity: uni.getStorageSync('userinfo').cardNo,
|
||||
measureTime: this.timetext,
|
||||
uploadType: 1,
|
||||
uploadType: this.uploadType ? this.uploadType : 1,
|
||||
}
|
||||
savebp(data).then(res => {
|
||||
if (res.code == 200) {
|
||||
@ -112,8 +200,13 @@
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
},
|
||||
},
|
||||
onUnload() {
|
||||
if (this.socketOpen) {
|
||||
uni.closeSocket();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -228,4 +321,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@ -316,4 +316,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user