From 6c6b7ab6627ac1e54c8d185a735064ef704ca7dd Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 27 Feb 2024 20:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=AE=8D=E5=9B=BA=E4=BB=B6=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=AE=8C=E6=88=90=EF=BC=8Cwl200=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E7=9B=AE=E5=89=8D=E7=BC=BA=E5=A4=B1wl200?= =?UTF-8?q?=E5=9B=BA=E4=BB=B6=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/bluetoot/connection/index.tsx | 210 ++++++++++-------- .../bluetoot/update-wl200/index.tsx | 59 +++-- src/pages/index/index.tsx | 139 ++++-------- src/pages/iotCarePlan/iotCarePlan.tsx | 2 + 5 files changed, 212 insertions(+), 200 deletions(-) diff --git a/package.json b/package.json index 115d2ad..0295a77 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "dependencies": { "@antmjs/vantui": "^3.2.2", "@flossom-npm/iot-translater": "^1.0.8", - "@flossom-npm/iot-translater-we100": "^1.0.66", + "@flossom-npm/iot-translater-we100": "^1.1.1", "@reduxjs/toolkit": "^2.0.1", "@taroify/core": "^0.1.1-alpha.8", "@tarojs/components": "3.6.19", diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 35cf451..6d419e1 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -32,22 +32,30 @@ import { getofflineData, hex2int, getTimeCode, + isNeedToUpdate, } from "@/utils/util"; const log = require("@/utils/log"); import commandMap from "@/utils/commandMap"; import { bleCommandSamples } from "./test"; import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; -const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200"); +const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200"); deviceToolKitInstanceWL200.setDebug(true); +// const _deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200"); + const deviceToolKitInstanceM01 = new DeviceToolKitWE100("WE100", "M01"); deviceToolKitInstanceM01.setDebug(true); const deviceToolKitInstanceFR200 = new DeviceToolKitFR200("FR200"); import { DeviceToolKit as DeviceToolKitFR200 } from "@flossom-npm/iot-translater"; -import { showModal, msg } from "@/utils/traoAPI"; +import { + showModal, + msg, + setStorageSync, + getStorageSync, +} from "@/utils/traoAPI"; // const { InstrumentTypeEnum, OtaDeviceTypeEnum } = app.globalData; import InstrumentTypeEnum from "../InstrumentTypeEnum"; @@ -72,10 +80,10 @@ let sendgetversionTimer: any = null; let sendGetVersionTimerNum = 0; let searchBluetootTimers: any = null; // 搜索蓝牙定时器 -let searchBluetootTimersNum = 0; // 搜索蓝牙秒数 +let searchBluetootTimersNum = 15; // 搜索蓝牙秒数 15秒 let connectionTimer: any = null; // 连接蓝牙定时器 -let connectionTimerNum = 0; +let connectionTimerNumber = 10000; // 连接蓝牙超时毫秒 let sendPairingTimer: any = null; // 发送配对 @@ -106,6 +114,16 @@ class ConnectionBluetoot extends Component { offlineDataindex: 0, //离线记录发送下标index versionInfo: {}, //版本号 offlineDataList: [], //离线数据 + + prefix: "12CAA", // WL200蓝牙搜索前缀 + + // WL200匹配 + tranType: [ + "WE100", // 发箍 + "WE200", // 发箍 + "WL200", // 发箍 + "12CAA", // 面罩前缀名 + ], }; } @@ -122,6 +140,14 @@ class ConnectionBluetoot extends Component { async initData() {} + isWL200() { + let currentDevicesName = getStorageSync("currentDevicesName"); + if (currentDevicesName.indexOf("12CAA") > -1) { + return true; + } + return false; + } + close() { clearInterval(sendPairingTimer); clearInterval(sendgetversionTimer); @@ -267,7 +293,7 @@ class ConnectionBluetoot extends Component { "searchBluetootTimersNum value => ", searchBluetootTimersNum ); - if (searchBluetootTimersNum === 8) { + if (searchBluetootTimersNum === 15) { clearInterval(searchBluetootTimers); this.setState({ error: true, @@ -289,43 +315,36 @@ class ConnectionBluetoot extends Component { onBluetoothDeviceFound() { Taro.onBluetoothDeviceFound((item: any) => { console.log("蓝牙查找item", item, item.devices[0].name); - /* - * 这里增加判断,类型不同识别的设备名称不一样 - * type1 FR200 - * type2 WM100 - * type3 we100 - * type4 FR380 - * */ - // const tranType = { - // 1: "FR200", - // 3: "WE200", // WL200 - // 4: "FR380", - // 5: "FR390", - // 6: "WE200", // M01 - // }; - // let type = this.props.yiqiInfo.model || "FR200"; - let type = "WE200"; - // this.props.yiqiInfo.model = type; - console.log("this.props.yiqiInfo.model", this.props.yiqiInfo.model); console.info("搜索到到蓝牙设备 value => ", item.devices[0]?.name); + console.log(">>>>>>>当前传入设备类型>>>>>", this.props.yiqiInfo.model); + // 先匹配到哪个连接哪个 + let tranType = [ + this.props.yiqiInfo.model, // 当前传入设备类型 + ...this.state.tranType, + ]; for (let i = 0; i < item.devices.length; i++) { - if ( - item.devices[i].connectable && - (item.devices[i].localName - ? item.devices[i].localName - : item.devices[i].name - ).indexOf(`${type}`) !== -1 - ) { - console.log("连接的设备信息", item.devices[i], type); + let devicesName = item.devices[i].localName || item.devices[i].name; + console.log("devicesName", devicesName); + console.log("tranType", tranType); + // 是否匹配可连接设备 + let isAvailable = tranType.some( + (item) => devicesName && devicesName.indexOf(item) > -1 + ); + console.log("isAvailable", isAvailable); + // 判断设备是否可连接 + if (item.devices[i].connectable && isAvailable) { + // 缓存当前连接设备名 可能是发箍或面罩 + setStorageSync("currentDevicesName", devicesName); + console.log("连接的设备信息", item.devices[i], devicesName); + let params = { deviceId: item.devices[i].deviceId, }; - this.props.setDeviceId(params); + this.props.setDeviceId(params); // 设置蓝牙连接设备ID setTimeout(() => { clearInterval(searchBluetootTimers); Taro.stopBluetoothDevicesDiscovery(); //停止搜索蓝牙 - // app.globalData.deviceInfo.deviceId = item.devices[i].deviceId; this.createBLEConnection(); }, 10); break; @@ -343,10 +362,6 @@ class ConnectionBluetoot extends Component { } catch (e) {} clearTimeout(connectionTimer); const { yiqiInfo: deviceInfo } = this.props; - console.log( - "this.props.bluetoothInfo.deviceId", - this.props.bluetoothInfo.deviceId - ); /*********开始主动连接*******/ createBLEConnection(this.props.bluetoothInfo.deviceId) .then((res) => { @@ -362,7 +377,7 @@ class ConnectionBluetoot extends Component { if (overTimer) clearTimeout(overTimer); this.failErrorCode(-1, "连接蓝牙失败,请重新开机后重试"); } - }, 10000); + }, connectionTimerNumber); } this.getBLEDeviceServices(); //获取特征 } else { @@ -424,6 +439,7 @@ class ConnectionBluetoot extends Component { console.log("onBLECharacteristicValueChange value => ", value); let str = ab2hex(value.value); //转为16进制字符串 console.log("转为16进制字符串 str", str); + let connectionStatus = [ "FR200", "WL200", @@ -434,27 +450,29 @@ class ConnectionBluetoot extends Component { let jsonStatus: any = null; let querySubDeviceArrayBuffer; + if (deviceInfo.model == "WL200") { - querySubDeviceArrayBuffer = - deviceToolKitInstanceWL200.toBleCommand( - bleCommandSamples.querySubDevice as any + if (this.isWL200()) { + jsonStatus = deviceToolKitInstanceWL200.toJsonStatus( + value.value ); - jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(value.value); - // jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value); - // querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand( - // bleCommandSamples.querySubDevice as any - // ); // todo + querySubDeviceArrayBuffer = + deviceToolKitInstanceWL200.toBleCommand( + bleCommandSamples.querySubDevice as any + ); + } else { + jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value); + querySubDeviceArrayBuffer = + deviceToolKitInstanceM01.toBleCommand( + bleCommandSamples.querySubDevice as any + ); + } } else if (deviceInfo.model == "M01") { jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value); querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand( bleCommandSamples.querySubDevice as any ); } - // log.info( - // commandMap.reciviedBLECommand, - // `仪器模式: ${deviceInfo.model}`, - // jsonStatus - // ); console.log( commandMap.reciviedBLECommand, `仪器模式: ${deviceInfo.model}`, @@ -487,7 +505,7 @@ class ConnectionBluetoot extends Component { }*/ } break; - case "BleStatusSync": + case "BleStatusSync": // 设备连接状态 if (jsonStatus.connectMessage?.connectType == "CONNECTED") { switch (jsonStatus.connectMessage?.deviceName) { case OtaDeviceTypeEnum.WE100: @@ -523,9 +541,24 @@ class ConnectionBluetoot extends Component { subDeviceConnectedStatus: true, synchronousStatus: true, }); - const deviceVersionNo = jsonStatus.versionNo; - const latestVersionNo = deviceInfo.iot_versions; - // const isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo) + + let currentDevicesName = getStorageSync("currentDevicesName"); + let deviceVersionNo = jsonStatus.versionNo; + let latestVersionNo = deviceInfo.iotVersion; + if (currentDevicesName.indexOf("12CAA") < -1) { + latestVersionNo = deviceInfo.we200IotVersion; + } + const isNeedToUpdateBl = isNeedToUpdate( + deviceVersionNo, + latestVersionNo + ); + console.log("deviceInfo", deviceInfo); + console.log("isNeedToUpdateBl", isNeedToUpdateBl); + if (isNeedToUpdateBl) { + // 版本号需要更新,显示更新弹窗 + this.props.upgradeFun(); + } + // 判断是否需要升级 // M01和WL200 不需要在这里进行蓝牙更新 // if (isNeedToUpdateBl) { @@ -551,9 +584,12 @@ class ConnectionBluetoot extends Component { hasSyncRecord: true, synchronousStatus: true, }); - console.log("offlineClockSummary value =>", jsonStatus); - // this.triggerEvent("pairingChange", this.state); - this.pairingChange(this.state); + console.log( + "离线汇总offlineClockSummary value =>", + jsonStatus + ); + // this.triggerEvent("pairingChange", this.state); + // this.pairingChange(this.state); // TODO 查询离线记录结果 default: break; @@ -629,25 +665,20 @@ class ConnectionBluetoot extends Component { value: `dbf0a00300${ccrc8("dbf0a00300")}de`, }); } else { - // const otaDeviceType = deviceInfo.type == instrumentTypeEnum.WL200 ? OtaDeviceTypeEnum.WL200 : OtaDeviceTypeEnum.WE100; - // 通过发箍连 都用we100 - const otaDeviceType = - deviceInfo.model == InstrumentTypeEnum.WL200 - ? OtaDeviceTypeEnum.WE100 - : OtaDeviceTypeEnum.WE100; + const otaDeviceType = this.isWL200() + ? OtaDeviceTypeEnum.WL200 + : OtaDeviceTypeEnum.WE100; const versionCommand = { commandType: "InfoQuery", infoQueryType: "versionInfo", otaDeviceType, }; - // const value = - // deviceInfo.model == InstrumentTypeEnum.WL200 - // ? deviceToolKitInstanceM01.toBleCommand(versionCommand as any) - // : deviceToolKitInstanceM01.toBleCommand(versionCommand as any); - const value = - deviceInfo.type == InstrumentTypeEnum.WL200 - ? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any) - : deviceToolKitInstanceM01.toBleCommand(versionCommand as any); + console.log("versionCommand", versionCommand); + + // 区分WL200 和 发箍 + const value = this.isWL200() + ? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any) + : deviceToolKitInstanceM01.toBleCommand(versionCommand as any); sendCommand({ value }); } } @@ -710,14 +741,20 @@ class ConnectionBluetoot extends Component { ); break; case InstrumentTypeEnum.WL200: - // console.log("WL200无法配对,只能用M01"); console.log("正在发送WL200", bleCommandSamples.match); - // matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand( - // bleCommandSamples.match as any - // ); - matchArrayBuffer = deviceToolKitInstanceM01.toBleCommand( - bleCommandSamples.match as any - ); + let currentDevicesName = getStorageSync("currentDevicesName"); + // 区分面罩和发箍 + if (currentDevicesName.indexOf("12CAA") > -1) { + console.log("12CAA"); + matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand( + bleCommandSamples.match as any + ); + } else { + matchArrayBuffer = deviceToolKitInstanceM01.toBleCommand( + bleCommandSamples.match as any + ); + } + break; case InstrumentTypeEnum.FR380: writeBLECharacteristicValue({ @@ -905,7 +942,8 @@ class ConnectionBluetoot extends Component { isGetSubDeviceTimer = setInterval(() => { sendCommand({ value }); isGetSubDeviceTimerNum += 1; - if (isGetSubDeviceTimerNum == 8) { + // 15秒超时 + if (isGetSubDeviceTimerNum === 15) { this.closeQuerySubDevice(); this.setState({ error: true, @@ -928,7 +966,6 @@ class ConnectionBluetoot extends Component { isGetVersionTimer = setInterval(() => { if (this.state.hasVersionInfo) { if (isGetVersionTimer) clearTimeout(isGetVersionTimer); - // that.sendSyncRecording() } else { sendGetVersionTimerNum += 1; if (sendGetVersionTimerNum >= 10) { @@ -937,8 +974,8 @@ class ConnectionBluetoot extends Component { this.setState({ connectionStatus: true, }); - console.log("this.pairingChange", this.state); - this.pairingChange(this.state); + console.log("超时未返回版本号 this.pairingChange", this.state); + // this.pairingChange(this.state); } else { this.sendGetVersion(); } @@ -963,10 +1000,9 @@ class ConnectionBluetoot extends Component { commandType: "InfoQuery", infoQueryType: "offlineClockSummary", }; - const value = - deviceInfo.model == InstrumentTypeEnum.WL200 - ? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any) - : deviceToolKitInstanceM01.toBleCommand(versionCommand as any); + const value = this.isWL200() + ? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any) + : deviceToolKitInstanceM01.toBleCommand(versionCommand as any); sendCommand({ value }).then(); if (isGetSyncRecordingTimer) clearTimeout(isGetSyncRecordingTimer); isGetSyncRecordingTimer = setTimeout(() => { diff --git a/src/components/bluetoot/update-wl200/index.tsx b/src/components/bluetoot/update-wl200/index.tsx index d31f281..92ef3e4 100644 --- a/src/components/bluetoot/update-wl200/index.tsx +++ b/src/components/bluetoot/update-wl200/index.tsx @@ -40,8 +40,12 @@ import OtaDeviceTypeEnum from "../OtaDeviceTypeEnum"; // 临时替代 var log = console; -var deviceToolKitInstance: any = null; -deviceToolKitInstance = new DeviceToolKitWE100("WE100", "WL200"); + +let deviceToolKitInstance: any = null; +// WE200 M01 M02都是WE200 +let deviceToolKitInstanceM01 = new DeviceToolKitWE100("WE100", "M01"); +// WL200面罩 +let deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200"); import "./index.less"; @@ -80,8 +84,24 @@ class UpdateIotWL200 extends Component { this.initData(); } + isWL200() { + let currentDevicesName = getStorageSync("currentDevicesName"); + if (currentDevicesName.indexOf("12CAA") > -1) { + return true; + } + return false; + } + async initData() { console.log("UpdateIotWL200"); + if (this.isWL200()) { + console.log("WL200更新"); + deviceToolKitInstance = deviceToolKitInstanceWL200; + } else { + console.log("WE100更新"); + deviceToolKitInstance = deviceToolKitInstanceM01; + } + let objStr = getStorageSync("instrument_detail"); if (objStr) { let info = JSON.parse(objStr); @@ -89,12 +109,6 @@ class UpdateIotWL200 extends Component { this.setState({ currentDevice: info, }); - - if (info.model == InstrumentTypeEnum.WL200) { - deviceToolKitInstance = new DeviceToolKitWE100("WE100", "WL200"); - } else { - deviceToolKitInstance = new DeviceToolKitWE100("WE100", "M01"); - } } setTimeout(() => { this.notifyBLECharacteristicValueChange(); @@ -134,22 +148,22 @@ class UpdateIotWL200 extends Component { */ startOTA() { this.resetOta(); - const { currentDevice } = this.state; let jsoncmd = { commandType: "OTAStart", otaDeviceType: "", versionNo: this.$otaDataGroup.versionNo, }; // 根据设备类型传 otaDeviceType - if (currentDevice.model == InstrumentTypeEnum.M01) { - jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WE100; - } else { + if (this.isWL200()) { jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WL200; + } else { + jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WE100; } - // deviceToolKitInstance.setDebug(true) + + console.log("startOTA jsoncmd", jsoncmd); //@ts-ignore - const value = deviceToolKitInstance.toBleCommand(jsoncmd); + const value = deviceToolKitInstance.toBleCommand(jsoncmd as any); console.log(jsoncmd); sendCommand({ value }).then((res) => { this.setState({ @@ -173,7 +187,7 @@ class UpdateIotWL200 extends Component { }; console.info("OTAPrepare json => ", jsoncmd); //@ts-ignore - const value = deviceToolKitInstance.toBleCommand(jsoncmd); + const value = deviceToolKitInstance.toBleCommand(jsoncmd as any); sendCommand({ value }); } /** @@ -194,7 +208,7 @@ class UpdateIotWL200 extends Component { }; console.info("OTAUpdating json => ", jsoncmd); //@ts-ignore - const value = deviceToolKitInstance.toBleCommand(jsoncmd); + const value = deviceToolKitInstance.toBleCommand(jsoncmd as any); sendCommand({ value }); } /** @@ -208,7 +222,7 @@ class UpdateIotWL200 extends Component { clearInterval(this.$checkTimer); log.info("ota成功日志, 清除计时器"); //@ts-ignore - const value = deviceToolKitInstance.toBleCommand(jsoncmd); + const value = deviceToolKitInstance.toBleCommand(jsoncmd as any); sendCommand({ value }).then((res) => { this.resetOta(); }); @@ -231,7 +245,7 @@ class UpdateIotWL200 extends Component { commandType: "OTAQuit", }; //@ts-ignore - const value = deviceToolKitInstance.toBleCommand(jsoncmd); + const value = deviceToolKitInstance.toBleCommand(jsoncmd as any); sendCommand({ value }) .then((res) => { this.resetOta(); @@ -357,7 +371,7 @@ class UpdateIotWL200 extends Component { Taro.onBLECharacteristicValueChange((value) => { // let str = ab2hex(value.value); //转为16进制字符串 // console.log('返回',str) - const jsonStatus = deviceToolKitInstance.toJsonStatus(value.value); + const jsonStatus: any = deviceToolKitInstance.toJsonStatus(value.value); log.info("OTA页面设备响应数据打印==》", JSON.stringify(jsonStatus)); console.info("onBLECharacteristicValueChange json => ", jsonStatus); this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo; @@ -376,7 +390,7 @@ class UpdateIotWL200 extends Component { this.$checkTimer = setInterval(() => { // 超过7s没有回包, 直接断开 if (this.$otaDataGroup.countDown <= 0 && this.state.hadStartOta) { - if (this.state.currentDevice.model == InstrumentTypeEnum.M01) { + if (!this.isWL200()) { this.quitOTA("shutDownMaskTip"); } else { this.quitOTA("updateTimeOut"); @@ -412,6 +426,7 @@ class UpdateIotWL200 extends Component { render() { let { isShow } = this.props; + let { progressbar } = this.state; return ( @@ -437,11 +452,11 @@ class UpdateIotWL200 extends Component { - {0.01 * 100}% + {progressbar}% 注意事项: 1.保持设备开机状态 diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 6c0b876..fb5322e 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -25,10 +25,12 @@ import PopupBinding from "@/components/popup/popup-binding"; import PopupSiteSwiper from "@/components/popup/popup-site-swiper"; import PopupAlert from "@/components/popup/popup-alert"; +import PopupConfirm from "@/components/popup/popup-confirm"; import type CustomTabBar from "@/custom-tab-bar"; import Navbar from "@/components/navbar/navbar"; import ConnectionBluetoot from "@/components/bluetoot/connection"; +import UpdateIotWL200 from "@/components/bluetoot/update-wl200/index"; /** 自定义组件 **/ import { @@ -134,6 +136,10 @@ class Index extends Component { connectInstrument: {}, yiqiinfo: {}, /* END */ + + // 设备升级弹窗 + isShowUpdateVersionTip: false, // 升级提示 + isShowVersionUpgrading: false, // 升级中 }; } @@ -650,96 +656,7 @@ class Index extends Component { versionInfo, }); let offlinelist: any = []; - offlineDataList.map((item, index) => { - let obj: any = { - clock_day: "", - status: 3, - second: 120, - screne_id: "", - screne_name: "离线打卡", - model_face_ward: 0, - model_face_use: 0, - model_face_type: "", - model_eye_ward: 0, - model_eye_use: 0, - model_eye_type: "", - instrument_id: this.state.connectInstrument.id, - }; - - //判断日期是否正常,如果不正常不处理 --- 脸部 - if ( - item.faceyear > 0 && - item.faceyear <= 99 && - item.facemonth >= 1 && - item.facemonth <= 12 && - item.faceday >= 1 && - item.faceday <= 31 - ) { - if ( - item.facehour > 0 || - (item.faceminutes > 0 && item.faceminutes < 60) || - (item.faceseconds > 0 && item.faceseconds < 60) - ) { - //脸部离线记录有值 - obj.model_face_use = - Number(item.facehour) * 60 * 60 + - Number(item.faceminutes) * 60 + - Number(item.faceseconds); - obj.model_face_ward = item.faceposition1; - obj.clock_day = `20${String(item.faceyear).padStart(2, "0")}-${String( - item.facemonth - ).padStart(2, "0")}-${String(item.faceday).padStart(2, "0")}`; - } - } - //判断日期是否正常,如果不正常不处理 --- 眼部 - if ( - item.eyeyear > 0 && - item.eyeyear <= 99 && - item.eyemonth >= 1 && - item.eyemonth <= 12 && - item.eyeday >= 1 && - item.eyeday <= 31 - ) { - if ( - item.eyehour > 0 || - (item.eyeminutes > 0 && item.eyeminutes < 60) || - (item.eyeseconds > 0 && item.eyeseconds < 60) - ) { - //眼部离线记录有值 - obj.model_eye_use = - Number(item.eyehour) * 60 * 60 + - Number(item.eyeminutes) * 60 + - Number(item.eyeseconds); - obj.model_eye_ward = item.eyeposition1; - obj.clock_day = `20${String(item.eyeyear).padStart(2, "0")}-${String( - item.eyemonth - ).padStart(2, "0")}-${String(item.eyeday).padStart(2, "0")}`; - } - } - obj.second = obj.model_face_use + obj.model_eye_use; - - if ( - item.faceyear > 0 && - item.faceyear <= 99 && - (item.facemonth == 1 || item.facemonth <= 12) && - (item.faceday == 1 || item.faceday <= 31) - ) { - let dayTime = new Date(`${obj.clock_day.replace(/-/g, "/")}`).getTime(); //离线记录的日期 - let now = new Date( - `${new Date().getFullYear()}/${String( - new Date().getMonth() + 1 - ).padStart(2, "0")}/${String(new Date().getDate()).padStart(2, "0")}` - ).getTime(); //当前日期 - /** - * 过滤7天前的离线记录 - * - */ - if (dayTime <= now && dayTime >= now - 24 * 60 * 60 * 1000 * 6) { - offlinelist.push(obj); - } - } - }); console.log(offlinelist); }; @@ -752,8 +669,25 @@ class Index extends Component { connectionConfirm = async () => { this.connectionClose(); }; - /*蓝牙 END*/ + + /** iot版本升级 */ + // 是否更新弹窗 + upgradeFun = () => { + this.setState({ isShowUpdateVersionTip: true, isConnectShow: false }); + }; + cancelUpdateVersionTip = () => { + this.setState({ isShowUpdateVersionTip: false }); + }; + confirmUpdateVersionTip = () => { + // 开始升级 + this.setState({ + isShowUpdateVersionTip: false, + isShowVersionUpgrading: true, + }); + }; + /** iot版本升级 END */ + render() { let { calendarComplete, @@ -777,6 +711,10 @@ class Index extends Component { instrumentInfo, instrumentList, + // 升级弹窗 + isShowUpdateVersionTip, + isShowVersionUpgrading, + // 蓝牙连接 isConnectShow, connectInstrument, @@ -785,6 +723,26 @@ class Index extends Component { return ( + {isShowVersionUpgrading && ( + + )} + + 检测到设备有升级请求 + 是否进行升级? + + } + textAlgin="center" + cancelButtonText="取消" + confirmButtonText="确定" + close={this.cancelUpdateVersionTip} + confirm={this.confirmUpdateVersionTip} + /> { confirm={this.connectionConfirm} offlineChange={this.offlineChange} pairingChange={this.pairingChange} + upgradeFun={this.upgradeFun} /> )} {/* */} diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index b7b6d82..249ec5d 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -584,6 +584,8 @@ class IotCarePlan extends Component { // }); } }; + + // 蓝牙特征更改 notifyBLECharacteristicValueChange = () => { console.log("notifyBLECharacteristicValueChange deviceInfo 参数为=>"); const bluetoothInfo = this.props.bluetoothInfo;