Merge branch 'dev' into rwkdev

master
blak-kong 2 years ago
commit 4a7354064e

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

@ -0,0 +1,19 @@
.nodata {
width: 200rpx;
height: 300rpx;
margin: 0 auto;
// margin-top: 310rpx;
text-align: center;
.nodata_img {
display: inline-block;
width: 160rpx;
height: 160rpx;
margin-bottom: 34rpx;
}
.nodata_text {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #666666;
}
}

@ -0,0 +1,45 @@
import classnames from "classnames";
import Taro from "@tarojs/taro";
import { Component } from "react";
import { Block, View, Image } from "@tarojs/components";
import "./nodata.less";
export default class NoDataComponent extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
name: "无数据组件",
};
}
async onLoad() {}
componentDidMount() {}
componentWillUnmount() {}
componentDidShow() {}
componentDidHide() {}
async initData() {}
showInit() {}
render() {
return (
<Block>
<View>
<View className="nodata">
<Image
className="nodata_img"
src={require("../../img/nodata.png")}
></Image>
<View className="nodata_text"></View>
</View>
</View>
</Block>
);
}
}

@ -116,14 +116,15 @@ class ConnectionBluetoot extends Component<any, any> {
offlineDataList: [], //离线数据
prefix: "12CAA", // WL200蓝牙搜索前缀
// WL200匹配
tranType: [
"WE100", // 发箍
"WE200", // 发箍
"WL200", // 发箍
"WL200", // 面罩
"12CAA", // 面罩前缀名
],
currentDeviceType: "", // 现在的设备类型: WE200 WL200
};
}
@ -194,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({
@ -332,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);
@ -450,6 +455,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 +464,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 +472,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
@ -502,9 +510,14 @@ 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:
console.log("手环连上了 value => ", jsonStatus);
case OtaDeviceTypeEnum.FACIALMASK:
console.log("面膜连上了 value => ", jsonStatus);
this.detectVersionUpdate();
@ -526,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;
@ -554,6 +580,7 @@ class ConnectionBluetoot extends Component<any, any> {
// 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗
this.props.upgradeFun();
} else {
console.log("不需要升级,跳转进入仪器详情页");
// 不需要升级,跳转进入仪器详情页
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
this.pairingChange(this.state);
@ -634,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({
//发送获取仪器版本号
@ -1014,15 +1047,24 @@ 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() {
let { isConnection, connectionSuccess, error } = this.state;
let { isConnection, connectionSuccess, error, currentDeviceType } =
this.state;
let { deviceInfo, isDisconnect } = this.props;
return (
<Block>
@ -1032,6 +1074,7 @@ class ConnectionBluetoot extends Component<any, any> {
reconnect={this.onReconnect}
data={deviceInfo}
isShow={true}
currentDeviceType={currentDeviceType}
connectionSuccess={connectionSuccess}
isConnection={isConnection}
error={error}

@ -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,7 @@ export default class DeviceConnectPopup extends Component<any, any> {
data,
// connectionStatus,
isConnection,
connectionSuccess,
currentDeviceType,
error,
} = this.props;
@ -120,62 +120,60 @@ export default class DeviceConnectPopup extends Component<any, any> {
/>
)}
<View className="block">
{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>
</Block>
) : (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
{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>
)}
</View>
{/* <View className="block2">
{connectionSuccess ? (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip"></View>
</Block>
) : (
{currentDeviceType !== "WE200" && (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
</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> */}
</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");
@ -104,10 +110,8 @@ class UpdateIotWL200 extends Component<any, any> {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let info = JSON.parse(objStr);
this.setState({
currentDevice: info,
currentDevice: objStr,
});
}
setTimeout(() => {
@ -258,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);
}
/**
@ -377,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);
});
@ -407,6 +419,7 @@ class UpdateIotWL200 extends Component<any, any> {
//升级销毁页面时关闭小程序蓝牙
onUnload() {
console.log("onUnload");
if (this.$checkTimer) clearInterval(this.$checkTimer);
Taro.closeBluetoothAdapter();
}
@ -421,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}>

@ -85,10 +85,6 @@ export default class PopupPrivacy extends Component<any, any> {
handleAgreePrivacyAuthorization = (event) => {
// Taro.setStorageSync("isPrivacyPopup", "true");
this.props.closePrivacy(); // 通知父组件关闭
let isScan = Taro.getStorageSync("isScan");
if (isScan) {
go("/pages/register/register");
}
};
onClickStop = (e) => {

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

@ -68,8 +68,14 @@ export default class Index extends Component {
// this.setSelected(index);
// Taro.switchTab({ url: "/" + url });
// }
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) {

@ -41,7 +41,7 @@ export default class Consultant extends Component<any, any> {
customBack = () => {
let customBack = this.$instance.router?.params?.customBack;
if (customBack) {
Taro.switchTab({ url: "/pages/index/index" });
Taro.reLaunch({ url: "/pages/index/index" });
return;
}
back();

@ -75,9 +75,7 @@ class Entry extends Component<any, any> {
let detail = JSON.parse(MpSplashDetail_type1);
let list = detail.filter((item: any) => item.fileSuffix === "images");
if (list.length === 0) {
Taro.switchTab({
url: "/pages/index/index",
});
Taro.reLaunch({ url: "/pages/index/index" });
return;
}
let welcomeList = list.map((item) => {
@ -89,9 +87,7 @@ class Entry extends Component<any, any> {
});
this.setState({ welcomeList });
} else {
Taro.switchTab({
url: "/pages/index/index",
});
Taro.reLaunch({ url: "/pages/index/index" });
}
}
@ -118,12 +114,7 @@ class Entry extends Component<any, any> {
}
}
toHomePage() {
// Taro.switchTab({
// url: "/pages/index/index",
// });
Taro.switchTab({
url: "/pages/index/index",
});
Taro.reLaunch({ url: "/pages/index/index" });
}
onFinish(event) {

@ -59,11 +59,15 @@ import {
// const log = require("@/utils/log");
class Index extends Component<any, any> {
$instance = Taro.getCurrentInstance();
$instance: any = Taro.getCurrentInstance();
constructor(props) {
super(props);
this.state = {
isDisabledClickAddDevice: false, // 是否禁止点击添加设备
isCommonError: false, // 是否显示通用错误提示
commonErrorText: [], // 通用错误提示
showEquipment: false, // 扫码绑定设备弹窗
isRegisterBoolean: false, // 是否已登录
isShowPrivacyPopup: false,
@ -100,8 +104,11 @@ class Index extends Component<any, any> {
/** 绑定仪器 */
isVisibleBinding: false, // 绑定弹窗
isBindingError: false, // 绑定失败
isBeforeBinding: false, // 已绑定弹窗
isBeforeBindingError: false, // 绑定前校验错误弹窗
BeforeBindingErrorText: "", // 绑定前校验错误文本
instrumentList: [], // 仪器列表
unbindingInstrumentList: [], // 未绑定仪器列表
instrumentInfo: {
// 扫码获得的序列号仪器
bindingStatus: 0, // 0已绑定1未绑定2已解绑
@ -138,6 +145,9 @@ class Index extends Component<any, any> {
isShowVersionUpgrading: false, // 升级中
isShowVersionUpgradFinish: false, // 升级完成:升级内容公告
versionUpgradFinishNodes: "", // 公告内容
// 设备是否重连弹窗
isShowReConnectDeviceRecordWL200: false,
};
}
@ -149,44 +159,68 @@ class Index extends Component<any, any> {
go("/pages/initiate/initiate");
}
}
// 判断是否跳过了注册
if (Taro.getStorageSync("skipRegister")) {
this.setState({ showEquipment: true });
Taro.removeStorageSync("skipRegister");
}
}
componentDidMount() {}
componentWillUnmount() {}
componentWillUnmount() {
// 页面卸载监听
Taro.offAppHide((res) => {});
this.$instance = null;
}
componentDidShow() {
const tabbar = Taro.getTabBar<CustomTabBar>(this.$instance.page);
tabbar?.setSelected(0);
this.showInit();
// 判断是否跳过了注册
if (Taro.getStorageSync("skipRegister")) {
this.setState({ showEquipment: true });
Taro.removeStorageSync("skipRegister");
} else {
// 已注册且非跳过,正常执行逻辑
this.showInit();
}
}
componentDidHide() {
this.closeUpgradeBox();
}
componentDidHide() {}
/**
*
*
* */
closeUpgradeBox() {
if (this.state.isShowVersionUpgrading) {
this.wl200UpgradeErrorFun();
Taro.closeBluetoothAdapter();
setStorageSync("isDisconnectUpdate", true); // 已断开更新
}
}
showInit() {
showInit = async () => {
// 判断是否登录
this.$instance = Taro.getCurrentInstance();
let mobile = Taro.getStorageSync("mobile");
if (mobile) {
this.setState({ isRegisterBoolean: true });
}
// 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,先缓存序列号,再检测隐私弹窗
let serial = Taro.getStorageSync("serial");
let url = this.$instance.router?.params?.q || "";
if (!url) {
// 非扫码进入
Taro.setStorageSync("isScan", false);
// 非扫码或扫码已跳转的返回进入
const isFirst = Taro.getStorageSync("isWelcome");
if (isFirst) {
if (isFirst || serial) {
// 如果是扫码进来的,不需要进入介绍页也弹鉴权弹窗
this.checkShowPrivacyPopup();
}
} else {
// 扫码进入
Taro.setStorageSync("isScan", true);
// 是否可以运行扫码逻辑:每次扫码后设为真,
Taro.setStorageSync("isScanRun", true);
if (url) {
let _url = decodeURIComponent(url);
if (_url.indexOf("?")) {
@ -194,15 +228,12 @@ class Index extends Component<any, any> {
if (ids.length > 1) {
let serial = ids[1];
Taro.setStorageSync("serial", serial);
if (!Taro.getStorageSync("mobile")) {
go("/pages/register/register");
}
}
}
}
this.checkShowPrivacyPopup();
}
}
};
// 检测是否弹出隐私协议
checkShowPrivacyPopup() {
@ -213,7 +244,6 @@ class Index extends Component<any, any> {
this.setState({ isShowPrivacyPopup: true });
} else {
// 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口
// this.initData();
this.isSancQrcodeEnter();
}
},
@ -236,13 +266,30 @@ class Index extends Component<any, any> {
}
}
async initPageData() {
initPageData = async () => {
const mobile = Taro.getStorageSync("mobile");
this.GetSiteCarousel();
const isToken = getStorageSync("token");
if (!isToken) {
// 防止逻辑出错没有token
await this.onlyLogin();
}
console.log("initPageData");
// 如果是扫码且已有token则跳转
if (Taro.getStorageSync("serial")) {
// 如果已注册绑定手机号不用跳转
if (!mobile) {
setTimeout(() => {
go("/pages/register/register");
}, 300);
return;
}
}
this.GetSiteCarousel();
if (mobile) {
this.GetNoReadMessageNum(); // 查询是否有消息
await this.bindingInstrumentList(); // 获取已绑定设备
await this.unbindingInstrumentInfoList(); // 获取未绑定设备
await this.getInstrumentInfoBySerial(); // 扫码序列号查询:注册后才调用,因为扫码未注册直接跳转注册页
if (!this.props.isShowIndexFlag) {
@ -256,7 +303,7 @@ class Index extends Component<any, any> {
});
}
}
}
};
// 刷新用户信息
RefreshWxUserInfo = async () => {
@ -314,7 +361,10 @@ class Index extends Component<any, any> {
// 新增设备
addNewDevice = () => {
if (this.isRegister("addNewDevice")) {
// todo
if (this.state.isDisabledClickAddDevice) {
msg("您已绑定所有设备");
return;
}
go("/pages/instrument/instrument");
}
};
@ -339,7 +389,7 @@ class Index extends Component<any, any> {
closePrivacy = () => {
this.setState({ isShowPrivacyPopup: false });
this.initData();
this.isSancQrcodeEnter(); // 关闭隐私弹窗后,需要判断是否扫码进入
};
closeAlert = () => {
@ -394,6 +444,28 @@ class Index extends Component<any, any> {
}
/* 仪器与是否扫码进入逻辑 */
isVideo = (str) => {
if (str.includes(".mp4")) {
return true;
}
return false;
};
// 未绑定列表
unbindingInstrumentInfoList = async () => {
let { data } = await InstrumentInfo.unbindingInstrumentInfoList();
if (data.code === 200) {
if (data.data.length === 0) {
this.setState({
isDisabledClickAddDevice: true,
});
} else {
this.setState({
unbindingInstrumentList: data.data,
});
}
}
};
// 获取已绑定仪器列表
bindingInstrumentList = async () => {
Taro.showLoading({
@ -419,7 +491,7 @@ class Index extends Component<any, any> {
this.initData();
}
};
async WCUserLogin() {
WCUserLogin = async () => {
Taro.showLoading({
title: "请求中...",
mask: true,
@ -433,6 +505,7 @@ class Index extends Component<any, any> {
Taro.setStorageSync("mobile", data.data.mobile);
this.props.tokenRefresh(data.data);
// 如果是扫码进入,直接跳转到注册登录页.
setTimeout(() => {
this.initPageData();
}, 300);
@ -442,7 +515,27 @@ class Index extends Component<any, any> {
this.WCUserLogin();
}, 2000);
}
}
};
// 只登陆,不做其他操作
onlyLogin = async () => {
Taro.showLoading({
title: "请求中...",
mask: true,
});
const { code } = await Taro.login();
const { data } = await WCUserLogin({ code });
Taro.hideLoading();
if (data.code === 200) {
Taro.setStorageSync("isWelcome", true);
Taro.setStorageSync("mobile", data.data.mobile);
this.props.tokenRefresh(data.data);
} else {
msg("请求失败,尝试重新请求");
}
};
closeBinding = () => {
this.setState({ isVisibleBinding: false });
};
@ -478,10 +571,24 @@ class Index extends Component<any, any> {
}
// 0已绑定 1未绑定 2已解绑
if (instrumentInfo.bindingStatus === 0) {
// 选择仪器有误
this.setState({
isBeforeBinding: true,
});
setTimeout(() => {
this.isBindingSerial();
}, 100);
let isBind = this.state.instrumentList.find(
(item) => item.id === instrumentInfo.id
);
if (isBind) {
this.setState({
isBeforeBindingError: true,
BeforeBindingErrorText: "序列号已绑定",
});
} else {
this.setState({
isBeforeBindingError: true,
BeforeBindingErrorText: "序列号已被其他用户绑定",
});
}
return;
} else if (
instrumentInfo.bindingStatus === 1 ||
@ -500,8 +607,7 @@ class Index extends Component<any, any> {
this.setState({ isBindingError: true });
}
Taro.removeStorageSync("isScan"); // 扫码弹窗显示完后,不需要再判断是否扫码
Taro.removeStorageSync("serial"); // 扫码弹窗显示完后,删除缓存的扫码序列号
this.removeScanFun();
}
};
@ -531,17 +637,27 @@ class Index extends Component<any, any> {
title: "请求中...",
mask: true,
});
let { instrumentInfo } = this.state;
let { instrumentInfo, unbindingInstrumentList } = this.state;
let { data } = await InstrumentInfo.binding({
serial: instrumentInfo.serial,
});
Taro.hideLoading();
this.closeBinding();
this.removeScanFun();
if (data.code === 200) {
msg("绑定成功");
let obj = unbindingInstrumentList.find(
(item) => item.id === instrumentInfo.id
);
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) {
// 换绑操作
@ -554,6 +670,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({
@ -574,24 +705,38 @@ class Index extends Component<any, any> {
// 仪器绑定失败弹窗
onBindErrorClose = () => {
this.setState({ isBindingError: false });
this.removeScanFun();
};
onBindErrorConfirm = () => {
this.onBindErrorClose();
go("/pages/consultant/consultant?customBack=true");
};
onBeforeBindClose = () => {
this.setState({ isBeforeBinding: false });
this.setState({ isBeforeBindingError: false });
this.removeScanFun();
};
onBeforeBindConfirm = () => {
this.setState({ isBeforeBinding: false });
this.setState({ isBeforeBindingError: false });
this.removeScanFun();
};
/**删除扫码缓存*/
removeScanFun = () => {
Taro.removeStorageSync("isScan"); // 扫码弹窗显示完后,不需要再判断是否扫码
Taro.removeStorageSync("serial"); // 扫码弹窗显示完后,删除缓存的扫码序列号
};
// 跳转仪器介绍页
goNursing = (item) => {
console.log("goNursing", item);
setStorageSync("instrument_detail", JSON.stringify(item));
this.setState({ connectInstrument: item });
setTimeout(() => this.bindBlockLeft());
if (item.status === 0) {
setStorageSync("instrument_detail", item);
this.setState({ connectInstrument: item });
setTimeout(() => this.bindBlockLeft());
} else {
this.openCommonError([
"该仪器暂时无法进行在线护理,",
"请联系微信小助理",
]);
}
};
/* 扫码进入逻辑 */
@ -649,12 +794,7 @@ class Index extends Component<any, any> {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
// return;
}
onUnloginConfirm() {
this.setState({ showEquipment: false });
}
onUnloginClose() {
this.setState({ showEquipment: false });
}
//连接完成时数据的回调
offlineChange = async (e) => {
console.log("offlineChange", e);
@ -687,6 +827,7 @@ class Index extends Component<any, any> {
isShowUpdateVersionTip: false,
isShowVersionUpgrading: true,
});
Taro.removeStorageSync("isDisconnectUpdate");
};
// 完成升级
@ -720,6 +861,7 @@ class Index extends Component<any, any> {
this.setState({
isShowVersionUpgrading: false,
});
msg("升级失败");
};
// 关闭升级完成公告
onVersionUpgradFinish = () => {
@ -729,8 +871,65 @@ class Index extends Component<any, any> {
};
/** 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()
};
// 扫码绑定必须先完成注册弹窗:确定以后删除扫码缓存,防止死循环
onUnloginConfirm() {
this.setState({ showEquipment: false });
this.removeScanFun();
}
onUnloginClose() {
this.setState({ showEquipment: false });
this.removeScanFun();
}
/**
* @name
* @description
* @params
*/
openCommonError = (text) => {
this.setState({
commonErrorText: text,
isCommonError: true,
});
};
onCommonErrorFun = () => {
this.setState({
isCommonError: false,
});
};
render() {
let {
isCommonError,
commonErrorText,
calendarComplete,
calendarInComplete,
currentDate,
@ -746,13 +945,13 @@ class Index extends Component<any, any> {
// 绑定弹窗
isVisibleBinding,
isBindingError,
isBeforeBinding,
isBeforeBindingError,
BeforeBindingErrorText,
isRegisterBoolean,
isExchangeBinding,
instrumentInfo,
instrumentList,
showEquipment,
bindEquipment,
// 升级弹窗
isShowUpdateVersionTip,
@ -763,30 +962,46 @@ class Index extends Component<any, any> {
// 蓝牙连接
isConnectShow,
connectInstrument,
// 设备存在记录,是否重连
isShowReConnectDeviceRecordWL200,
} = this.state;
return (
<Block>
<View catchMove>
{/* <PopupConfirm
isShow={isShowBindConfirm}
isClose
zIndex={10020}
myClassName="level-up"
title="提示"
content={
<Block>
<View>{}</View>
<View>{}</View>
<View>{}</View>
</Block>
}
cancelButtonText="暂不绑定"
confirmButtonText="确认"
textAlgin="center"
close={this.closeBindConfirm}
confirm={this.confirmBindConfirm}
/> */}
<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}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
@ -798,7 +1013,6 @@ class Index extends Component<any, any> {
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
/>
@ -847,17 +1061,17 @@ class Index extends Component<any, any> {
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
/>
<PopupAlert
isShow={isBeforeBinding}
isShow={isBeforeBindingError}
title="提示"
content="您选择的仪器有误,请重新确认选择"
content={
BeforeBindingErrorText || "您选择的仪器有误,请重新确认选择"
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBeforeBindClose}
confirm={this.onBeforeBindConfirm}
/>
@ -876,16 +1090,10 @@ class Index extends Component<any, any> {
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onUnloginClose.bind(this)}
confirm={this.onUnloginConfirm.bind(this)}
></PopupAlert>
{/* <PopupPrivacyTest
closePrivacy={this.closePrivacy.bind(this)}
initData={this.initData.bind(this)}
></PopupPrivacyTest> */}
<PopupSiteSwiper
isShow={isShowSiteSwiper}
siteData={sitePopupList}
@ -1009,24 +1217,22 @@ class Index extends Component<any, any> {
<View style="overflow-x: auto;">
<View className="device_list flex">
{instrumentList.map((item, index) => {
if (item.status === 0) {
return (
<View
key={"instrumentList" + index}
className="device_item"
onClick={this.goNursing.bind(this, item)}
>
<Image
className="banner_img"
src={item.banner}
mode="aspectFill"
/>
<View className="device_name ellipsis1">
{item.name}
</View>
return (
<View
key={"instrumentList" + index}
className="device_item"
onClick={this.goNursing.bind(this, item)}
>
<Image
className="banner_img"
src={item.banner}
mode="aspectFill"
/>
<View className="device_name ellipsis1">
{item.name}
</View>
);
}
</View>
);
})}
</View>
</View>

@ -127,7 +127,10 @@ class Initiate extends Component<any, any> {
}, 300);
} else {
msg("请求失败,尝试重新请求");
this.WCUserLogin();
// 防止快速请求
setTimeout(() => {
this.WCUserLogin();
}, 2000);
}
}

@ -18,7 +18,7 @@ import {
} from "@tarojs/components";
import { InstrumentInfo } from "@/utils/Interface";
import { go, msg, setStorageSync, getStorageSync } from "@/utils/traoAPI";
import { go, msg, setStorageSync } from "@/utils/traoAPI";
import { getImgInfo, contraction } from "@/utils/compressImage";
@ -26,6 +26,7 @@ import { getImgInfo, contraction } from "@/utils/compressImage";
import Navbar from "@/components/navbar/navbar";
import PopupAlert from "@/components/popup/popup-alert";
import PopupBinding from "@/components/popup/popup-binding";
import NoDataComponent from "@/components/base/nodata";
/* 组件 */
import "./instrument.less";
@ -36,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,
@ -66,6 +68,8 @@ export default class Instrument extends Component<any, any> {
isVisibleBinding: false,
isRegisterBoolean: false,
isExchangeBinding: false,
/** INPUT序列号拎出来防止上传图片被清空bug */
};
}
$instance = Taro.getCurrentInstance();
@ -73,12 +77,21 @@ export default class Instrument extends Component<any, any> {
currentDevice: any = null;
id: any = "";
async onLoad() {}
async onLoad() {
this.unbindingInstrumentInfoList();
}
componentDidMount() {}
componentWillUnmount() {}
componentDidShow() {
// 进入页面判断是否注册,用于扫码登录
let mobile = Taro.getStorageSync("mobile");
if (mobile) {
this.setState({ isRegisterBoolean: true });
}
// 用于判断是否只显示一个设备
let params: any = this.$instance.router?.params;
if (params?.isOnly && params?.id) {
if (params?.isOnly === "true") {
@ -87,7 +100,7 @@ export default class Instrument extends Component<any, any> {
}
}
console.log("params", params);
this.unbindingInstrumentInfoList();
console.log("channelInfo", this.state.channelInfo);
}
componentDidHide() {}
@ -98,7 +111,6 @@ export default class Instrument extends Component<any, any> {
const { value } = event.detail;
let { channelInfo } = this.state;
channelInfo.serialCode = value;
this.setState({ channelInfo });
};
@ -157,7 +169,7 @@ export default class Instrument extends Component<any, any> {
});
};
onChangeImg = async () => {
async onChangeImg() {
Taro.chooseMedia({
count: 1,
mediaType: ["image"],
@ -165,20 +177,31 @@ export default class Instrument extends Component<any, any> {
sizeType: ["compressed"],
camera: "back",
success: async (res) => {
console.log("success", res);
const tempFilePath = res.tempFiles[0].tempFilePath;
let img = await getImgInfo(tempFilePath);
console.log("img", img);
let compressImage = await contraction(img, "compressImage");
console.log("compressImage", compressImage);
// 压缩后文件地址
let compressTempFilePath = compressImage.tempFilePath;
let { channelInfo } = this.state;
channelInfo.serialImage = compressTempFilePath;
this.setState({ channelInfo });
console.log("tempFilePath", tempFilePath);
console.log("compressTempFilePath", compressTempFilePath);
setTimeout(() => {
let { channelInfo } = this.state;
channelInfo.serialImage = compressTempFilePath;
this.setState({ channelInfo });
});
},
fail: async (fail) => {
console.log("fail", fail);
},
});
};
}
onSubmit = () => {
const { serialCode, serialImage, id } = this.state.channelInfo;
const { serialImage, serialCode } = this.state.channelInfo;
if (!serialCode?.trim()) return msg("请填写序列号");
if (!serialImage) return msg("请上传序列号照片");
this.manualCodeBinding();
@ -192,15 +215,12 @@ export default class Instrument extends Component<any, any> {
channelInfo.scanCodeBinding = "";
this.setState({
channelInfo: channelInfo,
channelInfo: {
...channelInfo,
...item,
},
isVideo: this.isVideo(item.banner),
});
setTimeout(() => {
this.setState({
channelInfo: item,
});
}, 10);
}
closeDev = () => {
@ -226,27 +246,37 @@ export default class Instrument extends Component<any, any> {
if (data.code === 200) {
if (data.data.length) {
if (!this.isOnly) {
let item = data.data[0];
let equipmentList = data.data.filter((item) => item.status === 0);
if (equipmentList.length === 0) {
return;
}
let item = equipmentList[0];
item.serialCode = "";
this.setState({
equipmentList: data.data,
equipmentList: equipmentList,
channelInfo: item,
isVideo: this.isVideo(item.banner),
});
} else {
let item = data.data.find((item) => String(item.id) === this.id);
item.serialCode = "";
this.setState({
equipmentList: [item],
channelInfo: item,
isVideo: this.isVideo(item.banner),
});
if (item) {
item.serialCode = "";
this.setState({
equipmentList: [item],
channelInfo: item,
isVideo: this.isVideo(item.banner),
});
}
}
}
}
};
// 绑定仪器
/**
* @name
* @return code===204
*/
manualCodeBinding = async () => {
Taro.showLoading({
title: "请求中...",
@ -259,16 +289,22 @@ export default class Instrument extends Component<any, any> {
serialImage: channelInfo.serialImage,
instrumentId: channelInfo.id,
});
console.log("bindingInstrument", res);
Taro.hideLoading();
if (res.code === 200) {
// 文件上传接口返回格式不需要加data
console.log("res.data", res);
let code = Number(res.code); // 强制类型转换
if (code === 200) {
this.openBindingVisible();
} else if (res.code === 204) {
this.setState({ isBindingCheckError: false });
} else if (code === 204) {
this.setState({ isBindingCheckError: true });
} else {
this.setState({ isBindingError: true });
}
};
/**
* @name
* @return code===204
*/
scanCodeBinding = async () => {
Taro.showLoading({
title: "请求中...",
@ -283,7 +319,7 @@ export default class Instrument extends Component<any, any> {
if (res.data.code === 200) {
// this.bindingInstrument();
this.openBindingVisible();
} else if (res.data.code === 204) {
} else if (res.data.code === 204 || res.data.code === 205) {
this.setState({ isBindingCheckError: true });
} else {
this.setState({ isBindingError: true });
@ -326,8 +362,8 @@ export default class Instrument extends Component<any, any> {
console.log("exchangeBinding", data);
Taro.hideLoading();
this.closeBinding();
if (data.code !== 200) {
//todo
if (data.code === 200) {
msg("换绑成功");
}
};
@ -338,13 +374,20 @@ 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 });
};
customBack = () => {
Taro.switchTab({ url: "/pages/index/index" });
Taro.reLaunch({ url: "/pages/index/index" });
};
// 打开绑定弹窗
@ -369,6 +412,7 @@ export default class Instrument extends Component<any, any> {
render() {
let {
isBindingError,
isBindingError203,
isBindingCheckError,
channelInfo,
inputType,
@ -397,37 +441,46 @@ export default class Instrument extends Component<any, any> {
customBack={this.customBack}
/>
<PopupBinding
type={channelInfo.bindingStatus}
isShow={isVisibleBinding}
isRegisterBoolean={isRegisterBoolean}
isExchangeBinding={isExchangeBinding}
data={channelInfo}
close={this.closeBinding}
confirm={this.confirmBinding}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
content="序列号库仍在更新,请联系微信助手"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorClose}
></PopupAlert>
<PopupAlert
isShow={isBindingCheckError}
title="提示"
content="您选择的仪器有误,请重新选择确认"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindCheckErrorClose}
confirm={this.onBindCheckErrorClose}
></PopupAlert>
<View catchMove>
<PopupBinding
type={channelInfo.bindingStatus}
isShow={isVisibleBinding}
isRegisterBoolean={isRegisterBoolean}
isExchangeBinding={isExchangeBinding}
data={channelInfo}
close={this.closeBinding}
confirm={this.confirmBinding}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
content="序列号库仍在更新,请联系微信助手"
confirmButtonText="知道了"
textAlgin="center"
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="提示"
content="您选择的仪器有误,请重新选择确认"
confirmButtonText="知道了"
textAlgin="center"
close={this.onBindCheckErrorClose}
confirm={this.onBindCheckErrorClose}
></PopupAlert>
</View>
<Canvas
style="height: 0"
style="position: fixed;left:-10000px;max-width: 1024px;max-height: 768px;"
id="compressImage"
canvasId="compressImage"
type="2d"
@ -480,27 +533,36 @@ export default class Instrument extends Component<any, any> {
className="instrument_list"
style="width: 100%; white-space: nowrap;"
scrollIntoView={"scroll" + channelInfo.id}
scrollIntoViewAlignment={"center"}
>
{equipmentList.map((item, index) => {
return (
<View
className={classnames("cover", {
active_cover: channelInfo.id === item.id,
})}
id={"scroll" + item.id}
key={index}
onClick={this.onSelectChange.bind(this, item)}
>
<Image
className="instrument_img"
src={item.banner}
mode="aspectFill"
// mode="aspectFit"
></Image>
<View className="desc">{item.name}</View>
{equipmentList.length > 0 &&
equipmentList.map((item, index) => {
return (
<View
className={classnames("cover", {
active_cover: channelInfo.id === item.id,
})}
id={"scroll" + item.id}
key={index}
onClick={this.onSelectChange.bind(this, item)}
>
<Image
className="instrument_img"
src={item.banner}
mode="aspectFill"
></Image>
<View className="desc">{item.name}</View>
</View>
);
})}
{equipmentList.length === 0 && (
<Block>
<View>
<NoDataComponent />
</View>
);
})}
</Block>
)}
</ScrollView>
</View>
<View className="form_item is-tab">
@ -568,7 +630,10 @@ export default class Instrument extends Component<any, any> {
</Text>
</View>
</View>
<View className="photo_box" onClick={this.onChangeImg}>
<View
className="photo_box"
onClick={this.onChangeImg.bind(this)}
>
{channelInfo.serialImage && (
<Image
src={channelInfo.serialImage}

@ -9,15 +9,26 @@ import {
Video,
Swiper,
SwiperItem,
RichText,
} 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";
@ -25,30 +36,46 @@ class Intro extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
name: "template模板页",
name: "仪器介绍页",
current: 0,
instrument: {},
introList: [],
isNursing: false,
isCommonError: false, // 是否显示通用错误提示
commonErrorText: [], // 通用错误提示
/** 蓝牙相关 */
isConnectShow: false,
connectInstrument: {}, // 当前连接设备
/* END */
// 设备升级弹窗
isShowUpdateVersionTip: false, // 升级提示
isShowVersionUpgrading: false, // 升级中
isShowVersionUpgradFinish: false, // 升级完成:升级内容公告
versionUpgradFinishNodes: "", // 公告内容
// 设备是否重连弹窗
isShowReConnectDeviceRecordWL200: false,
};
}
$instance = Taro.getCurrentInstance();
async onLoad() {}
componentDidMount() {}
componentWillMount() {
// let params = Taro.Current?.router?.params;
// if (params) {
// this.getInstrumentInfo(params.id);
// }
componentDidMount() {
let strObj = getStorageSync("instrument_detail");
if (strObj) {
let instrument = JSON.parse(strObj);
let instrument = strObj;
this.getInstrumentInfo(instrument.id);
this.setState({ instrument });
}
}
componentWillMount() {
// let params = Taro.Current?.router?.params;
// if (params) {
// this.getInstrumentInfo(params.id);
// }
}
componentWillUnmount() {}
componentDidShow() {}
@ -64,55 +91,327 @@ class Intro extends Component<any, any> {
}
// 获取设备信息
async getInstrumentInfo(id) {
getInstrumentInfo = async (id) => {
let res = await InstrumentInfo.instructionInfo({
instrumentId: id,
});
if (res.data.code === 200) {
this.setState({ introList: res.data.data });
}
}
toNursing() {
// if (this.state.info.iot === 2) {
// this.setState({ isNursing: true }, () => {
// this.toHomePage();
// });
// } else {
// go("/pages/clock_in2/clock_in2?iid=" + this.state.info.id);
// }
}
};
toHomePage() {
// const { isNursing, info } = this.state;
// if (isNursing) {
// setStorageSync("introduceId", info.id);
// }
toHomePage = () => {
const url = "/pages/index/index";
Taro.switchTab({
url,
});
}
};
customBack = () => {
let customBack = this.$instance.router?.params?.customBack;
if (customBack) {
Taro.switchTab({ url: "/pages/index/index" });
Taro.reLaunch({ url: "/pages/index/index" });
return;
}
back();
};
// 跳转仪器介绍页
goNursing = () => {
let { instrument } = this.state;
if (instrument.status === 0) {
this.setState({ connectInstrument: instrument });
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.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"); // 画页面直接跳转
setTimeout(() => {
this.connectionClose();
}, 100);
};
async goIot() {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
setTimeout(() => {
this.connectionClose();
}, 100);
}
//连接完成时数据的回调
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,
});
};
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
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"
@ -164,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}>

@ -216,7 +216,8 @@ page {
.block1_1 {
height: 100%;
flex-direction: column;
width: 134rpx;
// width: 134rpx;
min-width: 80rpx;
.icon {
width: 30rpx;
height: 30rpx;

@ -55,6 +55,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
secondClockImg: null,
thirdClockImg: null,
},
clockcontents:'',
// 现在选中的数据
currentInfo: {
modeVideo: "",
@ -82,10 +83,9 @@ export default class InstrumentClickInUpload extends Component<any, any> {
componentDidHide() {}
async initData() {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let instrumentDetail = JSON.parse(objStr);
this.setState({ instrumentDetail });
let obj = getStorageSync("instrument_detail");
if (obj) {
this.setState({ instrumentDetail: obj });
}
setTimeout(() => {
this.firstNurseInfo();
@ -94,19 +94,29 @@ export default class InstrumentClickInUpload extends Component<any, any> {
}, 10);
}
// 打卡介绍
// 首次护理弹窗
firstNurseInfo = async () => {
let { instrumentDetail } = this.state;
let res = await InstrumentInfo.firstNurseInfo({
instrumentId: instrumentDetail.id,
});
if (res.data.code === 200) {
let isTipShow = getStorageSync("first_instrument_" + instrumentDetail.id);
if (!isTipShow) {
// 首次进入页面:自动打开打卡介绍弹窗
this.setState({ nurseInfo: res.data.data, isTipShow: true });
} else {
this.setState({ nurseInfo: res.data.data });
// 仅在有数据的时候执行
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 });
}
}
}
};
@ -251,10 +261,15 @@ 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 });
<<<<<<< HEAD
this.setState({ punchInInfo: { clockContent: e.detail.value } });
=======
const punchInInfo = this.state.punchInInfo;
punchInInfo.clockContent = e.detail.value;
let clockcontents = e.detail.value;
this.setState({ punchInInfo, clockcontents });
// this.setState({ punchInInfo:{...punchInInfo,clockContent: e.detail.value} });
>>>>>>> qsj
};
onModeLockOpen = async () => {
@ -265,13 +280,13 @@ export default class InstrumentClickInUpload extends Component<any, any> {
};
onTipShowOpen = async () => {
this.setState({ isTipShow: true });
if (this.state.nurseInfo.length) {
this.setState({ isTipShow: true });
} else {
msg("暂无数据");
}
};
onTipShowClose = async () => {
setStorageSync(
"first_instrument_" + this.state.instrumentDetail.id,
"true"
);
this.setState({ isTipShow: false });
};
@ -285,6 +300,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
punchInInfo,
isTipShow,
currentInfo,
clockcontents,
modeInfo,
nurseInfo,
isModeLock,
@ -302,7 +318,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
<Block>
<Navbar titleSlot="打卡上传" isBack />
<Canvas
style="height: 0"
style="position: fixed;left:-10000px;"
id="compressImage"
canvasId="compressImage"
type="2d"
@ -384,10 +400,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
}}
>
<View className="block1">
<View
className="block1_1 flex aitems "
style="min-width: 80rpx"
>
<View className="block1_1 flex aitems ">
<View className="tip1">{item.modeName}</View>
<View className="tip2">{item.modeDesc}</View>
@ -468,10 +481,10 @@ export default class InstrumentClickInUpload extends Component<any, any> {
</View>
<View className="content">
<Textarea
placeholder-className="placeholder"
placeholder-className="placeh和给g'holder"
maxlength={100}
onInput={this.handleTextareaInput}
value={punchInInfo.clockContent}
value={clockcontents}
placeholder="请记录一下今天打卡的心得吧~"
></Textarea>
{/* {tipshow && (

@ -33,10 +33,9 @@ export default class InstrumentDetail extends Component<any, any> {
componentDidHide() {}
async initData() {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let info = JSON.parse(objStr);
this.bindingInstrumentInfo(info.id);
let obj = getStorageSync("instrument_detail");
if (obj) {
this.bindingInstrumentInfo(obj.id);
}
}
@ -86,14 +85,16 @@ export default class InstrumentDetail extends Component<any, any> {
</View>
</View>
<View className="box">
<View className="tip2"></View>
<Image
className="serial_img"
src={info.bindingSerialImage}
mode="aspectFill"
/>
</View>
{info.bindingSerialImage && (
<View className="box">
<View className="tip2"></View>
<Image
className="serial_img"
src={info.bindingSerialImage}
mode="aspectFill"
/>
</View>
)}
<View className="box">
<View className="tip2"></View>
@ -118,21 +119,6 @@ export default class InstrumentDetail extends Component<any, any> {
/>
</View>
</View>
{info.id == 74 ||
(info.id == 73 && (
<View className="box">
<View className="tip2"></View>
<View className="inputbox">
<Input
type="text"
disabled={true}
placeholder-style="color:#000000;font-size:28rpx;font-weight: 500;"
placeholder="花至FLOSSOM.V01.00.00.230316"
/>
</View>
</View>
))}
</View>
</Block>
);

@ -87,45 +87,62 @@ export default class InstrumentManage extends Component<any, any> {
}
};
goIntro(item) {
goIntro = (item) => {
console.log("item", item);
setStorageSync("instrument_detail", item);
let bindid = item.id;
go("/pages/introduce/introduce?id=" + bindid);
}
goBind(item) {
go("/pages/instrument/intro?id=" + bindid);
};
goBind = (item) => {
let bindid = item.id;
go("/pages/instrument/instrument?isOnly=true&id=" + bindid); // 只显示当前仪器内容
}
};
goBindInfo(item) {
goBindInfo = (item) => {
// let bindid = item.id;
setStorageSync("instrument_detail", JSON.stringify(item));
setStorageSync("instrument_detail", item);
go("/pages/instrument_detail/index");
}
};
async lesgobuy(item) {
lesgobuy = (item) => {
console.log(item);
// if (item.programs_json) {
// item.programs_json = JSON.parse(item.programs_json);
// // console.log(item.programs_json)
// Taro.navigateToMiniProgram({
// appId: item.programs_json.buylink,
// path: item.programs_json.buypath,
// envVersion: "release",
// success(res) {
// // 打开成功
// },
// fail() {},
// });
// } else {
// msg("暂无购买链接");
// }
}
if (item.isPurchase === 1) {
if (item.programs_json) {
item.programs_json = JSON.parse(item.programs_json);
// console.log(item.programs_json)
Taro.navigateToMiniProgram({
appId: item.programs_json.buylink,
path: item.programs_json.buypath,
envVersion: "release",
success(res) {
// 打开成功
},
fail() {},
});
} else {
msg("暂无购买链接");
}
} else {
msg("暂无购买链接");
}
};
customBack = () => {
Taro.switchTab({ url: "/pages/user/user" });
};
render() {
let { bindList, unBindList, current } = this.state;
return (
<Block>
<Navbar titleSlot="设备管理" background="#fff" isBack={true} />
<Navbar
titleSlot="设备管理"
background="#fff"
isBack={true}
isCustomBack
customBack={this.customBack}
/>
<View className="instrument_box">
{bindList.length > 0 && (
<Block>
@ -146,7 +163,10 @@ export default class InstrumentManage extends Component<any, any> {
return (
<SwiperItem key={index}>
<View className="wrapper" key={"bind_" + index}>
<View className="cover" onClick={this.goIntro}>
<View
className="cover"
onClick={this.goIntro.bind(this, item)}
>
<Image
className="Image"
src={item.banner}
@ -154,9 +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}>
</View>
<View className="tips"></View>
<View className="right">
<Image
src={require("../../img/index/right.png")}
@ -184,51 +202,57 @@ export default class InstrumentManage extends Component<any, any> {
</View>
</Block>
)}
<View className="title"></View>
<View className="scroll">
<ScrollView scroll-x="true" className="un_bind_list">
{unBindList.map((item, index) => {
if (item.status === 0) {
return (
<View className="wrapper" key={index}>
<View
className="cover"
onClick={this.lesgobuy.bind(this, item)}
>
<Image
className="image"
src={item.banner}
mode="aspectFill"
></Image>
<View className="name">{item.name}</View>
<View
className="buy"
onClick={this.lesgobuy.bind(this, item)}
>
<View className="tips"></View>
<View className="right">
{/* 当且仅当未绑定仪器存在时显示 */}
{unBindList.length > 0 && (
<Block>
<View className="title"></View>
<View className="scroll">
<ScrollView scroll-x="true" className="un_bind_list">
{unBindList.map((item, index) => {
if (item.status === 0) {
return (
<View className="wrapper" key={index}>
<View className="cover">
<Image
src={require("../../img/index/right.png")}
mode="widthFix"
style="height: 20rpx;"
/>
className="image"
src={item.banner}
mode="aspectFill"
></Image>
<View className="name">{item.name}</View>
{item.isPurchase === 1 && (
<View
className="buy"
onClick={this.lesgobuy.bind(this, item)}
>
<View className="tips"></View>
<View className="right">
<Image
src={require("../../img/index/right.png")}
mode="widthFix"
style="height: 20rpx;"
/>
</View>
</View>
)}
</View>
<View className="bind_cont">
<View
className="tobind"
onClick={this.goBind.bind(this, item)}
>
</View>
</View>
</View>
</View>
<View className="bind_cont">
<View
className="tobind"
onClick={this.goBind.bind(this, item)}
>
</View>
</View>
</View>
);
}
})}
</ScrollView>
</View>
);
}
})}
</ScrollView>
</View>
</Block>
)}
</View>
</Block>
);

@ -0,0 +1,76 @@
.iot-footer {
position: fixed;
bottom: 0;
z-index: 99;
display: flex;
align-items: baseline;
width: 100%;
height: 153rpx;
background: #ffffff;
box-shadow: 0rpx -3rpx 7rpx 1rpx rgba(173, 191, 207, 0.21);
padding-bottom: env(safe-area-inset-bottom);
box-sizing: border-box;
.btn {
width: 690rpx;
height: 90rpx;
background: #000;
border-radius: 45rpx;
color: #fff;
line-height: 90rpx;
text-align: center;
margin: 21rpx 49rpx 42rpx 30rpx;
font-size: 32rpx;
}
.text {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: bold;
color: #000;
}
.btn-disable {
background-color: #ccc !important; /* 设置按钮背景颜色为灰色 */
color: #fff !important; /* 设置按钮文字颜色为白色 */
border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */
}
.switch-btn-box {
width: 100vw;
display: flex;
align-items: center;
margin-top: 34rpx;
.btn-item {
height: 70rpx;
display: flex;
flex: 1;
align-items: center;
justify-content: center;
.btn-icon {
width: 36rpx;
height: 36rpx;
margin-right: 18rpx;
}
.btn-text {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: bold;
color: #000000;
}
}
.border-right {
border-right: 1px solid #ddd;
}
.btn-disable {
color: #fff !important; /* 设置按钮文字颜色为白色 */
border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */
background-color: #fff !important; /* 设置按钮背景颜色为灰色 */
.btn-text {
color: #ccc !important; /* 设置按钮文字颜色为白色 */
border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */
background-color: #fff !important; /* 设置按钮背景颜色为灰色 */
}
}
}
}

@ -42,7 +42,7 @@ function Index({
return (
<Block>
<View className="footer">
<View className="iot-footer">
{!isShowNurse && (
<Block>
{isDisabled ? (

@ -9,7 +9,6 @@ interface Props {
activeModeID: any;
ModeList: any;
ModeType: string; // all visor cabin yimeish
ActiveModeItem: any;
isShowNurse: boolean; // 是否已进入护理详情页
isPop: boolean; // 是否弹窗
onEmit: Function; // 每次点击item回调事件和数据给父组件
@ -20,7 +19,6 @@ function Index({
isPop,
ModeList,
ModeType,
ActiveModeItem,
ModeID,
activeModeID,
onEmit,
@ -30,9 +28,7 @@ function Index({
let CabinList = ModeList.filter((item) => item.modeClass === 2); // 舱体模式
let YimeishList = ModeList.filter((item) => item.modeClass === 3); // 医美术后
// const [ModeID, setModeID] = useState<any>("mode_" + ActiveModeItem.id);
// const [activeModeID, setactiveModeID] = useState<any>(ActiveModeItem.id);
console.log("ModeType", ModeType);
const yimeishClick = (item) => {
onEmit(item);
};

@ -75,10 +75,10 @@
}
.msg-tips {
position: absolute;
top: 50%;
top: 40%;
left: 0;
right: 0;
transform: translateY(-50%);
transform: translateY(-40%);
display: flex;
align-items: center;
max-width: 635rpx;
@ -121,73 +121,6 @@
}
}
.footer {
position: fixed;
bottom: 0;
z-index: 99;
display: flex;
align-items: baseline;
width: 100%;
height: 153rpx;
background: #ffffff;
box-shadow: 0rpx -3rpx 7rpx 1rpx rgba(173, 191, 207, 0.21);
padding-bottom: env(safe-area-inset-bottom);
box-sizing: border-box;
.btn {
width: 690rpx;
height: 90rpx;
background: #000;
border-radius: 45rpx;
color: #fff;
line-height: 90rpx;
text-align: center;
margin: 21rpx 49rpx 42rpx 30rpx;
font-size: 32rpx;
}
.text {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: bold;
color: #000;
}
.btn-disable {
background-color: #ccc !important; /* 设置按钮背景颜色为灰色 */
color: #fff !important; /* 设置按钮文字颜色为白色 */
border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */
}
.switch-btn-box {
width: 100vw;
display: flex;
align-items: center;
margin-top: 34rpx;
.btn-item {
height: 70rpx;
display: flex;
flex: 1;
align-items: center;
justify-content: center;
.btn-icon {
width: 36rpx;
height: 36rpx;
margin-right: 18rpx;
}
.btn-text {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: bold;
color: #000000;
}
}
.border-right {
border-right: 1px solid #ddd;
}
}
}
.battery_icon {
width: 8rpx;
height: 20rpx;

@ -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,
@ -42,7 +43,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 +150,6 @@ class IotCarePlan extends Component<any, any> {
showVideoPlayBtn: true, // 视频播放按钮
duration: 0, // 视频总时长
hadShowBreakTips: false, // 是否展示过支架断开提示
popupType: "", // enoughTimePopup: 时间达标提示, endPopup: 结束弹窗
isConnectShow: false, // 是否弹出连蓝牙弹窗:在蓝牙断开时弹出
/** 连接设备 End */
@ -208,6 +208,7 @@ class IotCarePlan extends Component<any, any> {
// 按钮是否可运行
isFooterBtnDisabled: false,
isFirstEntryMode: false, // 模式首次打开
};
}
@ -227,6 +228,7 @@ class IotCarePlan extends Component<any, any> {
Taro.setKeepScreenOn({
keepScreenOn: true,
});
this.getWL200NursingHistory();
this.initData();
}
componentDidMount() {}
@ -254,18 +256,16 @@ class IotCarePlan extends Component<any, any> {
}
async initData() {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let info = JSON.parse(objStr);
let obj = getStorageSync("instrument_detail");
if (obj) {
this.setState({
currentDevice: info,
currentDevice: obj,
});
await this.GetModeList(info.id);
await this.GetModeList(obj.id);
// 如果不存在设备模式值,则判断为首次进入,弹窗提示
let isFirstTipShow = getStorageSync("first_instrument_" + info.id);
let isFirstTipShow = getStorageSync("first_instrument_" + obj.id);
if (!isFirstTipShow) {
this.firstNurseInfo();
}
@ -339,7 +339,7 @@ class IotCarePlan extends Component<any, any> {
Taro.onBLEConnectionStateChange(this.listener);
await this.notifyBLECharacteristicValueChange();
this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
// this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
}
listener = (res) => {
console.log("listener res", res);
@ -417,8 +417,9 @@ class IotCarePlan extends Component<any, any> {
// 护理检查改变模式,是否提示切换护理模式
// isNotCheck为真时不进行校验直接切换
this.tempModeCurrent = data;
this.footerIsDisabled();
// 如果按钮不可点击则报错,内部自带检查底部按钮函数
this.onEmitErrorTips();
if (!isNotCheck) {
let isReturn = this.modeRuningChange();
if (isReturn) return;
@ -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);
}
};
@ -518,43 +522,16 @@ class IotCarePlan extends Component<any, any> {
};
// 弹窗确定切换护理模式
confirmModeSwitchBtn = () => {
let { SwitchActiveModeItem, ActiveModeItem, isStandStatus } = this.state;
let modeArray = ["all", "visor", "cabin", "yimeish"];
// 切换护理模式时,需判断舱体和面罩是否切换
// if (SwitchActiveModeItem.isCabinMode !== ActiveModeItem.isCabinMode) {
// if (SwitchActiveModeItem.isCabinMode === 1) {
// // 判断舱体是否连接成功
// if (!isStandStatus) {
// console.log(
// "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
// );
// this.showTips(
// "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
// );
// // this.openErrorTipsText(
// // "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
// // );
// // return;
// }
// } else {
// // 判断舱体是否断开连接
// if (isStandStatus) {
// console.log("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
// this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
// // this.openErrorTipsText(
// // "检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"
// // );
// // return;
// }
// }
// }
let { SwitchActiveModeItem } = this.state;
this.cancelModeSwitchBtn();
this.modeCurrentFun(SwitchActiveModeItem);
let modeArray = ["all", "visor", "cabin", "yimeish"];
this.setState({
ModeType: modeArray[SwitchActiveModeItem.modeClass],
});
setTimeout(() => {
this.modeCurrentFun(SwitchActiveModeItem);
this.cancelModeSwitchBtn();
console.log("ModeType", this.state.ModeType);
}, 100);
};
@ -579,6 +556,7 @@ class IotCarePlan extends Component<any, any> {
// 如果检查通过,可运行,则执行下一步
if (!this.footerIsDisabled()) {
this.stepNext();
this.openStepTips(); // 仅在进入运行页的时候弹窗
return;
}
// 如果检查失败,则报错
@ -590,8 +568,11 @@ class IotCarePlan extends Component<any, any> {
* @description isCabinMode 0. 1.
*/
onEmitErrorTips = async () => {
let { isStandStatus, ActiveModeItem } = this.state;
if (isStandStatus) {
let { ActiveModeItem } = this.state;
// 按钮不可点击时,提示报错
let isDisabled = this.footerIsDisabled();
if (isDisabled) {
if (ActiveModeItem.isCabinMode === 0) {
this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
} else {
@ -621,9 +602,24 @@ class IotCarePlan extends Component<any, any> {
});
};
/**
* @name
*/
openStepTips = () => {
let isFirstEntryModeNot = getStorageSync(
"isFirstEntryMode_" + this.state.currentDevice.id
);
// 1.如果没有持久化不再提示,每次进入都会弹窗提示
if (!isFirstEntryModeNot) {
// 2.必须要有数据才弹窗
if (this.state.ActiveModeItem.openSourceData.length > 0) {
this.setState({ isShowStepTips: true });
}
}
};
closeStepTips = (data) => {
if (data.isLocal) {
setStorageSync("isFirstEntry_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
setStorageSync("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
}
this.setState({ isShowStepTips: false });
};
@ -650,12 +646,11 @@ class IotCarePlan extends Component<any, any> {
case "WL200":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
} else {
// 清除时间倒计时定时器
this.setState({
facialMaskConnectStatus: 0, // 蓝牙断开
isFooterBtnDisabled: false, // 蓝牙断开所以不可点击
});
// 断开连接直接暂停
// 断开连接直接暂停:会自动暂停定时器
this.judgementWorkStatus(
MODE_WORKING_ENUM.PAUSE,
ActiveModeItem?.modeType
@ -697,6 +692,10 @@ class IotCarePlan extends Component<any, any> {
isStopNurse: true,
ActiveModeItem,
});
setTimeout(() => {
this.onEmitErrorTips();
}, 500);
}
break;
default:
@ -780,6 +779,19 @@ class IotCarePlan extends Component<any, any> {
jsonStatus
);
// 判断设备主动上报的关机事件
if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) {
// 判断id是否一致, 一致的话则生成护理报表, 并提示
if (jsonStatus.id == this.WL200NursingHistory.id) {
debounce(
this.checkInstrumentRecord.bind(this, jsonStatus),
500
);
}
return;
}
this.workStatus = jsonStatus.workStatus;
this.setState({
Electricity: jsonStatus.battery,
@ -910,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 = {
@ -931,7 +954,9 @@ class IotCarePlan extends Component<any, any> {
console.log("时间校准频率默认5秒一次", TIME_CALIBRATION_FREQUENCY);
//对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准
const currentScene = ActiveModeItem; // 获取当前的场景
let sceneTime = minSecToS(currentScene.modeTimeStr); // 场景时间
let sceneTime = ActiveModeItem?.breakTimeStr
? minSecToS(ActiveModeItem.breakTimeStr)
: minSecToS(currentScene.modeTimeStr); // 场景时间
console.log("场景时间 sceneTime", sceneTime);
console.log("当前显示时间 currentTime", currentTime);
@ -997,6 +1022,13 @@ class IotCarePlan extends Component<any, any> {
});
}
opts.workStatus = nWorkStatus;
let nowCurrentTime = ActiveModeItem.modeTimeStr;
// 完成重连同步则删除重连时间字段
if (ActiveModeItem?.breakTimeStr) {
nowCurrentTime = ActiveModeItem?.breakTimeStr;
}
const statusF = {
sleep: () => {
this.setState({
@ -1008,7 +1040,7 @@ class IotCarePlan extends Component<any, any> {
isShowCountdown: false,
});
if (nowModeItem?.isCabinMode && step == 2) {
opts.currentTime = nowModeItem.modeTimeStr;
opts.currentTime = nowCurrentTime;
} else if (!nowModeItem?.isCabinMode && step == 2) {
// fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby
opts.step = 1;
@ -1036,7 +1068,7 @@ class IotCarePlan extends Component<any, any> {
});
}
if (nowModeItem) {
opts.currentTime = nowModeItem.modeTimeStr;
opts.currentTime = nowCurrentTime;
}
// startSettingCountDown 用于标记打开了倒计时loading
if (!this.state.isShowCountdown) {
@ -1133,17 +1165,21 @@ class IotCarePlan extends Component<any, any> {
step == 2 &&
facialMaskConnectStatus == 1
) {
let totalSeconds = minSecToS(ActiveModeItem.modeTimeStr);
// 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算
let currentSeconds = ActiveModeItem?.breakTimeStr
let totalSeconds = ActiveModeItem?.breakTimeStr
? minSecToS(ActiveModeItem.breakTimeStr)
: minSecToS(currentTime);
: minSecToS(ActiveModeItem.modeTimeStr);
// 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算
let currentSeconds = minSecToS(currentTime);
let checkTime = totalSeconds - currentSeconds;
// 缓存经过的时间:用于接口提交
this.elapsedTime = checkTime;
// 完成重连同步则删除重连时间字段
// 如果存在中断时间,则要加上间隔的时间
if (ActiveModeItem?.breakTimeStr) {
delete ActiveModeItem?.breakTimeStr;
this.setState({ ActiveModeItem });
let intervalTime =
minSecToS(ActiveModeItem.modeTimeStr) -
minSecToS(ActiveModeItem.breakTimeStr);
this.elapsedTime += intervalTime;
}
// 判断剩余时间是否大于1
@ -1240,9 +1276,10 @@ class IotCarePlan extends Component<any, any> {
};
/**
*
* @name
* @params type switch
*/
onNursingTap() {
onNursingTap(type = "") {
// 如果已禁止运行,则停止执行后续逻辑
if (this.state.isFooterBtnDisabled) return;
// 防止多次点击
@ -1301,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; // 不管当前什么状态,直接设为工作状态
@ -1378,6 +1417,7 @@ class IotCarePlan extends Component<any, any> {
*
* */
checkInstrumentRecord = async (jsonStatus: any) => {
console.log("检查护理记录");
let { currentDevice, ActiveModeItem, ModeList } = this.state;
if (jsonStatus) {
}
@ -1417,7 +1457,6 @@ class IotCarePlan extends Component<any, any> {
return;
}
let sceneTime = minSecToS(ActiveModeItem.modeTimeStr);
// 4.判断设备状态-未运行/已完成/待机
if (
workStatus == MODE_WORKING_ENUM.STANDBY ||
@ -1438,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;
}
@ -1480,6 +1519,7 @@ class IotCarePlan extends Component<any, any> {
console.log("同步异常,但设备运行中");
}
};
/** 获取小程序本地缓存的历史记录 */
getWL200NursingHistory() {
this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
@ -1530,13 +1570,20 @@ class IotCarePlan extends Component<any, any> {
console.log("更新updateWL200NursingHistory");
}
};
/** 删除WL200护理历史 */
/**
* @name WL200
* @description 1 2
* IDID
*
*/
rmWL200NursingHistory = (WL200NursingHistory, hard = false) => {
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 = "";
}
};
@ -1561,6 +1608,7 @@ class IotCarePlan extends Component<any, any> {
console.log("PostNursingLogClock", res);
if (res.data.code === 200) {
this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录
if (isJump) {
this.setState({
isShowNursingSuccess: true,
@ -1756,7 +1804,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({
isNotEnoughTime: false,
});
Taro.switchTab({
Taro.reLaunch({
url: "/pages/index/index",
});
};
@ -1773,26 +1821,35 @@ class IotCarePlan extends Component<any, any> {
this.setState({
isConnectShow: false,
});
this.onNursingTap();
};
connectionClose = () => {
this.setState({
isConnectShow: false,
});
Taro.reLaunch({ url: "/pages/index/index" });
};
// 手动护理模式切换:提示是否保存护理
/**仅关闭*/
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); // 不进行校验
};
@ -1819,7 +1876,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({ isFirstTipShow: true });
};
onTipShowClose = async () => {
setStorageSync("first_instrument_" + this.state.currentDevice.id, "true");
setStorageSync("first_instrument_" + this.state.currentDevice.id, true);
this.setState({ isFirstTipShow: false });
};
/** 初次护理信息弹窗 END */
@ -1834,13 +1891,33 @@ class IotCarePlan extends Component<any, any> {
let isCanClick = isStandStatus
? this.tempModeCurrent?.isCabinMode === 1
: this.tempModeCurrent?.isCabinMode === 0;
let isFooterBtnDisabled = !(isStandStatus === isCanClick);
this.setState({
isFooterBtnDisabled: isFooterBtnDisabled,
});
// 如果舱体状态和模式类型不相等,则禁用
let isFooterBtnDisabled = false;
if (isStandStatus) {
if (!isCanClick) {
isFooterBtnDisabled = true;
}
} else {
if (!isCanClick) {
isFooterBtnDisabled = true;
}
}
// 仅在值变化时更新state
if (isFooterBtnDisabled !== this.state.isFooterBtnDisabled) {
this.setState({
isFooterBtnDisabled: isFooterBtnDisabled,
});
}
return isFooterBtnDisabled; // 数据更新有延迟,返回用于判断
};
customBack = () => {
Taro.reLaunch({ url: "/pages/index/index" });
};
render() {
let {
title,
@ -1875,11 +1952,17 @@ class IotCarePlan extends Component<any, any> {
nurseInfo,
isShowReReadRecordSave,
isFooterBtnDisabled,
isFirstEntryMode,
} = this.state;
return (
<Block>
<Navbar titleSlot={title} isBack />
<Navbar
titleSlot={title}
isBack
isCustomBack
customBack={this.customBack}
/>
<View catchMove>
<PopupInstrumentUploadTips
@ -1917,7 +2000,6 @@ class IotCarePlan extends Component<any, any> {
isShowNurse={isShowNurse}
ModeList={ModeList}
ModeType={ModeType}
ActiveModeItem={SwitchActiveModeItem}
onEmit={this.switchModeCurrentFun}
onEmitShowAll={this.openModeSwitch}
/>
@ -1933,7 +2015,7 @@ class IotCarePlan extends Component<any, any> {
<PopupStepTips
isShow={isShowStepTips}
isLarge
isFirstEntry
isFirstEntry={isFirstEntryMode}
confirmButtonText="知道了"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}
@ -1980,25 +2062,7 @@ class IotCarePlan extends Component<any, any> {
confirmButtonText="确认"
textAlgin="center"
close={this.closeTipsSave}
confirm={this.confirmTipsSave}
/>
<PopupConfirm
isShow={isShowReReadRecordSave}
isClose
zIndex={10020}
myClassName="level-up"
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
cancelButtonText="取消"
confirmButtonText="确认"
textAlgin="center"
close={this.closeTipsSave}
cancel={this.cancelTipsSave}
confirm={this.confirmTipsSave}
/>
@ -2035,6 +2099,7 @@ class IotCarePlan extends Component<any, any> {
<Video
className="video-or-image"
src={ActiveModeItem.modeVideo}
loop
/>
)}
@ -2090,7 +2155,6 @@ class IotCarePlan extends Component<any, any> {
ModeType={ModeType}
ModeID={ModeID}
activeModeID={activeModeID}
ActiveModeItem={ActiveModeItem}
onEmit={this.modeCurrentFun}
onEmitShowAll={this.openModeSwitch}
/>

@ -171,11 +171,9 @@ export default class Recording extends Component<any, any> {
}
}
// 文本框输入文字
handleTextareaInput(e) {
const punchInInfo = this.state.punchInInfo;
punchInInfo.clockContent = e.detail.value;
this.setState({ punchInInfo });
}
handleTextareaInput = (e) => {
this.setState({ punchInInfo: { clockContent: e.detail.value } });
};
// 打开/关闭弹窗
setShow(show: boolean) {
this.setState({ show });
@ -330,7 +328,9 @@ export default class Recording extends Component<any, any> {
monthTime,
show,
punchInInfo,
clockContent,
} = this.state;
return (
<Block>
<Navbar isBack titleSlot="护理记录"></Navbar>

@ -51,16 +51,13 @@ class Register extends Component<any, any> {
}
onSkip = () => {
Taro.switchTab({
url: "/pages/index/index",
});
// 返回首页尽量清空路由记录,防止扫码参数bug扰乱逻辑
Taro.reLaunch({ url: "/pages/index/index" });
};
skipRegister() {
// 跳过注册
Taro.setStorageSync("skipRegister", true);
Taro.navigateBack({
delta: 1,
});
Taro.reLaunch({ url: "/pages/index/index" });
}
onDisagreeTap = () => {
// 关闭小程序
@ -163,6 +160,7 @@ class Register extends Component<any, any> {
componentDidHide() {}
async initData() {
console.log("MpSplashDetail Register");
const { data } = await MpSplashDetail({
pageNum: 1,
pageSize: 5,

@ -51,7 +51,6 @@ export const Ajax = (params) => {
},
data: params.data,
success(res) {
// console.log("res", res);
if (res.data.code == 401 || res.data.code == 403) {
// 自动重新登录
Taro.removeStorageSync("token");
@ -59,14 +58,6 @@ export const Ajax = (params) => {
return;
}
// if (res.statusCode !== 200) {
// Taro.showModal({
// title: "提示",
// content: String("错误码:" + res.statusCode),
// showCancel: false,
// });
// return false;
// }
if (res.data.code === 500) {
let msg = "系统异常,请联系管理人员";
@ -148,7 +139,12 @@ export const AjaxUploadFile = (params, formData) => {
});
return false;
}
if (o.code !== 200) {
if (
o.code !== 200 &&
o.code !== 203 &&
o.code !== 204 &&
o.code !== 205
) {
let msg =
typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员";
Taro.showModal({
@ -217,7 +213,7 @@ export const AjaxFormData = (params) => {
});
return false;
}
if (res.data.code !== 200) {
if (res.data.code !== 200 && o.code !== 204 && o.code !== 205) {
let msg =
typeof res.data.msg == "string"
? res.data.msg

Loading…
Cancel
Save