|
|
|
|
@ -11,13 +11,23 @@ import {
|
|
|
|
|
SwiperItem,
|
|
|
|
|
} from "@tarojs/components";
|
|
|
|
|
|
|
|
|
|
/* 自定义组件 */
|
|
|
|
|
/** 自定义组件 **/
|
|
|
|
|
import PopupAlert from "@/components/popup/popup-alert";
|
|
|
|
|
import PopupConfirm from "@/components/popup/popup-confirm";
|
|
|
|
|
import Navbar from "@/components/navbar/navbar";
|
|
|
|
|
// import PopupAlert from "../../components/popup/popup-alert";
|
|
|
|
|
/* 组件 */
|
|
|
|
|
|
|
|
|
|
import ConnectionBluetoot from "@/components/bluetoot/connection";
|
|
|
|
|
import UpdateIotWL200 from "@/components/bluetoot/update-wl200/index";
|
|
|
|
|
/** 自定义组件 **/
|
|
|
|
|
|
|
|
|
|
import { InstrumentInfo } from "@/utils/Interface";
|
|
|
|
|
import { setStorageSync, getStorageSync, go, back } from "@/utils/traoAPI";
|
|
|
|
|
import {
|
|
|
|
|
setStorageSync,
|
|
|
|
|
getStorageSync,
|
|
|
|
|
go,
|
|
|
|
|
back,
|
|
|
|
|
showModal,
|
|
|
|
|
} from "@/utils/traoAPI";
|
|
|
|
|
|
|
|
|
|
import "./intro.less";
|
|
|
|
|
|
|
|
|
|
@ -29,6 +39,23 @@ class Intro extends Component<any, any> {
|
|
|
|
|
current: 0,
|
|
|
|
|
instrument: {},
|
|
|
|
|
introList: [],
|
|
|
|
|
|
|
|
|
|
isCommonError: false, // 是否显示通用错误提示
|
|
|
|
|
commonErrorText: [], // 通用错误提示
|
|
|
|
|
|
|
|
|
|
/** 蓝牙相关 */
|
|
|
|
|
isConnectShow: false,
|
|
|
|
|
connectInstrument: {}, // 当前连接设备
|
|
|
|
|
/* END */
|
|
|
|
|
|
|
|
|
|
// 设备升级弹窗
|
|
|
|
|
isShowUpdateVersionTip: false, // 升级提示
|
|
|
|
|
isShowVersionUpgrading: false, // 升级中
|
|
|
|
|
isShowVersionUpgradFinish: false, // 升级完成:升级内容公告
|
|
|
|
|
versionUpgradFinishNodes: "", // 公告内容
|
|
|
|
|
|
|
|
|
|
// 设备是否重连弹窗
|
|
|
|
|
isShowReConnectDeviceRecordWL200: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
$instance = Taro.getCurrentInstance();
|
|
|
|
|
@ -100,16 +127,292 @@ class Intro extends Component<any, any> {
|
|
|
|
|
back();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 跳转仪器介绍页
|
|
|
|
|
goNursing = (item) => {
|
|
|
|
|
if (item.status === 0) {
|
|
|
|
|
setStorageSync("instrument_detail", item);
|
|
|
|
|
this.setState({ connectInstrument: item });
|
|
|
|
|
setTimeout(() => this.bindBlockLeft());
|
|
|
|
|
} else {
|
|
|
|
|
// todo
|
|
|
|
|
this.openCommonError([
|
|
|
|
|
"该仪器暂时无法进行在线护理,",
|
|
|
|
|
"请联系微信小助理",
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
/**
|
|
|
|
|
* @name 打开公共提示弹窗
|
|
|
|
|
* @description 仅适用于仅提示文字的弹窗
|
|
|
|
|
* @params 传入字符类型数组,不同下标会自动换行
|
|
|
|
|
*/
|
|
|
|
|
openCommonError = (text) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
commonErrorText: text,
|
|
|
|
|
isCommonError: true,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
onCommonErrorFun = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isCommonError: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 蓝牙逻辑 */
|
|
|
|
|
bindBlockLeft() {
|
|
|
|
|
if (!this.state.isRegisterBoolean) {
|
|
|
|
|
//未注册授权
|
|
|
|
|
this.alertRegister();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.state.connectInstrument.type === 1) {
|
|
|
|
|
//非IOT
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
go("/pages/instrumentClickinUpload/index");
|
|
|
|
|
}, 10);
|
|
|
|
|
} else {
|
|
|
|
|
Taro.getSystemInfo({
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log("getSystemInfo", res);
|
|
|
|
|
let { locationEnabled, locationAuthorized, bluetoothEnabled } = res;
|
|
|
|
|
if (!locationEnabled || !locationAuthorized) {
|
|
|
|
|
showModal({
|
|
|
|
|
t2: "您的手机定位授权未开启,请前往手机设置,打开定位访问授权",
|
|
|
|
|
btn2text: "查看指引",
|
|
|
|
|
}).then(() => {
|
|
|
|
|
go("/pages/connection_help/connection_help?type=location");
|
|
|
|
|
});
|
|
|
|
|
} else if (!bluetoothEnabled) {
|
|
|
|
|
showModal({
|
|
|
|
|
t2: "您的手机蓝牙授权未开启,请前往手机设置,打开蓝牙访问授权",
|
|
|
|
|
btn2text: "查看指引",
|
|
|
|
|
}).then(() => {
|
|
|
|
|
go("/pages/connection_help/connection_help?type=bluetoot");
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 打开连接弹窗
|
|
|
|
|
this.connectionOpen();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WE100,WL200配对完成回调
|
|
|
|
|
*/
|
|
|
|
|
pairingChange = (e) => {
|
|
|
|
|
console.log("===epairingChange===》", e);
|
|
|
|
|
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
|
|
|
|
|
|
|
|
|
|
this.connectionClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async goIot() {
|
|
|
|
|
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//连接完成时数据的回调
|
|
|
|
|
offlineChange = async (e) => {
|
|
|
|
|
console.log("offlineChange", e);
|
|
|
|
|
this.pairingChange("offlineChange");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
connectionOpen = async () => {
|
|
|
|
|
this.setState({ isConnectShow: true });
|
|
|
|
|
};
|
|
|
|
|
connectionClose = async () => {
|
|
|
|
|
this.setState({ isConnectShow: false });
|
|
|
|
|
};
|
|
|
|
|
connectionConfirm = async () => {
|
|
|
|
|
this.connectionClose();
|
|
|
|
|
};
|
|
|
|
|
/*蓝牙 END*/
|
|
|
|
|
|
|
|
|
|
/** 设备iot固件版本升级 */
|
|
|
|
|
// 是否更新弹窗
|
|
|
|
|
upgradeFun = () => {
|
|
|
|
|
this.setState({ isShowUpdateVersionTip: true, isConnectShow: false });
|
|
|
|
|
};
|
|
|
|
|
cancelUpdateVersionTip = () => {
|
|
|
|
|
// 关闭提示
|
|
|
|
|
this.setState({ isShowUpdateVersionTip: false });
|
|
|
|
|
};
|
|
|
|
|
confirmUpdateVersionTip = () => {
|
|
|
|
|
// 提示升级与开始升级
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowUpdateVersionTip: false,
|
|
|
|
|
isShowVersionUpgrading: true,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 完成升级
|
|
|
|
|
wl200UpgradeFinishFun = (isWL200) => {
|
|
|
|
|
let { connectInstrument } = this.state;
|
|
|
|
|
console.log("connectInstrument", connectInstrument);
|
|
|
|
|
let content = "";
|
|
|
|
|
if (isWL200) {
|
|
|
|
|
content = connectInstrument.iotVersionUpgrade;
|
|
|
|
|
} else {
|
|
|
|
|
content = connectInstrument.we200IotVersionUpgrade;
|
|
|
|
|
}
|
|
|
|
|
let nodes = decodeURIComponent(content || "");
|
|
|
|
|
nodes = nodes.replace(/\<img/gi, '<img style="width:100%;height:auto" ');
|
|
|
|
|
nodes = nodes.replace(
|
|
|
|
|
/\<table/gi,
|
|
|
|
|
'<table style="border-spacing: 0;border-collapse: collapse;border: 1px solid #000" '
|
|
|
|
|
);
|
|
|
|
|
nodes = nodes.replace(
|
|
|
|
|
/\<td/gi,
|
|
|
|
|
'<td style="border: 1px solid #000;text-align:center" '
|
|
|
|
|
);
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowVersionUpgrading: false,
|
|
|
|
|
isShowVersionUpgradFinish: true, // 升级介绍
|
|
|
|
|
versionUpgradFinishNodes: nodes,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 升级失败
|
|
|
|
|
wl200UpgradeErrorFun = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowVersionUpgrading: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 关闭升级完成公告
|
|
|
|
|
onVersionUpgradFinish = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowVersionUpgradFinish: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
/** iot版本升级 END */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @name 初始化WL200设备护理历史
|
|
|
|
|
* @description 如果存在护理历史,则提示是否连接设备,重新读取
|
|
|
|
|
*/
|
|
|
|
|
initDeviceNursingHistory = async () => {
|
|
|
|
|
let WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
|
|
|
|
|
if (WL200NursingHistory) {
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowReConnectDeviceRecordWL200: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
closeReConnectDeviceRecordWL200 = () => {
|
|
|
|
|
Taro.removeStorageSync("WL200NursingHistory");
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowReConnectDeviceRecordWL200: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
confirmReConnectDeviceRecordWL200 = () => {
|
|
|
|
|
let WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
|
|
|
|
|
console.log("WL200NursingHistory", WL200NursingHistory);
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowReConnectDeviceRecordWL200: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// this.goNursing()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
let { current, introList, instrument } = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
<Navbar
|
|
|
|
|
titleSlot="仪器绑定"
|
|
|
|
|
titleSlot="仪器介绍"
|
|
|
|
|
isBack
|
|
|
|
|
isCustomBack
|
|
|
|
|
customBack={this.customBack}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<View catchMove>
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isShow={isCommonError}
|
|
|
|
|
title="提示"
|
|
|
|
|
content={
|
|
|
|
|
<Block>
|
|
|
|
|
{commonErrorText.map((item) => {
|
|
|
|
|
return <View>{item}</View>;
|
|
|
|
|
})}
|
|
|
|
|
</Block>
|
|
|
|
|
}
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
close={this.onCommonErrorFun}
|
|
|
|
|
confirm={this.onCommonErrorFun}
|
|
|
|
|
/>
|
|
|
|
|
<PopupConfirm
|
|
|
|
|
isShow={isShowReConnectDeviceRecordWL200}
|
|
|
|
|
isClose
|
|
|
|
|
title="提示"
|
|
|
|
|
zIndex={10020}
|
|
|
|
|
myClassName="level-up"
|
|
|
|
|
content={
|
|
|
|
|
<Block>
|
|
|
|
|
<View>检测到您上一次护理的记录未生成,</View>
|
|
|
|
|
<View>是否重新读取</View>
|
|
|
|
|
</Block>
|
|
|
|
|
}
|
|
|
|
|
cancelButtonText="暂不绑定"
|
|
|
|
|
confirmButtonText="确认"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
close={this.closeReConnectDeviceRecordWL200}
|
|
|
|
|
confirm={this.confirmReConnectDeviceRecordWL200}
|
|
|
|
|
/>
|
|
|
|
|
{/* IOT相关弹窗 */}
|
|
|
|
|
{isConnectShow && (
|
|
|
|
|
<ConnectionBluetoot
|
|
|
|
|
deviceInfo={connectInstrument}
|
|
|
|
|
close={this.connectionClose}
|
|
|
|
|
confirm={this.connectionConfirm}
|
|
|
|
|
offlineChange={this.offlineChange}
|
|
|
|
|
pairingChange={this.pairingChange}
|
|
|
|
|
upgradeFun={this.upgradeFun}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isLarge
|
|
|
|
|
isClose
|
|
|
|
|
isShow={isShowUpdateVersionTip}
|
|
|
|
|
title="提示"
|
|
|
|
|
content={
|
|
|
|
|
<Block>
|
|
|
|
|
<View>检测到设备有升级请求</View>
|
|
|
|
|
<View>是否进行升级?</View>
|
|
|
|
|
</Block>
|
|
|
|
|
}
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
confirmButtonText="确定"
|
|
|
|
|
close={this.cancelUpdateVersionTip}
|
|
|
|
|
confirm={this.confirmUpdateVersionTip}
|
|
|
|
|
/>
|
|
|
|
|
{isShowVersionUpgrading && (
|
|
|
|
|
<UpdateIotWL200
|
|
|
|
|
isShow={isShowVersionUpgrading}
|
|
|
|
|
finishFun={this.wl200UpgradeFinishFun}
|
|
|
|
|
errorFun={this.wl200UpgradeErrorFun}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isShow={isShowVersionUpgradFinish}
|
|
|
|
|
title="升级内容公告"
|
|
|
|
|
content={
|
|
|
|
|
<Block>
|
|
|
|
|
<View className="nodes">
|
|
|
|
|
<RichText nodes={versionUpgradFinishNodes} />
|
|
|
|
|
</View>
|
|
|
|
|
</Block>
|
|
|
|
|
}
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="left"
|
|
|
|
|
isClose
|
|
|
|
|
close={this.onVersionUpgradFinish}
|
|
|
|
|
confirm={this.onVersionUpgradFinish}
|
|
|
|
|
/>
|
|
|
|
|
{/* IOT相关弹窗 END */}
|
|
|
|
|
</View>
|
|
|
|
|
<View style="position: relative">
|
|
|
|
|
<Swiper
|
|
|
|
|
className="main"
|
|
|
|
|
|