From 49d63dc8eb44f0725ed115a3ad12938b18fb069a Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 12 Mar 2024 14:12:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=85=BC=E5=AE=B9WE100/WE200=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/bluetoot/connection/index.tsx | 80 ++++++++++++----- .../device-connection-popup.less | 8 +- .../device-connection-popup.tsx | 86 ++++++++++--------- src/pages/instrumentClickinUpload/index.tsx | 5 +- src/pages/recording/recording.tsx | 18 ++-- 5 files changed, 119 insertions(+), 78 deletions(-) diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 3886d13..6281810 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -124,7 +124,7 @@ class ConnectionBluetoot extends Component { "12CAA", // 面罩前缀名 ], - currentDeviceType: "WE200", // 现在的设备类型: WE200 WL200 + currentDeviceType: "", // 现在的设备类型: WE200 WL200 }; } @@ -195,18 +195,19 @@ class ConnectionBluetoot extends Component { } /** 重新连接 */ - // againConnection() { - // this.setState({ - // connectionStatus: false, - // islian: false, - // error: false, - // }); - // Taro.closeBluetoothAdapter({ - // complete: () => { - // this.bluetoothInit(); - // }, - // }); - // } + againConnection() { + this.setState({ + hasVersionInfo: false, // 重置已获取版本信息状态 + connectionStatus: false, + islian: false, + error: false, + }); + Taro.closeBluetoothAdapter({ + complete: () => { + this.bluetoothInit(); + }, + }); + } // skip() { // this.setState({ @@ -333,15 +334,18 @@ class ConnectionBluetoot extends Component { ]; for (let i = 0; i < item.devices.length; i++) { 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) { + // 如果是已连接WE200后,再次搜索,则只能连接WL200 + if (this.state.currentDeviceType === "WE200") { + if (!devicesName.includes("12CAA")) { + return; + } + } // 缓存当前连接设备名 可能是发箍或面罩 setStorageSync("currentDevicesName", devicesName); console.log("连接的设备信息", item.devices[i], devicesName); @@ -506,6 +510,10 @@ class ConnectionBluetoot extends Component { } break; case "BleStatusSync": // 设备连接状态 + console.log( + "设备连接状态jsonStatus.connectMessage", + jsonStatus.connectMessage + ); if (jsonStatus.connectMessage?.connectType == "CONNECTED") { switch (jsonStatus.connectMessage?.deviceName) { case OtaDeviceTypeEnum.WE100: @@ -531,7 +539,20 @@ class ConnectionBluetoot extends Component { break; } } else if (jsonStatus?.commandType === "InfoQuery") { - console.log("查询版本信息", jsonStatus); + console.log("查询版本信息:", jsonStatus); + console.log("当前设备:", jsonStatus.otaDeviceType); + console.log("当前设备版本号:", jsonStatus.versionNo); + + if ( + jsonStatus.otaDeviceType === "WE100" || + jsonStatus.otaDeviceType === "WE200" + ) { + console.log("closeBLEConnection"); + setTimeout(() => { + this.againConnection(); + }, 1000); + } + switch (jsonStatus.infoQueryType) { case "versionInfo": if (this.state.hasVersionInfo) return; @@ -559,6 +580,7 @@ class ConnectionBluetoot extends Component { // 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗 this.props.upgradeFun(); } else { + console.log("不需要升级,跳转进入仪器详情页"); // 不需要升级,跳转进入仪器详情页 if (isGetVersionTimer) clearTimeout(isGetVersionTimer); this.pairingChange(this.state); @@ -639,9 +661,15 @@ class ConnectionBluetoot extends Component { // 8.发送指令:获取仪器版本号 sendGetVersion() { const { deviceInfo } = this.props; - const isFRDevice = ["FR200", "FR380", "FR390"].includes(deviceInfo.model); - // log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`); - console.log(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`); + let model = deviceInfo.model; + if (model == "WL200") { + if (!this.isWL200()) { + model = "WE200"; + } + } + + const isFRDevice = ["FR200", "FR380", "FR390"].includes(model); + console.log(commandMap.sendVersionCommand, `仪器:${model}`); if (isFRDevice) { writeBLECharacteristicValue({ //发送获取仪器版本号 @@ -1019,11 +1047,19 @@ class ConnectionBluetoot extends Component { }; pairingChange = (data) => { - this.props.pairingChange(data); + console.log("pairingChange"); + let { currentDeviceType } = this.state; + if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") { + this.props.pairingChange(data); + } }; offlineChange = (data) => { - this.props.offlineChange(data); + console.log("offlineChange"); + let { currentDeviceType } = this.state; + if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") { + this.props.offlineChange(data); + } }; render() { diff --git a/src/components/bluetoot/device-connection-popup/device-connection-popup.less b/src/components/bluetoot/device-connection-popup/device-connection-popup.less index e36b80e..fdee03f 100644 --- a/src/components/bluetoot/device-connection-popup/device-connection-popup.less +++ b/src/components/bluetoot/device-connection-popup/device-connection-popup.less @@ -66,7 +66,6 @@ position: relative; width: 84%; box-sizing: border-box; - display: flex; // column-gap: 30rpx; // padding-top: 10px; margin: 0 auto 10px; @@ -85,7 +84,7 @@ } } .block { - margin-top: 80rpx; + margin-top: 40rpx; } .block2 { margin-top: 40rpx; @@ -121,3 +120,8 @@ .device-popup-btns { margin-top: 60rpx; } + +.blue-device-tips { + display: flex; + flex-direction: column; +} diff --git a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx index 33face0..88cc794 100644 --- a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx +++ b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx @@ -82,7 +82,6 @@ export default class DeviceConnectPopup extends Component { data, // connectionStatus, isConnection, - connectionSuccess, currentDeviceType, error, } = this.props; @@ -121,48 +120,57 @@ export default class DeviceConnectPopup extends Component { /> )} - {currentDeviceType === "WE200" && ( - - - - - - - {data.bluetoothConnectingContent} - - - - )} - - {currentDeviceType === "WL200" && isConnection ? ( + + {currentDeviceType === "WE200" && ( - - - - - {data.bluetoothConnectingContent} + + + + + + 请打开面罩电源,并保持开机状态 + - ) : ( + )} + + {currentDeviceType !== "WE200" && ( - - - - - {data.bluetoothConnectingContent} - + {isConnection ? ( + + + + + + + {data.bluetoothConnectingContent} + + + + ) : ( + + + + + + + {data.bluetoothConnectingContent} + + + + )} )} diff --git a/src/pages/instrumentClickinUpload/index.tsx b/src/pages/instrumentClickinUpload/index.tsx index e3bdd90..b0dbcde 100644 --- a/src/pages/instrumentClickinUpload/index.tsx +++ b/src/pages/instrumentClickinUpload/index.tsx @@ -260,10 +260,7 @@ export default class InstrumentClickInUpload extends Component { videoLoadedMetaData = async () => {}; handleTextareaInput = async (e) => { - let { punchInInfo } = this.state; - punchInInfo.clockContent = e.detail.value; - - this.setState({ punchInInfo }); + this.setState({ punchInInfo: { clockContent: e.detail.value } }); }; onModeLockOpen = async () => { diff --git a/src/pages/recording/recording.tsx b/src/pages/recording/recording.tsx index 1488878..66f5516 100644 --- a/src/pages/recording/recording.tsx +++ b/src/pages/recording/recording.tsx @@ -59,7 +59,6 @@ export default class Recording extends Component { clockImageList: [], clockContent: "", }, - clockContent: "", }; } @@ -111,8 +110,7 @@ export default class Recording extends Component { clockImageList: res.data.data.clockImg, clockContent: res.data.data.clockContent, }; - let clockContent = res.data.data.clockContent; - this.setState({ punchInInfo, clockContent }); + this.setState({ punchInInfo }); } } } @@ -173,12 +171,9 @@ export default class Recording extends Component { } } // 文本框输入文字 - handleTextareaInput(e) { - const punchInInfo = this.state.punchInInfo; - punchInInfo.clockContent = e.detail.value; - let clockContent = e.detail.value; - this.setState({ punchInInfo, clockContent }); - } + handleTextareaInput = (e) => { + this.setState({ punchInInfo: { clockContent: e.detail.value } }); + }; // 打开/关闭弹窗 setShow(show: boolean) { this.setState({ show }); @@ -335,6 +330,7 @@ export default class Recording extends Component { punchInInfo, clockContent, } = this.state; + return ( @@ -664,11 +660,11 @@ export default class Recording extends Component { placeholder="请记录一下今天的护理心得吧" maxlength={120} onInput={this.handleTextareaInput.bind(this)} - value={clockContent} + value={punchInInfo.clockContent} > - {"(" + (clockContent.length || 0) + "/120)"} + {"(" + (punchInInfo.clockContent.length || 0) + "/120)"}