修改
This commit is contained in:
parent
28d363d0eb
commit
1efff531ba
@ -37,8 +37,24 @@
|
|||||||
hr: '',
|
hr: '',
|
||||||
timetext: this.formatDate(Date.now()),
|
timetext: this.formatDate(Date.now()),
|
||||||
measureTime: 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: {
|
methods: {
|
||||||
formatDate(timestamp) {
|
formatDate(timestamp) {
|
||||||
const now = new Date(parseInt(timestamp))
|
const now = new Date(parseInt(timestamp))
|
||||||
@ -55,11 +71,78 @@
|
|||||||
timeconfirm(time) {
|
timeconfirm(time) {
|
||||||
this.timetext = 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() {
|
submit() {
|
||||||
if (this.hr) {
|
if (this.hr) {
|
||||||
let data = {
|
let data = {
|
||||||
hr: this.hr,
|
hr: this.hr,
|
||||||
uploadType: 1,
|
uploadType: this.uploadType ? this.uploadType : 1,
|
||||||
identity: uni.getStorageSync('userinfo').cardNo,
|
identity: uni.getStorageSync('userinfo').cardNo,
|
||||||
measureTime: this.timetext,
|
measureTime: this.timetext,
|
||||||
}
|
}
|
||||||
@ -91,7 +174,12 @@
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
if (this.socketOpen) {
|
||||||
|
uni.closeSocket();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,9 @@
|
|||||||
import {
|
import {
|
||||||
savebp
|
savebp
|
||||||
} from '@/api/examinationapi/add.js'
|
} from '@/api/examinationapi/add.js'
|
||||||
|
import {
|
||||||
|
bound,
|
||||||
|
} from '@/api/examinationapi/add.js'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -57,8 +60,24 @@
|
|||||||
hr: '',
|
hr: '',
|
||||||
timetext: this.formatDate(Date.now()),
|
timetext: this.formatDate(Date.now()),
|
||||||
measureTime: 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: {
|
methods: {
|
||||||
formatDate(timestamp) {
|
formatDate(timestamp) {
|
||||||
const now = new Date(parseInt(timestamp))
|
const now = new Date(parseInt(timestamp))
|
||||||
@ -75,6 +94,75 @@
|
|||||||
timeconfirm(time) {
|
timeconfirm(time) {
|
||||||
this.timetext = 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() {
|
submit() {
|
||||||
if (this.ruls(this.dbp) && this.ruls(this.sbp) && this.ruls(this.hr)) {
|
if (this.ruls(this.dbp) && this.ruls(this.sbp) && this.ruls(this.hr)) {
|
||||||
let data = {
|
let data = {
|
||||||
@ -83,7 +171,7 @@
|
|||||||
hr: this.hr,
|
hr: this.hr,
|
||||||
identity: uni.getStorageSync('userinfo').cardNo,
|
identity: uni.getStorageSync('userinfo').cardNo,
|
||||||
measureTime: this.timetext,
|
measureTime: this.timetext,
|
||||||
uploadType: 1,
|
uploadType: this.uploadType ? this.uploadType : 1,
|
||||||
}
|
}
|
||||||
savebp(data).then(res => {
|
savebp(data).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
@ -112,8 +200,13 @@
|
|||||||
} else {
|
} else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
if (this.socketOpen) {
|
||||||
|
uni.closeSocket();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user