diff --git a/README.md b/README.md index 1a33144..d31ed73 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN #### 安装教程 -1. 电脑需要安装 node,16.18.0 以上版本 +1. 电脑需要安装 node ,开发版本为 16.18.0 2. 下载项目依赖 diff --git a/src/components/base/nodata.less b/src/components/base/nodata.less new file mode 100644 index 0000000..aa18061 --- /dev/null +++ b/src/components/base/nodata.less @@ -0,0 +1,19 @@ +.nodata { + width: 200rpx; + height: 300rpx; + margin: 0 auto; + // margin-top: 310rpx; + text-align: center; + .nodata_img { + display: inline-block; + width: 160rpx; + height: 160rpx; + margin-bottom: 34rpx; + } + .nodata_text { + font-size: 30rpx; + font-family: PingFang SC; + font-weight: 400; + color: #666666; + } +} diff --git a/src/components/base/nodata.tsx b/src/components/base/nodata.tsx new file mode 100644 index 0000000..0e057b8 --- /dev/null +++ b/src/components/base/nodata.tsx @@ -0,0 +1,45 @@ +import classnames from "classnames"; +import Taro from "@tarojs/taro"; +import { Component } from "react"; + +import { Block, View, Image } from "@tarojs/components"; + +import "./nodata.less"; + +export default class NoDataComponent extends Component { + constructor(props) { + super(props); + this.state = { + name: "无数据组件", + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() {} + + showInit() {} + + render() { + return ( + + + + + 暂无数据 + + + + ); + } +} diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 09eed6b..6281810 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -116,14 +116,15 @@ class ConnectionBluetoot extends Component { offlineDataList: [], //离线数据 prefix: "12CAA", // WL200蓝牙搜索前缀 - // WL200匹配 tranType: [ "WE100", // 发箍 "WE200", // 发箍 - "WL200", // 发箍 + "WL200", // 面罩 "12CAA", // 面罩前缀名 ], + + currentDeviceType: "", // 现在的设备类型: WE200 WL200 }; } @@ -194,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({ @@ -332,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); @@ -450,6 +455,7 @@ class ConnectionBluetoot extends Component { if (deviceInfo.model == "WL200") { if (this.isWL200()) { + this.setState({ currentDeviceType: "WL200" }); jsonStatus = deviceToolKitInstanceWL200.toJsonStatus( value.value ); @@ -458,6 +464,7 @@ class ConnectionBluetoot extends Component { bleCommandSamples.querySubDevice as any ); } else { + this.setState({ currentDeviceType: "WE200" }); jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value); querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand( @@ -465,6 +472,7 @@ class ConnectionBluetoot extends Component { ); } } else if (deviceInfo.model == "M01") { + this.setState({ currentDeviceType: "M01" }); jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value); querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand( bleCommandSamples.querySubDevice as any @@ -502,9 +510,14 @@ 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: + console.log("手环连上了 value => ", jsonStatus); case OtaDeviceTypeEnum.FACIALMASK: console.log("面膜连上了 value => ", jsonStatus); this.detectVersionUpdate(); @@ -526,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; @@ -554,6 +580,7 @@ class ConnectionBluetoot extends Component { // 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗 this.props.upgradeFun(); } else { + console.log("不需要升级,跳转进入仪器详情页"); // 不需要升级,跳转进入仪器详情页 if (isGetVersionTimer) clearTimeout(isGetVersionTimer); this.pairingChange(this.state); @@ -634,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({ //发送获取仪器版本号 @@ -1014,15 +1047,24 @@ 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() { - let { isConnection, connectionSuccess, error } = this.state; + let { isConnection, connectionSuccess, error, currentDeviceType } = + this.state; let { deviceInfo, isDisconnect } = this.props; return ( @@ -1032,6 +1074,7 @@ class ConnectionBluetoot extends Component { reconnect={this.onReconnect} data={deviceInfo} isShow={true} + currentDeviceType={currentDeviceType} connectionSuccess={connectionSuccess} isConnection={isConnection} error={error} 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 0057e32..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,7 @@ export default class DeviceConnectPopup extends Component { data, // connectionStatus, isConnection, - connectionSuccess, + currentDeviceType, error, } = this.props; @@ -120,62 +120,60 @@ export default class DeviceConnectPopup extends Component { /> )} - - {isConnection ? ( + + {currentDeviceType === "WE200" && ( - - - - - {data.bluetoothConnectingContent} - - - ) : ( - - - - - - {data.bluetoothConnectingContent} + + + + + + 请打开面罩电源,并保持开机状态 + )} - - {/* - {connectionSuccess ? ( - - - - - 正在为您启动今日护理场景 - - ) : ( + + {currentDeviceType !== "WE200" && ( - - - - - 正在为您启动今日护理场景 - + {isConnection ? ( + + + + + + + {data.bluetoothConnectingContent} + + + + ) : ( + + + + + + + {data.bluetoothConnectingContent} + + + + )} )} - */} +