blak-kong 2 years ago
parent 8d3e804844
commit 625d36d025

@ -12,7 +12,7 @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN
#### 安装教程
1. 电脑需要安装 node16.18.0 以上版本
1. 电脑需要安装 node ,开发版本为 16.18.0
2. 下载项目依赖

@ -116,14 +116,15 @@ class ConnectionBluetoot extends Component<any, any> {
offlineDataList: [], //离线数据
prefix: "12CAA", // WL200蓝牙搜索前缀
// WL200匹配
tranType: [
"WE100", // 发箍
"WE200", // 发箍
"WL200", // 发箍
"WL200", // 面罩
"12CAA", // 面罩前缀名
],
currentDeviceType: "WE200", // 现在的设备类型: WE200 WL200
};
}
@ -450,6 +451,7 @@ class ConnectionBluetoot extends Component<any, any> {
if (deviceInfo.model == "WL200") {
if (this.isWL200()) {
this.setState({ currentDeviceType: "WL200" });
jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(
value.value
);
@ -458,6 +460,7 @@ class ConnectionBluetoot extends Component<any, any> {
bleCommandSamples.querySubDevice as any
);
} else {
this.setState({ currentDeviceType: "WE200" });
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer =
deviceToolKitInstanceM01.toBleCommand(
@ -465,6 +468,7 @@ class ConnectionBluetoot extends Component<any, any> {
);
}
} else if (deviceInfo.model == "M01") {
this.setState({ currentDeviceType: "M01" });
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.querySubDevice as any
@ -505,6 +509,7 @@ class ConnectionBluetoot extends Component<any, any> {
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();
@ -1022,7 +1027,8 @@ class ConnectionBluetoot extends Component<any, any> {
};
render() {
let { isConnection, connectionSuccess, error } = this.state;
let { isConnection, connectionSuccess, error, currentDeviceType } =
this.state;
let { deviceInfo, isDisconnect } = this.props;
return (
<Block>
@ -1032,6 +1038,7 @@ class ConnectionBluetoot extends Component<any, any> {
reconnect={this.onReconnect}
data={deviceInfo}
isShow={true}
currentDeviceType={currentDeviceType}
connectionSuccess={connectionSuccess}
isConnection={isConnection}
error={error}

@ -83,6 +83,7 @@ export default class DeviceConnectPopup extends Component<any, any> {
// connectionStatus,
isConnection,
connectionSuccess,
currentDeviceType,
error,
} = this.props;
@ -120,22 +121,9 @@ export default class DeviceConnectPopup extends Component<any, any> {
/>
)}
<View className="block">
{isConnection ? (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip">
{data.bluetoothConnectingContent}
</View>
</Block>
) : (
<Block>
{currentDeviceType === "WE200" && (
<Block>
<View>
<View className="icon">
<Image
className="images"
@ -146,11 +134,11 @@ export default class DeviceConnectPopup extends Component<any, any> {
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
</Block>
)}
</View>
{/* <View className="block2">
{connectionSuccess ? (
</View>
</Block>
)}
<View className="block">
{currentDeviceType === "WL200" && isConnection ? (
<Block>
<View className="icon">
<Image
@ -159,7 +147,9 @@ export default class DeviceConnectPopup extends Component<any, any> {
mode="aspectFill"
/>
</View>
<View className="tip"></View>
<View className="tip">
{data.bluetoothConnectingContent}
</View>
</Block>
) : (
<Block>
@ -171,11 +161,11 @@ export default class DeviceConnectPopup extends Component<any, any> {
/>
</View>
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
</Block>
)}
</View> */}
</View>
</View>
<View className="common-popup-btns">
<Button

@ -35,7 +35,6 @@ import {
// 通过设备类型判断给 deviceToolKitInstance 赋值
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
import InstrumentTypeEnum from "../InstrumentTypeEnum";
import OtaDeviceTypeEnum from "../OtaDeviceTypeEnum";
// 临时替代
@ -79,10 +78,17 @@ class UpdateIotWL200 extends Component<any, any> {
countDown: 7,
};
async onLoad() {}
async onLoad() {
if (this.$checkTimer) clearInterval(this.$checkTimer);
}
componentDidMount() {
console.log("componentDidMount");
this.initData();
}
componentDidHide() {
console.log("componentDidHide");
this.errorFun();
}
isWL200() {
let currentDevicesName = getStorageSync("currentDevicesName");
@ -256,9 +262,17 @@ class UpdateIotWL200 extends Component<any, any> {
});
// log.info('ota失败日志', '发送日志OTAQuit失败', err);
console.info("ota失败日志", "发送日志OTAQuit失败", err);
// this.showError(errorMap[errorString] || tipMap[errorString] || '发生错误')
if (err.errCode === 10000) {
let isDisconnect = getStorageSync("isDisconnectUpdate");
if (isDisconnect) {
if (this.$checkTimer) clearInterval(this.$checkTimer);
}
}
}
});
setTimeout(() => {
this.errorFun();
}, 1000);
}
/**
@ -375,8 +389,8 @@ class UpdateIotWL200 extends Component<any, any> {
const jsonStatus: any = deviceToolKitInstance.toJsonStatus(value.value);
log.info("OTA页面设备响应数据打印==》", JSON.stringify(jsonStatus));
console.info("onBLECharacteristicValueChange json => ", jsonStatus);
this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo;
this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo;
this.$otaDataGroup.countDown = 7;
this.parseData(jsonStatus);
});
@ -405,6 +419,7 @@ class UpdateIotWL200 extends Component<any, any> {
//升级销毁页面时关闭小程序蓝牙
onUnload() {
console.log("onUnload");
if (this.$checkTimer) clearInterval(this.$checkTimer);
Taro.closeBluetoothAdapter();
}
@ -419,6 +434,7 @@ class UpdateIotWL200 extends Component<any, any> {
// 错误关闭回调
errorFun = () => {
this.resetOta();
this.props.errorFun();
};
// 升级完成回调

@ -46,11 +46,20 @@ export default class PopupConfirm extends Component<any, any> {
componentDidHide() {}
async initData() {}
// 关闭
onClose = () => {
this.props.close();
};
// 取消
onCancel = () => {
// 旧代码共用了取消和关闭回调,临时适配兼容:有取消用取消,没取消用关闭
if (this.props.cancel) {
this.props.cancel();
} else {
this.onClose();
}
};
// 确认
onConfirm = () => {
this.props.confirm();
};
@ -115,7 +124,7 @@ export default class PopupConfirm extends Component<any, any> {
</View>
</View>
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}>
<Button className="common-popup-btn2" onClick={this.onCancel}>
{cancelButtonText}
</Button>
<Button className="common-popup-btn2" onClick={this.onConfirm}>

@ -156,6 +156,7 @@ export default class PopupSiteSwiper extends Component<any, any> {
className="cover"
src={item.fileUrl}
mode="aspectFit"
lazyLoad
></Image>
</View>
</SwiperItem>

@ -1,5 +1,10 @@
.step-popup-content-box {
margin: 0;
.absolutely-img {
width: 100%;
height: 600rpx;
background-color: #eee;
}
}
.step-absolutely {
width: 600rpx;
@ -13,9 +18,7 @@
height: 600rpx;
border-radius: 30rpx;
}
// .van-popup {
// background-color: transparent;
// }
.site-close {
position: absolute;
right: 16rpx;

@ -151,16 +151,12 @@ export default class PopupStepTips extends Component<any, any> {
return (
current === index && (
<View className="absolutely" key={"swiper_" + index}>
<View
style={{
width: "100%",
height: "600rpx",
}}
>
<View className="absolutely-img">
<Image
className="cover"
src={item.openSourceUrl}
mode="aspectFit"
lazyLoad
></Image>
</View>
<View className="tips-message">{item.openContent}</View>

@ -70,7 +70,12 @@ export default class Index extends Component {
// }
console.log("url", url);
this.setSelected(index);
Taro.switchTab({ url: "/" + url });
if (url === "pages/index/index") {
Taro.reLaunch({ url: "/" + url });
} else {
Taro.switchTab({ url: "/" + url });
}
}
setSelected(idx: number) {

@ -183,7 +183,11 @@ class Index extends Component<any, any> {
}
}
componentDidHide() {}
componentDidHide() {
this.wl200UpgradeErrorFun();
Taro.closeBluetoothAdapter();
setStorageSync("isDisconnectUpdate", true); // 已断开更新
}
showInit = async () => {
// 判断是否登录
@ -557,20 +561,21 @@ class Index extends Component<any, any> {
}
// 0已绑定 1未绑定 2已解绑
if (instrumentInfo.bindingStatus === 0) {
setTimeout(() => {
this.isBindingSerial();
}, 100);
let isBind = this.state.instrumentList.find(
(item) => item.id === instrumentInfo.id
);
if (isBind) {
// 选择仪器有误
this.setState({
isBeforeBindingError: true,
BeforeBindingErrorText: "序列号已被其他用户绑定",
BeforeBindingErrorText: "序列号已绑定",
});
} else {
// 选择仪器有误
this.setState({
isBeforeBindingError: true,
BeforeBindingErrorText: "序列号已绑定",
BeforeBindingErrorText: "序列号已被其他用户绑定",
});
}
@ -638,9 +643,11 @@ class Index extends Component<any, any> {
if (obj) {
setStorageSync("instrument_detail", obj);
}
setTimeout(() => {
go("/pages/instrument/intro??customBack=true&id=" + instrumentInfo.id);
}, 2000);
// 绑定成功后,先查询设备介绍页,有数据则跳转,没数据则刷新已绑定数据
this.getInstrumentIntroInfo(instrumentInfo.id);
}, 1000);
return;
} else if (data.code === 202) {
// 换绑操作
@ -653,6 +660,21 @@ class Index extends Component<any, any> {
}
};
/** 获取设备介绍页信息 */
getInstrumentIntroInfo = async (id) => {
let res = await InstrumentInfo.instructionInfo({
instrumentId: id,
});
if (res.data.code === 200) {
console.log("res.data.data", res.data.data);
if (res.data.data.length > 0) {
go("/pages/instrument/intro??customBack=true&id=" + id);
} else {
this.bindingInstrumentList();
}
}
};
// 换绑仪器
exchangeBinding = async () => {
Taro.showLoading({
@ -700,7 +722,6 @@ class Index extends Component<any, any> {
this.setState({ connectInstrument: item });
setTimeout(() => this.bindBlockLeft());
} else {
// todo
this.openCommonError([
"该仪器暂时无法进行在线护理,",
"请联系微信小助理",
@ -796,6 +817,7 @@ class Index extends Component<any, any> {
isShowUpdateVersionTip: false,
isShowVersionUpgrading: true,
});
Taro.removeStorageSync("isDisconnectUpdate");
};
// 完成升级
@ -829,6 +851,7 @@ class Index extends Component<any, any> {
this.setState({
isShowVersionUpgrading: false,
});
msg("升级失败");
};
// 关闭升级完成公告
onVersionUpgradFinish = () => {

@ -37,6 +37,7 @@ export default class Instrument extends Component<any, any> {
this.state = {
name: "instrument",
isBindingError: false,
isBindingError203: false,
isBindingCheckError: false,
style: "font-size: 28rpx; color: #ccc;",
succeedShow: false,
@ -373,6 +374,13 @@ export default class Instrument extends Component<any, any> {
this.onBindErrorClose();
go("/pages/consultant/consultant");
};
onBindErrorClose203 = () => {
this.setState({ isBindingError203: false });
};
onBindErrorConfirm203 = () => {
this.onBindErrorClose203();
go("/pages/consultant/consultant");
};
onBindCheckErrorClose = () => {
this.setState({ isBindingCheckError: false });
@ -404,6 +412,7 @@ export default class Instrument extends Component<any, any> {
render() {
let {
isBindingError,
isBindingError203,
isBindingCheckError,
channelInfo,
inputType,
@ -451,6 +460,15 @@ export default class Instrument extends Component<any, any> {
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
></PopupAlert>
<PopupAlert
isShow={isBindingError203}
title="提示"
content="序列码已被别人绑定,请联系微信助手"
confirmButtonText="知道了"
textAlgin="center"
close={this.onBindErrorClose203}
confirm={this.onBindErrorConfirm203}
></PopupAlert>
<PopupAlert
isShow={isBindingCheckError}
title="提示"

@ -9,6 +9,7 @@ import {
Video,
Swiper,
SwiperItem,
RichText,
} from "@tarojs/components";
/** 自定义组件 **/
@ -99,18 +100,6 @@ class Intro extends Component<any, any> {
}
};
/** 跳转至打卡页或护理页 */
toNursing = () => {
const { instrument } = this.state;
console.log("instrument", instrument);
if (instrument.type === 1) {
go("/pages/instrumentClickinUpload/index");
} else {
go("/pages/iotCarePlan/iotCarePlan");
}
};
toHomePage = () => {
const url = "/pages/index/index";
Taro.switchTab({
@ -128,10 +117,10 @@ class Intro extends Component<any, any> {
};
// 跳转仪器介绍页
goNursing = (item) => {
if (item.status === 0) {
setStorageSync("instrument_detail", item);
this.setState({ connectInstrument: item });
goNursing = () => {
let { instrument } = this.state;
if (instrument.status === 0) {
this.setState({ connectInstrument: instrument });
setTimeout(() => this.bindBlockLeft());
} else {
// todo
@ -160,11 +149,6 @@ class Intro extends Component<any, any> {
/** 蓝牙逻辑 */
bindBlockLeft() {
if (!this.state.isRegisterBoolean) {
//未注册授权
this.alertRegister();
return false;
}
if (this.state.connectInstrument.type === 1) {
//非IOT
setTimeout(() => {
@ -205,12 +189,16 @@ class Intro extends Component<any, any> {
console.log("===epairingChange===》", e);
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
this.connectionClose();
setTimeout(() => {
this.connectionClose();
}, 100);
};
async goIot() {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
// return;
setTimeout(() => {
this.connectionClose();
}, 100);
}
//连接完成时数据的回调
@ -312,12 +300,23 @@ class Intro extends Component<any, any> {
this.setState({
isShowReConnectDeviceRecordWL200: false,
});
// this.goNursing()
};
render() {
let { current, introList, instrument } = this.state;
let {
current,
introList,
instrument,
isCommonError,
commonErrorText,
isShowReConnectDeviceRecordWL200,
isConnectShow,
connectInstrument,
isShowUpdateVersionTip,
isShowVersionUpgrading,
isShowVersionUpgradFinish,
versionUpgradFinishNodes,
} = this.state;
return (
<Block>
<Navbar
@ -464,7 +463,7 @@ class Intro extends Component<any, any> {
</View>
<View className="footer flex aitems jcenter">
<View className="btn" onClick={this.toNursing}>
<View className="btn" onClick={this.goNursing}>
</View>
<View className="btn text" onClick={this.toHomePage}>

@ -174,12 +174,7 @@ export default class InstrumentManage extends Component<any, any> {
></Image>
<View className="bind_status"></View>
<View className="intro">
<View
className="tips"
onClick={this.goIntro.bind(this, item)}
>
</View>
<View className="tips"></View>
<View className="right">
<Image
src={require("../../img/index/right.png")}

@ -1,6 +1,7 @@
import Taro from "@tarojs/taro";
import dayjs from "dayjs";
import classnames from "classnames";
import { debounce } from "lodash";
// eslint-disable-next-line import/no-named-as-default
import React, {
Component,
@ -457,9 +458,12 @@ class IotCarePlan extends Component<any, any> {
// 如果是正在运行中切换,则直接准备运行
if (isShowNurse) {
this.onStartNurse();
if (!this.footerIsDisabled()) {
this.stepNext(); // 如果切换模式,则不执行开始逻辑
return;
}
setTimeout(() => {
this.onNursingTap();
this.onNursingTap("switch");
}, 800);
}
};
@ -608,7 +612,7 @@ class IotCarePlan extends Component<any, any> {
// 1.如果没有持久化不再提示,每次进入都会弹窗提示
if (!isFirstEntryModeNot) {
// 2.必须要有数据才弹窗
if (this.state.ActiveModeItem.openSourceData) {
if (this.state.ActiveModeItem.openSourceData.length > 0) {
this.setState({ isShowStepTips: true });
}
}
@ -777,13 +781,14 @@ class IotCarePlan extends Component<any, any> {
// 判断设备主动上报的关机事件
if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) {
this.rmWL200NursingHistory(this.WL200NursingHistory, true);
// 判断护理时间,如果不足,则提示不足
if (!this.isCheckNurseTime()) {
this.setState({ isNotEnoughTime: true });
} else {
this.endNurseFun();
// 判断id是否一致, 一致的话则生成护理报表, 并提示
if (jsonStatus.id == this.WL200NursingHistory.id) {
debounce(
this.checkInstrumentRecord.bind(this, jsonStatus),
500
);
}
return;
}
@ -917,6 +922,17 @@ class IotCarePlan extends Component<any, any> {
});
};
/**监听关机事件*/
onEndDevice = () => {
this.rmWL200NursingHistory(this.WL200NursingHistory, true);
// 判断护理时间,如果不足,则提示不足
if (!this.isCheckNurseTime()) {
this.setState({ isNotEnoughTime: true });
} else {
this.endNurseFun();
}
};
/** 同步设备运行信息:运行时间 */
updateDeviceSyncData = (newData, jsonStatus) => {
DeviceSyncData = {
@ -1260,9 +1276,10 @@ class IotCarePlan extends Component<any, any> {
};
/**
*
* @name
* @params type switch
*/
onNursingTap() {
onNursingTap(type = "") {
// 如果已禁止运行,则停止执行后续逻辑
if (this.state.isFooterBtnDisabled) return;
// 防止多次点击
@ -1321,9 +1338,11 @@ class IotCarePlan extends Component<any, any> {
return;
}
let downNum = CountDownTime[ActiveModeItem.modeType] || 3;
console.log("downNum", downNum);
this.showCountdownFun(downNum, () => {}); // 倒计时弹窗
// 仅在切换模式的时候,弹窗倒计时.
if (type === "switch") {
let downNum = CountDownTime[ActiveModeItem.modeType] || 3;
this.showCountdownFun(downNum, () => {}); // 倒计时弹窗
}
// 开始执行护理
this.workStatus = MODE_WORKING_ENUM.WORKING; // 不管当前什么状态,直接设为工作状态
@ -1398,6 +1417,7 @@ class IotCarePlan extends Component<any, any> {
*
* */
checkInstrumentRecord = async (jsonStatus: any) => {
console.log("检查护理记录");
let { currentDevice, ActiveModeItem, ModeList } = this.state;
if (jsonStatus) {
}
@ -1437,7 +1457,6 @@ class IotCarePlan extends Component<any, any> {
return;
}
let sceneTime = minSecToS(ActiveModeItem.modeTimeStr);
// 4.判断设备状态-未运行/已完成/待机
if (
workStatus == MODE_WORKING_ENUM.STANDBY ||
@ -1458,8 +1477,8 @@ class IotCarePlan extends Component<any, any> {
let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间
if (totalSeconds < nursingTime) {
console.log("护理时间不足,弹出提示");
// todo
// 护理时间不足
this.setState({ isNotEnoughTime: true });
this.rmWL200NursingHistory(WL200NursingHistory);
return;
}
@ -1561,8 +1580,10 @@ class IotCarePlan extends Component<any, any> {
const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
if (nowWL200NursingHistory.id == WL200NursingHistory.id) {
Taro.removeStorageSync("WL200NursingHistory");
this.WL200NursingHistory.id = "";
} else if (hard) {
Taro.removeStorageSync("WL200NursingHistory");
this.WL200NursingHistory.id = "";
}
};
@ -1810,18 +1831,25 @@ class IotCarePlan extends Component<any, any> {
};
// 手动护理模式切换:提示是否保存护理
/**仅关闭*/
closeTipsSave = () => {
this.setState({
isShowTipsSave: false,
});
this.modeCurrentFun(this.tempModeCurrent, true); // 不进行校验
};
/**关闭+切换*/
cancelTipsSave = () => {
this.setState({
isShowTipsSave: false,
});
this.modeCurrentFun(this.tempModeCurrent, true); // 不提交护理记录,也不进行校验
};
/**关闭+提交+切换*/
confirmTipsSave = async () => {
this.setState({
isShowTipsSave: false,
});
// isShowTipsSave
this.PostNursingLogClock(null, false);
this.PostNursingLogClock(null, false); // 先提交护理记录
this.modeCurrentFun(this.tempModeCurrent, true); // 不进行校验
};
@ -1876,9 +1904,13 @@ class IotCarePlan extends Component<any, any> {
}
}
this.setState({
isFooterBtnDisabled: isFooterBtnDisabled,
});
// 仅在值变化时更新state
if (isFooterBtnDisabled !== this.state.isFooterBtnDisabled) {
this.setState({
isFooterBtnDisabled: isFooterBtnDisabled,
});
}
return isFooterBtnDisabled; // 数据更新有延迟,返回用于判断
};
@ -2030,6 +2062,7 @@ class IotCarePlan extends Component<any, any> {
confirmButtonText="确认"
textAlgin="center"
close={this.closeTipsSave}
cancel={this.cancelTipsSave}
confirm={this.confirmTipsSave}
/>
@ -2066,6 +2099,7 @@ class IotCarePlan extends Component<any, any> {
<Video
className="video-or-image"
src={ActiveModeItem.modeVideo}
loop
/>
)}

@ -139,7 +139,12 @@ export const AjaxUploadFile = (params, formData) => {
});
return false;
}
if (o.code !== 200 && o.code !== 204 && o.code !== 205) {
if (
o.code !== 200 &&
o.code !== 203 &&
o.code !== 204 &&
o.code !== 205
) {
let msg =
typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员";
Taro.showModal({

Loading…
Cancel
Save