|
@@ -121,9 +121,9 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <view class="flex-row items-center section_5 space-x-4">
|
|
|
+ <view class="flex-row items-center section_5 space-x-4" @click="modalName = true">
|
|
|
<image class="shrink-0 image_8" src="../../static/home/homeIconChange.png"/>
|
|
|
- <text class="font_3" @click="modalName = 'RadioModal'">切换</text>
|
|
|
+ <text class="font_3">切换</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
@@ -184,7 +184,7 @@
|
|
|
<text class="self-start font_6 text_16">次/分</text>
|
|
|
</view>
|
|
|
<view class="flex-col flex-auto justify-start shrink-0 relative home-data-chart content">
|
|
|
- <view class="echarts-wrap">
|
|
|
+ <view class="echarts-wrap" :hidden="modalName">
|
|
|
<mpvue-echarts class="ec-canvas" canvasId="canvasChart-1" ref="xinlvRefChart" @onInit="onInit1"></mpvue-echarts>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -203,7 +203,7 @@
|
|
|
<text class="self-start font_6 text_16">次/分</text>
|
|
|
</view>
|
|
|
<view class="flex-col flex-auto justify-start shrink-0 relative home-data-chart content">
|
|
|
- <view class="echarts-wrap">
|
|
|
+ <view class="echarts-wrap" :hidden="modalName">
|
|
|
<mpvue-echarts class="ec-canvas" canvasId="canvasChart-2" ref="huxiRefChart" @onInit="onInit2"></mpvue-echarts>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -284,16 +284,16 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <view class="cu-modal" :class="modalName=='RadioModal'?'show':''" @tap="hideModal">
|
|
|
- <view class="cu-dialog" @tap.stop="">
|
|
|
- <view class="cu-bar bg-white justify-end">
|
|
|
- <view style="color: black" class="content">设备切换</view>
|
|
|
+ <view style="z-index: 9999999" class="cu-modal" :class="modalName ?'show':''" @tap="hideModal">
|
|
|
+ <view style="background-image: linear-gradient(45deg, #4d9efa, #156fce);z-index: 9999999" class="cu-dialog" @tap.stop="">
|
|
|
+ <view class="cu-bar justify-end">
|
|
|
+ <view class="content">设备切换</view>
|
|
|
</view>
|
|
|
<radio-group class="block" @change="RadioChange">
|
|
|
<view class="cu-list menu text-left">
|
|
|
- <view class="cu-item" v-for="(item, index) in deviceList" :key="index">
|
|
|
+ <view style="background-image: linear-gradient(45deg, #4d9efa, #156fce)" class="cu-item" v-for="(item, index) in deviceList" :key="index">
|
|
|
<label class="flex justify-between align-center flex-sub">
|
|
|
- <view class="flex-sub">{{ item.imei }}</view>
|
|
|
+ <view class="flex-sub text-white">{{ item.imei }}</view>
|
|
|
<radio class="round" :class="homeFrom.nowDevice===item.imei?'checked':''" :checked="homeFrom.nowDevice === item.imei"
|
|
|
:value="item.imei"></radio>
|
|
|
</label>
|
|
@@ -356,7 +356,8 @@ export default {
|
|
|
memberId: '',
|
|
|
bindSn: '',
|
|
|
bindShow: false,
|
|
|
- modalName: false
|
|
|
+ modalName: false,
|
|
|
+ activeBreak: false
|
|
|
};
|
|
|
},
|
|
|
// onLoad() {
|
|
@@ -375,6 +376,14 @@ export default {
|
|
|
this.memberId = memberId
|
|
|
console.log('this.memberId===', this.memberId)
|
|
|
this.API_getDeviceList()
|
|
|
+ const _this = this
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log('_this.connected====', _this.connected)
|
|
|
+ if (!_this.connected) {
|
|
|
+ console.log('我要登录过...')
|
|
|
+ _this.API_getDeviceList()
|
|
|
+ }
|
|
|
+ }, 1500)
|
|
|
} else {
|
|
|
this.checkHasLogin()
|
|
|
const _this = this
|
|
@@ -392,8 +401,17 @@ export default {
|
|
|
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
+ this.activeBreak = true
|
|
|
this.closeWebsocket()
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ connected() {
|
|
|
+ if (!this.activeBreak && !this.connected) {
|
|
|
+ console.log('监听到webSocket连接断开,现在开始连接')
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// onShow() {
|
|
|
// const imei = Storage.getItem('nowChangeDevice')
|
|
|
// if (imei) {
|
|
@@ -406,12 +424,14 @@ export default {
|
|
|
this.homeFrom.nowDevice = imei
|
|
|
this.deviceAdded = true
|
|
|
if (!this.connected && this.memberId) {
|
|
|
- this.init()
|
|
|
+ console.log('重新连接...')
|
|
|
+ this.connect()
|
|
|
}
|
|
|
} else {
|
|
|
this.deviceAdded = false
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
handleShareClick() {
|
|
|
uni.navigateTo({
|
|
@@ -421,17 +441,21 @@ export default {
|
|
|
API_getDeviceList() {
|
|
|
const _this = this
|
|
|
API_deviceMemberBind.getDeviceByDtypeAndMemberId({dtype: '睡眠床垫', memberId: this.memberId}).then(res => {
|
|
|
- if (res.length === 0) {
|
|
|
- _this.deviceAdded = false
|
|
|
- } else {
|
|
|
- _this.deviceAdded = true
|
|
|
- _this.deviceList = res
|
|
|
- _this.homeFrom.nowDevice = res[0].imei
|
|
|
- Storage.setItem("nowChangeDevice", _this.homeFrom.nowDevice)
|
|
|
- Storage.setItem("myBindDevices", res)
|
|
|
- if (!this.connected) {
|
|
|
- _this.init()
|
|
|
+ if (res) {
|
|
|
+ if (res.length === 0) {
|
|
|
+ _this.deviceAdded = false
|
|
|
+ } else {
|
|
|
+ _this.deviceAdded = true
|
|
|
+ _this.deviceList = res
|
|
|
+ _this.homeFrom.nowDevice = res[0].imei
|
|
|
+ Storage.setItem("nowChangeDevice", _this.homeFrom.nowDevice)
|
|
|
+ Storage.setItem("myBindDevices", res)
|
|
|
+ if (!this.connected) {
|
|
|
+ _this.init()
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ console.log('获取床垫错误...')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -476,23 +500,25 @@ export default {
|
|
|
this.connecting = false
|
|
|
this.connected = false
|
|
|
uni.hideLoading()
|
|
|
- uni.showModal({
|
|
|
- content: '连接失败,可能是websocket服务不可用,请稍后再试',
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
+ console.log('连接失败,可能是websocket服务不可用,请稍后再试!')
|
|
|
+ // uni.showModal({
|
|
|
+ // content: '连接失败,可能是websocket服务不可用,请稍后再试',
|
|
|
+ // showCancel: false
|
|
|
+ // })
|
|
|
console.log('onError', err)
|
|
|
})
|
|
|
this.mySocketTask.onMessage(res => {
|
|
|
let msg = res.data
|
|
|
// console.log('收到消息:', msg)
|
|
|
- if (msg.length === 30) {
|
|
|
+ if (msg.length === 234) {
|
|
|
if (this.homeFrom.nowDevice !== msg.substring(2, 14)) {
|
|
|
return
|
|
|
}
|
|
|
this.homeFrom.status = '在线'
|
|
|
this.lastMsgTime = Date.parse(new Date())
|
|
|
- this.getValue1(parseInt(msg.substring(22, 24), 16))
|
|
|
- this.getValue2(parseInt(msg.substring(24, 26), 16))
|
|
|
+ this.getValue(msg)
|
|
|
+ // this.getValue1(parseInt(msg.substring(22, 24), 16))
|
|
|
+ // this.getValue2(parseInt(msg.substring(24, 26), 16))
|
|
|
switch (msg.substring(26, 28)) {
|
|
|
case "03":
|
|
|
this.sleepStatus = '在床'
|
|
@@ -520,6 +546,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
this.mySocketTask.onClose(res => {
|
|
|
+ console.log('webSocket关闭了...')
|
|
|
this.connected = false
|
|
|
this.msg = false
|
|
|
clearInterval(this.timer)
|
|
@@ -580,6 +607,7 @@ export default {
|
|
|
axisPointer: {
|
|
|
animation: false,
|
|
|
},
|
|
|
+ extraCssText: 'z-index: 2'
|
|
|
},
|
|
|
grid: {
|
|
|
top: '15%',
|
|
@@ -597,11 +625,27 @@ export default {
|
|
|
yAxis: {
|
|
|
type: 'value',
|
|
|
boundaryGap: [0, '100%'],
|
|
|
- min: 0,
|
|
|
- max: xMax,
|
|
|
+ min: function (value) {
|
|
|
+ if (value === 0) {
|
|
|
+ return 0
|
|
|
+ } else {
|
|
|
+ return value.min - 20
|
|
|
+ }
|
|
|
+ },
|
|
|
+ max: function (value) {
|
|
|
+ return value.max + 20
|
|
|
+ },
|
|
|
+ // min: 0,
|
|
|
+ // min: 'dataMin', // 取数据在该轴上的最大值作为最小刻度
|
|
|
+ // max: xMax,
|
|
|
// max: 'dataMax', // 取数据在该轴上的最大值作为最大刻度
|
|
|
splitLine: {
|
|
|
- show: false, // 是否显示分隔线
|
|
|
+ show: true, // 是否显示分隔线
|
|
|
+ lineStyle: {
|
|
|
+ color: "rgba(168,162,162,0.6)",
|
|
|
+ width: 1,
|
|
|
+ type: 'dotted'
|
|
|
+ }
|
|
|
},
|
|
|
axisLine: {
|
|
|
show: false, // 是否显示坐标轴轴线
|
|
@@ -628,6 +672,56 @@ export default {
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
+ getValue(msg) {
|
|
|
+ this.pjxl = parseInt(msg.substring(22, 24), 16)
|
|
|
+ this.pjhx = parseInt(msg.substring(24, 26), 16)
|
|
|
+ const bx = msg.substring(34, msg.length);
|
|
|
+ const size = bx.length / 4
|
|
|
+ const ii = size / 2;
|
|
|
+ if (this.myData1.length > 100) {
|
|
|
+ this.myData1.splice(0, ii)
|
|
|
+ }
|
|
|
+ if (this.myData2.length > 100) {
|
|
|
+ this.myData2.splice(0, ii)
|
|
|
+ }
|
|
|
+ if (this.myCount1 > 300) {
|
|
|
+ this.myCount1 = 0
|
|
|
+ }
|
|
|
+ if (this.myCount2 > 300) {
|
|
|
+ this.myCount2 = 0
|
|
|
+ }
|
|
|
+ for (let i = 0; i < size; i++) {
|
|
|
+ // bx.substring(i * 4, i * 4 + 4)
|
|
|
+ const j = i * 4
|
|
|
+ // console.log(bx.substring(j, j + 2), bx.substring(j + 2, j + 4))
|
|
|
+ const s1 = bx.substring(j, j + 2)
|
|
|
+ const s2 = bx.substring(j + 2, j + 4)
|
|
|
+ let value = parseInt(s2 + s1 , 16)
|
|
|
+ // if (parseInt(s1, 16) > parseInt(s2, 16)) {
|
|
|
+ // value = parseInt(s2 + s1, 16)
|
|
|
+ // } else {
|
|
|
+ // value = parseInt(s1 + s2, 16)
|
|
|
+ // }
|
|
|
+ // if (value === 2) {
|
|
|
+ // console.log(s1, s2)
|
|
|
+ // if (parseInt(s1, 16) > parseInt(s2, 16)) {
|
|
|
+ // console.log('111111111===', parseInt(s1, 16), parseInt(s2, 16), s2 + '' + s1, parseInt(s2 + '' + s1, 16))
|
|
|
+ // } else {
|
|
|
+ // console.log('2222222222=====', parseInt(s1, 16), parseInt(s2, 16), s1 + s2, parseInt(s1 + '' + s2, 16))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // console.log('value=====', value)
|
|
|
+ if (i % 2 === 0) {
|
|
|
+ this.myCount1 ++
|
|
|
+ this.myData1.push([this.myCount1, value])
|
|
|
+ } else {
|
|
|
+ this.myCount2 ++
|
|
|
+ this.myData2.push([this.myCount2, value])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.myChart1.setOption(this.options1)
|
|
|
+ this.myChart2.setOption(this.options2)
|
|
|
+ },
|
|
|
getValue1(value) {
|
|
|
// console.log("心率是", value)
|
|
|
this.pjxl = value
|
|
@@ -662,7 +756,7 @@ export default {
|
|
|
this.myData2.push([this.myCount2, value])
|
|
|
}
|
|
|
} else {
|
|
|
- value = parseInt((Math.random(10) * 300 + 100))
|
|
|
+ value = parseInt((Math.random(10) * 200 + 100))
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
this.myCount2 ++;
|
|
|
value += parseInt(Math.random() * 10 - 5)
|
|
@@ -805,7 +899,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
hideModal(e) {
|
|
|
- this.modalName = null
|
|
|
+ this.modalName = false
|
|
|
},
|
|
|
RadioChange(e) {
|
|
|
console.log('1111111==', e.detail.value)
|