fix:兼容WE100/WE200逻辑

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

@ -124,7 +124,7 @@ class ConnectionBluetoot extends Component<any, any> {
"12CAA", // 面罩前缀名 "12CAA", // 面罩前缀名
], ],
currentDeviceType: "WE200", // 现在的设备类型: WE200 WL200 currentDeviceType: "", // 现在的设备类型: WE200 WL200
}; };
} }
@ -195,18 +195,19 @@ class ConnectionBluetoot extends Component<any, any> {
} }
/** 重新连接 */ /** 重新连接 */
// againConnection() { againConnection() {
// this.setState({ this.setState({
// connectionStatus: false, hasVersionInfo: false, // 重置已获取版本信息状态
// islian: false, connectionStatus: false,
// error: false, islian: false,
// }); error: false,
// Taro.closeBluetoothAdapter({ });
// complete: () => { Taro.closeBluetoothAdapter({
// this.bluetoothInit(); complete: () => {
// }, this.bluetoothInit();
// }); },
// } });
}
// skip() { // skip() {
// this.setState({ // this.setState({
@ -333,15 +334,18 @@ class ConnectionBluetoot extends Component<any, any> {
]; ];
for (let i = 0; i < item.devices.length; i++) { for (let i = 0; i < item.devices.length; i++) {
let devicesName = item.devices[i].localName || item.devices[i].name; let devicesName = item.devices[i].localName || item.devices[i].name;
console.log("devicesName", devicesName);
console.log("tranType", tranType);
// 是否匹配可连接设备 // 是否匹配可连接设备
let isAvailable = tranType.some( let isAvailable = tranType.some(
(item) => devicesName && devicesName.indexOf(item) > -1 (item) => devicesName && devicesName.indexOf(item) > -1
); );
console.log("isAvailable", isAvailable);
// 判断设备是否可连接 // 判断设备是否可连接
if (item.devices[i].connectable && isAvailable) { if (item.devices[i].connectable && isAvailable) {
// 如果是已连接WE200后再次搜索则只能连接WL200
if (this.state.currentDeviceType === "WE200") {
if (!devicesName.includes("12CAA")) {
return;
}
}
// 缓存当前连接设备名 可能是发箍或面罩 // 缓存当前连接设备名 可能是发箍或面罩
setStorageSync("currentDevicesName", devicesName); setStorageSync("currentDevicesName", devicesName);
console.log("连接的设备信息", item.devices[i], devicesName); console.log("连接的设备信息", item.devices[i], devicesName);
@ -506,6 +510,10 @@ class ConnectionBluetoot extends Component<any, any> {
} }
break; break;
case "BleStatusSync": // 设备连接状态 case "BleStatusSync": // 设备连接状态
console.log(
"设备连接状态jsonStatus.connectMessage",
jsonStatus.connectMessage
);
if (jsonStatus.connectMessage?.connectType == "CONNECTED") { if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
switch (jsonStatus.connectMessage?.deviceName) { switch (jsonStatus.connectMessage?.deviceName) {
case OtaDeviceTypeEnum.WE100: case OtaDeviceTypeEnum.WE100:
@ -531,7 +539,20 @@ class ConnectionBluetoot extends Component<any, any> {
break; break;
} }
} else if (jsonStatus?.commandType === "InfoQuery") { } 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) { switch (jsonStatus.infoQueryType) {
case "versionInfo": case "versionInfo":
if (this.state.hasVersionInfo) return; if (this.state.hasVersionInfo) return;
@ -559,6 +580,7 @@ class ConnectionBluetoot extends Component<any, any> {
// 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗 // 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗
this.props.upgradeFun(); this.props.upgradeFun();
} else { } else {
console.log("不需要升级,跳转进入仪器详情页");
// 不需要升级,跳转进入仪器详情页 // 不需要升级,跳转进入仪器详情页
if (isGetVersionTimer) clearTimeout(isGetVersionTimer); if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
this.pairingChange(this.state); this.pairingChange(this.state);
@ -639,9 +661,15 @@ class ConnectionBluetoot extends Component<any, any> {
// 8.发送指令:获取仪器版本号 // 8.发送指令:获取仪器版本号
sendGetVersion() { sendGetVersion() {
const { deviceInfo } = this.props; const { deviceInfo } = this.props;
const isFRDevice = ["FR200", "FR380", "FR390"].includes(deviceInfo.model); let model = deviceInfo.model;
// log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`); if (model == "WL200") {
console.log(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`); if (!this.isWL200()) {
model = "WE200";
}
}
const isFRDevice = ["FR200", "FR380", "FR390"].includes(model);
console.log(commandMap.sendVersionCommand, `仪器:${model}`);
if (isFRDevice) { if (isFRDevice) {
writeBLECharacteristicValue({ writeBLECharacteristicValue({
//发送获取仪器版本号 //发送获取仪器版本号
@ -1019,11 +1047,19 @@ class ConnectionBluetoot extends Component<any, any> {
}; };
pairingChange = (data) => { pairingChange = (data) => {
this.props.pairingChange(data); console.log("pairingChange");
let { currentDeviceType } = this.state;
if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") {
this.props.pairingChange(data);
}
}; };
offlineChange = (data) => { offlineChange = (data) => {
this.props.offlineChange(data); console.log("offlineChange");
let { currentDeviceType } = this.state;
if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") {
this.props.offlineChange(data);
}
}; };
render() { render() {

@ -66,7 +66,6 @@
position: relative; position: relative;
width: 84%; width: 84%;
box-sizing: border-box; box-sizing: border-box;
display: flex;
// column-gap: 30rpx; // column-gap: 30rpx;
// padding-top: 10px; // padding-top: 10px;
margin: 0 auto 10px; margin: 0 auto 10px;
@ -85,7 +84,7 @@
} }
} }
.block { .block {
margin-top: 80rpx; margin-top: 40rpx;
} }
.block2 { .block2 {
margin-top: 40rpx; margin-top: 40rpx;
@ -121,3 +120,8 @@
.device-popup-btns { .device-popup-btns {
margin-top: 60rpx; margin-top: 60rpx;
} }
.blue-device-tips {
display: flex;
flex-direction: column;
}

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

@ -260,10 +260,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
videoLoadedMetaData = async () => {}; videoLoadedMetaData = async () => {};
handleTextareaInput = async (e) => { handleTextareaInput = async (e) => {
let { punchInInfo } = this.state; this.setState({ punchInInfo: { clockContent: e.detail.value } });
punchInInfo.clockContent = e.detail.value;
this.setState({ punchInInfo });
}; };
onModeLockOpen = async () => { onModeLockOpen = async () => {

@ -59,7 +59,6 @@ export default class Recording extends Component<any, any> {
clockImageList: [], clockImageList: [],
clockContent: "", clockContent: "",
}, },
clockContent: "",
}; };
} }
@ -111,8 +110,7 @@ export default class Recording extends Component<any, any> {
clockImageList: res.data.data.clockImg, clockImageList: res.data.data.clockImg,
clockContent: res.data.data.clockContent, clockContent: res.data.data.clockContent,
}; };
let clockContent = res.data.data.clockContent; this.setState({ punchInInfo });
this.setState({ punchInInfo, clockContent });
} }
} }
} }
@ -173,12 +171,9 @@ export default class Recording extends Component<any, any> {
} }
} }
// 文本框输入文字 // 文本框输入文字
handleTextareaInput(e) { handleTextareaInput = (e) => {
const punchInInfo = this.state.punchInInfo; this.setState({ punchInInfo: { clockContent: e.detail.value } });
punchInInfo.clockContent = e.detail.value; };
let clockContent = e.detail.value;
this.setState({ punchInInfo, clockContent });
}
// 打开/关闭弹窗 // 打开/关闭弹窗
setShow(show: boolean) { setShow(show: boolean) {
this.setState({ show }); this.setState({ show });
@ -335,6 +330,7 @@ export default class Recording extends Component<any, any> {
punchInInfo, punchInInfo,
clockContent, clockContent,
} = this.state; } = this.state;
return ( return (
<Block> <Block>
<Navbar isBack titleSlot="护理记录"></Navbar> <Navbar isBack titleSlot="护理记录"></Navbar>
@ -664,11 +660,11 @@ export default class Recording extends Component<any, any> {
placeholder="请记录一下今天的护理心得吧" placeholder="请记录一下今天的护理心得吧"
maxlength={120} maxlength={120}
onInput={this.handleTextareaInput.bind(this)} onInput={this.handleTextareaInput.bind(this)}
value={clockContent} value={punchInInfo.clockContent}
></Textarea> ></Textarea>
</View> </View>
<View className="tip"> <View className="tip">
{"" + (clockContent.length || 0) + "/120"} {"" + (punchInInfo.clockContent.length || 0) + "/120"}
</View> </View>
</View> </View>
<View className="popbtnbox flex aitems jcenter"> <View className="popbtnbox flex aitems jcenter">

Loading…
Cancel
Save