fix:兼容WE100/WE200逻辑

master
blak-kong 2 years ago
parent 075021a38e
commit 49d63dc8eb

@ -124,7 +124,7 @@ class ConnectionBluetoot extends Component<any, any> {
"12CAA", // 面罩前缀名
],
currentDeviceType: "WE200", // 现在的设备类型: WE200 WL200
currentDeviceType: "", // 现在的设备类型: WE200 WL200
};
}
@ -195,18 +195,19 @@ class ConnectionBluetoot extends Component<any, any> {
}
/** 重新连接 */
// 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<any, any> {
];
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<any, any> {
}
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<any, any> {
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<any, any> {
// 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗
this.props.upgradeFun();
} else {
console.log("不需要升级,跳转进入仪器详情页");
// 不需要升级,跳转进入仪器详情页
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
this.pairingChange(this.state);
@ -639,9 +661,15 @@ class ConnectionBluetoot extends Component<any, any> {
// 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<any, any> {
};
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() {

@ -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;
}

@ -82,7 +82,6 @@ export default class DeviceConnectPopup extends Component<any, any> {
data,
// connectionStatus,
isConnection,
connectionSuccess,
currentDeviceType,
error,
} = this.props;
@ -121,48 +120,57 @@ export default class DeviceConnectPopup extends Component<any, any> {
/>
)}
{currentDeviceType === "WE200" && (
<Block>
<View>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
</View>
</Block>
)}
<View className="block">
{currentDeviceType === "WL200" && isConnection ? (
<View className="blue-device-tips">
{currentDeviceType === "WE200" && (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip">
{data.bluetoothConnectingContent}
<View className="block">
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
</View>
</View>
</Block>
) : (
)}
{currentDeviceType !== "WE200" && (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
{isConnection ? (
<Block>
<View className="block">
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip">
{data.bluetoothConnectingContent}
</View>
</View>
</Block>
) : (
<Block>
<View className="block">
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
</View>
</Block>
)}
</Block>
)}
</View>

@ -260,10 +260,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
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 () => {

@ -59,7 +59,6 @@ export default class Recording extends Component<any, any> {
clockImageList: [],
clockContent: "",
},
clockContent: "",
};
}
@ -111,8 +110,7 @@ export default class Recording extends Component<any, any> {
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<any, any> {
}
}
// 文本框输入文字
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<any, any> {
punchInInfo,
clockContent,
} = this.state;
return (
<Block>
<Navbar isBack titleSlot="护理记录"></Navbar>
@ -664,11 +660,11 @@ export default class Recording extends Component<any, any> {
placeholder="请记录一下今天的护理心得吧"
maxlength={120}
onInput={this.handleTextareaInput.bind(this)}
value={clockContent}
value={punchInInfo.clockContent}
></Textarea>
</View>
<View className="tip">
{"" + (clockContent.length || 0) + "/120"}
{"" + (punchInInfo.clockContent.length || 0) + "/120"}
</View>
</View>
<View className="popbtnbox flex aitems jcenter">

Loading…
Cancel
Save