diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index a4dad64..6c29123 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -764,15 +764,6 @@ class Index extends Component { // return; } - // 扫码绑定必须先完成注册弹窗:确定以后删除扫码缓存,防止死循环 - onUnloginConfirm() { - this.setState({ showEquipment: false }); - this.removeScanFun(); - } - onUnloginClose() { - this.setState({ showEquipment: false }); - this.removeScanFun(); - } //连接完成时数据的回调 offlineChange = async (e) => { console.log("offlineChange", e); @@ -876,6 +867,16 @@ class Index extends Component { // this.goNursing() }; + // 扫码绑定必须先完成注册弹窗:确定以后删除扫码缓存,防止死循环 + onUnloginConfirm() { + this.setState({ showEquipment: false }); + this.removeScanFun(); + } + onUnloginClose() { + this.setState({ showEquipment: false }); + this.removeScanFun(); + } + /** * @name 打开公共提示弹窗 * @description 仅适用于仅提示文字的弹窗 diff --git a/src/pages/instrument/intro.tsx b/src/pages/instrument/intro.tsx index eeb6721..e8b0d37 100644 --- a/src/pages/instrument/intro.tsx +++ b/src/pages/instrument/intro.tsx @@ -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 { 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 { 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(/\ { + 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 ( + + + + {commonErrorText.map((item) => { + return {item}; + })} + + } + confirmButtonText="知道了" + textAlgin="center" + close={this.onCommonErrorFun} + confirm={this.onCommonErrorFun} + /> + + 检测到您上一次护理的记录未生成, + 是否重新读取 + + } + cancelButtonText="暂不绑定" + confirmButtonText="确认" + textAlgin="center" + close={this.closeReConnectDeviceRecordWL200} + confirm={this.confirmReConnectDeviceRecordWL200} + /> + {/* IOT相关弹窗 */} + {isConnectShow && ( + + )} + + 检测到设备有升级请求 + 是否进行升级? + + } + textAlgin="center" + confirmButtonText="确定" + close={this.cancelUpdateVersionTip} + confirm={this.confirmUpdateVersionTip} + /> + {isShowVersionUpgrading && ( + + )} + + + + + + } + confirmButtonText="知道了" + textAlgin="left" + isClose + close={this.onVersionUpgradFinish} + confirm={this.onVersionUpgradFinish} + /> + {/* IOT相关弹窗 END */} + { }); if (res.data.code === 200) { // 仅在有数据的时候执行 - if (res.data.length) { + if (res.data.length > 0) { let isTipShow = getStorageSync( "first_instrument_" + instrumentDetail.id ); if (!isTipShow) { // 首次进入页面:自动打开打卡介绍弹窗 this.setState({ nurseInfo: res.data.data, isTipShow: true }); + // 已打开初次护理 + setStorageSync( + "first_instrument_" + this.state.instrumentDetail.id, + true + ); } else { this.setState({ nurseInfo: res.data.data }); } @@ -276,10 +281,6 @@ export default class InstrumentClickInUpload extends Component { } }; onTipShowClose = async () => { - setStorageSync( - "first_instrument_" + this.state.instrumentDetail.id, - "true" - ); this.setState({ isTipShow: false }); }; diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index 7863373..02edd67 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -42,7 +42,7 @@ import ModeContent from "./components/ModeContent/index"; import Footer from "./components/Footer"; /* 本页组件 END */ -import { go, getStorageSync, setStorageSync } from "@/utils/traoAPI"; +import { go, getStorageSync, setStorageSync, msg } from "@/utils/traoAPI"; import { InstrumentInfo } from "@/utils/Interface"; import "./iotCarePlan.less"; @@ -149,7 +149,6 @@ class IotCarePlan extends Component { showVideoPlayBtn: true, // 视频播放按钮 duration: 0, // 视频总时长 hadShowBreakTips: false, // 是否展示过支架断开提示 - popupType: "", // enoughTimePopup: 时间达标提示, endPopup: 结束弹窗 isConnectShow: false, // 是否弹出连蓝牙弹窗:在蓝牙断开时弹出 /** 连接设备 End */ @@ -417,8 +416,9 @@ class IotCarePlan extends Component { // 护理检查改变模式,是否提示切换护理模式 // isNotCheck为真时,不进行校验,直接切换 this.tempModeCurrent = data; - this.footerIsDisabled(); + // 如果按钮不可点击则报错,内部自带检查底部按钮函数 + this.onEmitErrorTips(); if (!isNotCheck) { let isReturn = this.modeRuningChange(); if (isReturn) return; @@ -566,12 +566,16 @@ class IotCarePlan extends Component { onEmitErrorTips = async () => { let { ActiveModeItem } = this.state; - if (ActiveModeItem.isCabinMode === 0) { - this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - } else { - this.showTips( - "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - ); + // 按钮不可点击时,提示报错 + let isDisabled = this.footerIsDisabled(); + if (isDisabled) { + if (ActiveModeItem.isCabinMode === 0) { + this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); + } else { + this.showTips( + "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" + ); + } } }; @@ -601,10 +605,12 @@ class IotCarePlan extends Component { let isFirstEntryModeNot = getStorageSync( "isFirstEntryMode_" + this.state.currentDevice.id ); - console.log("isFirstEntryModeNot", isFirstEntryModeNot); - // 如果没有持久化不再提示,每次进入都会弹窗提示 + // 1.如果没有持久化不再提示,每次进入都会弹窗提示 if (!isFirstEntryModeNot) { - this.setState({ isShowStepTips: true }); + // 2.必须要有数据才弹窗 + if (this.state.ActiveModeItem.openSourceData) { + this.setState({ isShowStepTips: true }); + } } }; closeStepTips = (data) => { @@ -1870,9 +1876,6 @@ class IotCarePlan extends Component { } } - console.log("isStandStatus", isStandStatus); - console.log("isFooterBtnDisabled", isFooterBtnDisabled); - console.log("isCanClick", isCanClick); this.setState({ isFooterBtnDisabled: isFooterBtnDisabled, });