临时提交

master
blak-kong 2 years ago
parent 67d6d9fb88
commit 9b6a4077e2

@ -533,7 +533,7 @@ class ConnectionBluetoot extends Component<any, any> {
let currentDevicesName = getStorageSync("currentDevicesName");
let deviceVersionNo = jsonStatus.versionNo;
let latestVersionNo = deviceInfo.iotVersion;
if (currentDevicesName.indexOf("12CAA") < -1) {
if (currentDevicesName.indexOf("12CAA") === -1) {
latestVersionNo = deviceInfo.we200IotVersion;
}
// 判断版本号是否需要升级
@ -541,9 +541,14 @@ class ConnectionBluetoot extends Component<any, any> {
deviceVersionNo,
latestVersionNo
);
console.log("isNeedToUpdateBl", isNeedToUpdateBl);
if (isNeedToUpdateBl) {
// 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗
this.props.upgradeFun();
} else {
// 不需要升级,跳转进入仪器详情页
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
this.pairingChange(this.state);
}
break;
case "offlineClockSummary":
@ -648,6 +653,7 @@ class ConnectionBluetoot extends Component<any, any> {
const value = this.isWL200()
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
sendCommand({ value });
}
}
@ -807,9 +813,6 @@ class ConnectionBluetoot extends Component<any, any> {
case 10000:
errorText = "未初始化蓝牙适配器";
break;
case 10000:
errorText = "未初始化蓝牙适配器";
break;
case 10001:
errorText = "当前蓝牙适配器不可用";
break;
@ -940,14 +943,13 @@ class ConnectionBluetoot extends Component<any, any> {
if (sendGetVersionTimerNum >= 10) {
// 超时未返回版本号
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
console.log("超时未返回版本号 this.pairingChange", this.state);
// this.pairingChange(this.state);
} else {
this.sendGetVersion();
}
}
}, 600);
}, 1000);
// 5秒后没有收到版本返回直接跳去护理页
// if (isGetVersionTimer) clearTimeout(isGetVersionTimer);

@ -5,7 +5,7 @@ import { useState, useEffect } from "react";
import "./index.less";
interface Props {
isConnectionBlutoot: boolean;
isCanClick: boolean;
isShowNurse: boolean;
isStopNurse: boolean;
onEmitStartNurse: Function; // 每次点击item回调事件和数据给父组件
@ -13,7 +13,7 @@ interface Props {
onEmitEndPlan: Function;
}
function Index({
isConnectionBlutoot,
isCanClick,
isShowNurse,
isStopNurse,
onEmitStartNurse,
@ -37,7 +37,7 @@ function Index({
<View className="footer">
{!isShowNurse && (
<Block>
{isConnectionBlutoot ? (
{isCanClick ? (
<View className="btn" onClick={onStartNurse}>
</View>

@ -57,8 +57,7 @@ import {
} from "@/utils/util";
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
import commandMap from "@/utils/commandMap";
const deviceToolKitInstanceWE100 = new DeviceToolKitWE100("WE100", "M01");
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200");
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200");
let currentTimeTimer: any = null; // 当前项目时间定时器
let CountdownTimer: any = null;
@ -70,22 +69,6 @@ let switchModeStatus = "free"; // 用于标记是否在切换模式中, free:
// 设备运行时间校准频率,每多少秒校准一次
const TIME_CALIBRATION_FREQUENCY = 5;
// 模式类型
const WORK_MODE_NAME_ENUM = {
POWERFULSOOTHING: "powerfulSoothing",
STABILITY: "Stability",
BRIGHTEN: "Brighten",
FIRMSKIN: "FirmSkin",
MaskCustom: "MaskCustom",
BrightenStand: "BrightenStand",
FirmSkinStand: "FirmSkinStand",
SmallpoxSoothingPro: "SmallpoxSoothingPro",
SmallpoxSoothing: "SmallpoxSoothing",
MixNursePro: "MixNursePro",
MixNurse: "MixNurse",
ScalpCare: "ScalpCare",
};
// 组合模式:分别对应的是哪几个模式类型
// 黄光590nm
// 红光630nm
@ -114,12 +97,12 @@ const MODE_WORKING_ENUM = {
END: "end",
};
// 倒计时时间
// 不同模式启动前的倒计时时间
let CountDownTime = {
powerfulSoothing: 6,
Stability: 4,
Brighten: 4,
FirmSkin: 4,
Stability: 3,
Brighten: 3,
FirmSkin: 3,
MaskCustom: 6,
BrightenStand: 6,
FirmSkinStand: 6,
@ -134,7 +117,7 @@ let DeviceSyncData = {
totalWorkingMinutes: 0,
totalWorkingSeconds: 0,
};
let deviceToolKitInstance = deviceToolKitInstanceWE100; // we100
let deviceToolKitInstance = deviceToolKitInstanceWL200;
class IotCarePlan extends Component<any, any> {
constructor(props) {
@ -142,20 +125,18 @@ class IotCarePlan extends Component<any, any> {
this.state = {
name: "iotCarePlan",
title: "美容仪名字", // 页面标题
instrument: "WE200",
// 当前设备
currentDevice: {
name: "",
model: "",
}, // 当前设备
},
/** 连接设备 */
hasVersion: false, // 是否已查询到版本号
curDeviceInfo: {}, // 当前设备信息
basicModeList: [], //模式列表
modelActiveIndex: 0, //模式下标
sliderProgress: 22,
isStandStatus: false, // 支架开启状态(支架就是舱体)
facialMaskConnectStatus: 0, // 面罩连接状态 0未连接 1已连接
facialMaskConnectStatus: 1, // 面罩连接状态 0未连接 1已连接
workStatus: "", // 工作状态
Electricity: 4, // WL200电量
matrixElectricity: 4, // WE200发箍电量
@ -164,10 +145,7 @@ class IotCarePlan extends Component<any, any> {
gear: { gear: 1 },
currentShowDialog: "",
// countdown: 3, // 倒计时
step: 1, // 1:选择模式并播放视频, 2:护理中
isCheckedMaskVersion: false, // 是否检查过固件版本了
isAskedOta: false, // 询问过用户是否需要OTA
showVideoPlayBtn: true, // 视频播放按钮
duration: 0, // 视频总时长
hadShowBreakTips: false, // 是否展示过支架断开提示
@ -175,12 +153,15 @@ class IotCarePlan extends Component<any, any> {
/** 连接设备 End */
/** 护理过程 */
isStandStatus: false, // 当前模式是否舱体/支架模式
isShowStepTips: false, // 是否显示介绍步骤弹窗
isConnectionBlutoot: false, // 是否已连接蓝牙
isConnectionBlutoot: true, // 是否已连接蓝牙
isShowNurse: false, // 是否开始并显示护理
isStopNurse: false, // 是否暂停护理
isEndNurse: false, // 是否结束护理
errorTips: "", // 错误提示
/** 护理过程 END*/
// 模式列表
isSwitchActiveMode: false, // 是否显示弹窗切换模式
@ -198,21 +179,20 @@ class IotCarePlan extends Component<any, any> {
startSource: "",
stopSource: "",
},
// 模式组合
isCombineSuccess: false, // 组合模式是否设置成功
// 倒计时
isShowCountdown: false, // 倒计时弹窗
countdown: 3,
// 是否结束护理
isEndCarePlan: false,
// 最后执行步骤位置
endPlace: "",
currentTime: "01:00",
};
}
hadGotInstrumentHistoryData = false; // 已缓存仪器历史数据
async onLoad() {
// 保持屏幕常亮
@ -244,7 +224,7 @@ class IotCarePlan extends Component<any, any> {
currentDevice: info,
});
this.GetModeList(info.id);
await this.GetModeList(info.id);
console.log("info");
// 如果不存在设备模式值,则判断为首次进入,弹窗提示
@ -321,7 +301,9 @@ class IotCarePlan extends Component<any, any> {
ModeList: res.data.data,
});
this.modeCurrentFun(res.data.data[0]);
setTimeout(() => {
this.modeCurrentFun(res.data.data[0]);
});
} else {
this.setState({ ModeList: res.data.data });
}
@ -360,6 +342,17 @@ class IotCarePlan extends Component<any, any> {
/** 选中护理模式 */
modeCurrentFun = async (data) => {
let { isStandStatus } = this.state;
// 舱体模式无法对应的时候,置灰开始按钮
let isCabinMode = data.isCabinMode === 1;
if (isStandStatus === isCabinMode) {
this.setState({ isCanClick: true });
} else {
this.setState({ isCanClick: false });
}
console.log("isStandStatus", isStandStatus, isCabinMode);
console.log("isStandStatus === isCabinMode", isStandStatus === isCabinMode);
let currentServiceData = {
startSource: "",
stopSource: "",
@ -431,22 +424,19 @@ class IotCarePlan extends Component<any, any> {
ModeType: modeArray[modeClass],
isShowNurse: true,
isStopNurse: true,
isStandStatus: this.state.ActiveModeItem.isCabinMode === 1,
workStatus: "pause",
step: 2,
});
this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
setTimeout(() => {
this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
});
};
/** 开始护理按钮:点击开始,页面进行到下一步 */
onStartNurse = async () => {
this.stepNext();
return;
let { isConnectionBlutoot } = this.state;
if (isConnectionBlutoot) {
let { isCanClick } = this.state;
if (isCanClick) {
this.stepNext();
} else {
// todo 提示未连接蓝牙
}
};
/** 切换光照 */
@ -474,6 +464,7 @@ class IotCarePlan extends Component<any, any> {
/** 蓝牙相关 */
switchBLEMatch = (jsonStatus: any) => {
console.log("蓝牙相关", jsonStatus);
switch (jsonStatus.bleCommandType) {
// 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。
case "SendMatchCode":
@ -485,39 +476,34 @@ class IotCarePlan extends Component<any, any> {
// 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了
case "BleStatusSync":
console.log("BleStatusSync", jsonStatus);
switch (jsonStatus.connectMessage?.deviceName) {
case "WL200":
console.log(
"BleStatusSync 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上",
jsonStatus.connectMessage?.connectType == "CONNECTED"
);
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
// 已连接WL200
this.setState({ isConnectionBlutoot: true });
// 附属设备连接成功,如何区分是哪个设备?
this.setState({
facialMaskConnectStatus: 1, // 面罩已连接
});
deviceToolKitInstance = deviceToolKitInstanceWL200;
console.log(
"检查版本isCheckedMaskVersion",
this.state.isCheckedMaskVersion
);
if (!this.state.isCheckedMaskVersion) {
this.checkVersion();
}
} else {
// WL200连接失败
// deviceToolKitInstance = deviceToolKitInstanceWE100;
// // TODO 护理中(step==2)时, 如果断开, 可能需要暂停
console.log("WL200连接失败或断开");
this.setState({
facialMaskConnectStatus: 0,
});
}
break;
// 是否附属设备是否连接支架
// 附属设备是否WL200
// case "WL200":
// console.log(
// "BleStatusSync 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上",
// jsonStatus.connectMessage?.connectType == "CONNECTED"
// );
// if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
// // 已连接WL200
// this.setState({ isConnectionBlutoot: true });
// // 附属设备连接成功,如何区分是哪个设备?
// this.setState({
// facialMaskConnectStatus: 1, // 面罩已连接
// });
// deviceToolKitInstance = deviceToolKitInstanceWL200;
// } else {
// // WL200连接失败
// // deviceToolKitInstance = deviceToolKitInstanceWE100;
// // // TODO 护理中(step==2)时, 如果断开, 可能需要暂停
// console.log("WL200连接失败或断开");
// this.setState({
// facialMaskConnectStatus: 0,
// });
// }
// break;
// 附属设备是否连接支架
case "Stand":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
this.setState({
@ -534,50 +520,28 @@ class IotCarePlan extends Component<any, any> {
case "QueryMatchStatus":
const isStandDevice =
jsonStatus?.subDeviceList?.includes("Stand") || false;
const isConnectedMask =
jsonStatus?.subDeviceList?.includes("WL200") || false;
deviceToolKitInstance = isConnectedMask
? deviceToolKitInstanceWL200
: deviceToolKitInstanceWE100;
deviceToolKitInstance = deviceToolKitInstanceWL200;
console.log("连接and更改成功 deviceToolKitInstance", isConnectedMask);
if (!this.state.isCheckedMaskVersion && isConnectedMask) {
this.checkVersion(); // 检查版本
}
console.log("支架是否链接", isStandDevice);
console.log("面罩是否链接", isConnectedMask);
if (isConnectedMask) {
this.setState({
isConnectionBlutoot: true,
facialMaskConnectStatus: 1,
this.setState({
isStandStatus: isStandDevice,
});
// 连上面罩后, 获取仪器记录, 与缓存信息对比,
if (!this.hadGotInstrumentHistoryData) {
// 查询护理记录
this.getInstrumentHistoryData();
// 如果不延时, 无法获取到仪器状态
const queryDeviceArrayBuffer = deviceToolKitInstance.toBleCommand(
bleCommandSamples.queryDeviceStatus as any
);
console.log("发送查询设备指令 获取仪器状态");
sendCommand({
value: queryDeviceArrayBuffer,
});
}
// 连上面罩后, 获取仪器记录, 与缓存信息对比,
// if (
// isConnectedMask &&
// !this.state.hadGotInstrumentHistoryData
// ) {
// // 如果不延时, 无法获取到仪器状态
// const queryDeviceArrayBuffer =
// deviceToolKitInstance.toBleCommand(
// bleCommandSamples.queryDeviceStatus as any
// );
// console.log("发送查询设备指令");
// sendCommand({
// value: queryDeviceArrayBuffer,
// });
// // 打开ota页面需要关闭
// // that.data.getInstrumentHistoryDataTimer = setTimeout(() => {
// // that.getInstrumentHistoryData();
// // }, 3000);
// }
// this.setData({
// isStandStatus: isStandDevice,
// facialMaskConnectStatus: `${isConnectedMask ? 1 : 0}`,
// // currentTime: this.data.standInfo.currentTime
// });
}
};
@ -666,7 +630,7 @@ class IotCarePlan extends Component<any, any> {
switch (jsonStatus.infoQueryType) {
// 自定义模式设置
case "customModeSet":
console.log(">>>>>>>>>>>>>>>自定义模式>>>>>>>>>>>>>>>");
console.log(">>>>>>>>>>>>>>>设置自定义模式>>>>>>>>>>>>>>>");
console.log(
"InfoQuery customModeSet responseStatus=====>",
jsonStatus
@ -681,28 +645,25 @@ class IotCarePlan extends Component<any, any> {
break;
// 自定义模式信息
case "customModeInfo":
console.log(">>>>>>>>>>>>>>>查询自定义模式信息>>>>>>>>>>>>>>>");
console.log(
"InfoQuery customModeInfo responseStatus=====>",
jsonStatus
);
break;
case "versionInfo":
console.log(
"InfoQuery versionInfo responseStatus=====>",
jsonStatus
);
if (jsonStatus.versionNo) {
// 清理计时器
if (checkVersionTimeout) clearTimeout(checkVersionTimeout);
if (this.state.hasVersion) return;
this.setState({
hasVersion: true,
});
}
break;
// 当前报告
case "currentMaskReportInfo":
// 每次切换模式并开始运行后生成一个新的自增ID
// commandType: "InfoQuery"
// createDate: ""
// gear: 0
// id: 73
// infoQueryType: "currentMaskReportInfo"
// neededTotalSeconds: 900
// totalSeconds: 0
// workMode: "BrightenStand"
console.log("当前面罩报告 currentMaskReportInfo", jsonStatus);
// if (!this.state.hadCheckReport) {
// this.state.hadCheckReport = true;
@ -750,35 +711,6 @@ class IotCarePlan extends Component<any, any> {
});
};
// 检查版本
checkVersion = () => {
this.sendCheckVersion();
this.setState({
isCheckedMaskVersion: true,
});
if (checkVersionTimeout) clearTimeout(checkVersionTimeout);
checkVersionTimeout = setTimeout(() => {
if (this.state.hasVersion) {
if (checkVersionTimeout) clearTimeout(checkVersionTimeout);
} else {
this.sendCheckVersion();
}
}, 600);
};
// 检查版本指令
sendCheckVersion = () => {
deviceToolKitInstance.setDebug(true);
// 加定时器查询版本
const queryVersion = deviceToolKitInstance.toBleCommand({
commandType: "InfoQuery",
infoQueryType: "versionInfo",
otaDeviceType: "WL200",
});
sendCommand({
value: queryVersion,
});
};
//待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData)
updateDeviceSyncData = (newData, jsonStatus) => {
DeviceSyncData = {
@ -885,9 +817,9 @@ class IotCarePlan extends Component<any, any> {
this.setState({
isShowCountdown: false,
});
if (nowModeItem?.isStandMode && step == 2) {
if (nowModeItem?.isCabinMode && step == 2) {
opts.currentTime = nowModeItem.modeTime;
} else if (!nowModeItem?.isStandMode && step == 2) {
} else if (!nowModeItem?.isCabinMode && step == 2) {
// fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby
opts.step = 1;
}
@ -956,7 +888,7 @@ class IotCarePlan extends Component<any, any> {
},
end: () => {
// 仪器返回护理结束, 支架模式不需要了
// if (modeItem.isStandMode) {
// if (modeItem.isCabinMode) {
// this.onPauseTap();
// }
// 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息
@ -1128,9 +1060,9 @@ class IotCarePlan extends Component<any, any> {
const sendParams = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
// workMode: "MaskCustom",
workStatus: newWorkStatus,
};
console.log("准备发送自定义指令", ActiveModeItem, sendParams);
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
@ -1162,21 +1094,23 @@ class IotCarePlan extends Component<any, any> {
hadClickStart: false,
});
}, 500);
const {
ActiveModeItem,
workStatus,
isStandStatus,
facialMaskConnectStatus,
customModeData,
} = this.state;
const modelActiveItem = ActiveModeItem;
// log.info(
// commandMap.WL200Command,
// "点击开始护理按钮",
// `当前模式: ${modelActiveIndex}`,
// `当前面罩状态:${facialMaskConnectStatus}`,
// `当前仪器模式:${workStatus}`
// );
if (isStandStatus === 1 && ActiveModeItem.isCabinMode === 0) {
console.log("已连接舱体,只可选择舱体模式");
return;
}
if (isStandStatus === 0 && ActiveModeItem.isCabinMode === 1) {
console.log("未连接舱体!");
return;
}
console.info(
commandMap.WL200Command,
"点击开始护理按钮",
@ -1184,7 +1118,7 @@ class IotCarePlan extends Component<any, any> {
`当前面罩状态:${facialMaskConnectStatus}`,
`当前仪器模式:${workStatus}`
);
console.log(modelActiveItem);
console.log(ActiveModeItem);
console.log("isStandStatus:" + isStandStatus);
console.log(
workStatus !== MODE_WORKING_ENUM.WORKING &&
@ -1198,12 +1132,12 @@ class IotCarePlan extends Component<any, any> {
return;
}
// 如果是强效舒缓,需要判断是否连接支架
if (modelActiveItem.isStandMode && !isStandStatus) {
if (ActiveModeItem.isCabinMode && !isStandStatus) {
this.showTips(
`检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源`
);
return;
} else if (!modelActiveItem.isStandMode && isStandStatus) {
} else if (!ActiveModeItem.isCabinMode && isStandStatus) {
this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`);
return;
}
@ -1211,7 +1145,7 @@ class IotCarePlan extends Component<any, any> {
ActiveModeItem.modeType === "MaskCustom" &&
!this.state.isCombineSuccess
) {
this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
this.showTips(`${ActiveModeItem.modeName}模式设置失败,请联系小助手`);
return;
}
// 开始执行护理
@ -1268,6 +1202,20 @@ class IotCarePlan extends Component<any, any> {
}
}
getInstrumentHistoryData() {
this.hadGotInstrumentHistoryData = true;
console.log("发送获取currentMaskReportInfo指令");
setTimeout(() => {
const queryCurrentMaskReportInfoBuffer =
deviceToolKitInstance.toBleCommand({
...(bleCommandSamples.queryCurrentMaskReportInfo as any),
});
sendCommand({
value: queryCurrentMaskReportInfoBuffer,
});
}, 3000);
}
// 删除WL200护理历史
rmWL200NursingHistory(WL200NursingHistory, hard = false) {}
@ -1296,11 +1244,6 @@ class IotCarePlan extends Component<any, any> {
totalWorkingSeconds,
};
});
console.log(
"组合时间ServiceTimeData",
serviceData,
ActiveModeItem.serviceData
);
return serviceData;
}
// 设置护理时间组合
@ -1319,14 +1262,12 @@ class IotCarePlan extends Component<any, any> {
let oldTime = old.totalWorkingMinutes * 60 + old.totalWorkingSeconds;
let value = oldTime + curTime;
console.log("value", value);
ModeStepTimeArray.push(value);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
totalWorkingSeconds: newTotalWorkingSeconds,
};
}
console.log("curTime", curTime);
ModeStepTimeArray.push(curTime);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
@ -1460,7 +1401,7 @@ class IotCarePlan extends Component<any, any> {
isShowUpdateVersionTip,
isShowVersionUpgrading,
isShowStepTips,
isConnectionBlutoot,
isCanClick,
isShowNurse,
isStopNurse,
ModeList,
@ -1487,6 +1428,7 @@ class IotCarePlan extends Component<any, any> {
<View catchMove>
<PopupCountdown isShow={isShowCountdown} countdown={countdown} />
<PopupConfirm
isLarge
isClose
@ -1613,7 +1555,7 @@ class IotCarePlan extends Component<any, any> {
</View>
<Footer
isConnectionBlutoot={isConnectionBlutoot}
isCanClick={isCanClick}
isShowNurse={isShowNurse}
isStopNurse={isStopNurse}
onEmitStartNurse={this.onStartNurse}

@ -2,7 +2,17 @@ import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Component, PropsWithChildren, useEffect, useState } from "react";
import { Block, View, Text, Image, Input, Button, ScrollView, Picker, Textarea } from "@tarojs/components";
import {
Block,
View,
Text,
Image,
Input,
Button,
ScrollView,
Picker,
Textarea,
} from "@tarojs/components";
import { go } from "@/utils/traoAPI";
import { Tab, Tabs, Dialog, Popup } from "@antmjs/vantui";
@ -10,9 +20,9 @@ import { Tab, Tabs, Dialog, Popup } from "@antmjs/vantui";
import Navbar from "../../components/navbar/navbar";
import PopupClock from "../../components/popup/popup-clock";
/** 自定义组件 **/
import { InstrumentInfo } from '../../utils/Interface'
import { InstrumentInfo } from "../../utils/Interface";
import { date, getdates, previewImage } from "../../utils/util";
import { showModal } from '../../utils/traoAPI.js'
import { showModal } from "../../utils/traoAPI.js";
import "./recording.less";
@ -47,14 +57,14 @@ export default class Recording extends Component<any, any> {
show: false,
punchInInfo: {
clockImageList: [],
clockContent: '',
clockContent: "",
},
};
}
componentDidMount() { }
componentDidMount() {}
componentWillUnmount() { }
componentWillUnmount() {}
// 格式化时间
getTime(time) {
const hour = time.slice(0, 2);
@ -62,46 +72,45 @@ export default class Recording extends Component<any, any> {
const second = time.slice(6, 8);
if (hour > 0) {
return hour + '时' + minute + '分' + second + '秒'
return hour + "时" + minute + "分" + second + "秒";
} else {
return minute + '分' + second + '秒'
return minute + "分" + second + "秒";
}
}
// 获取仪器列表
async getBindingInstrumentList() {
let res = await InstrumentInfo.bindingInstrumentList()
let res = await InstrumentInfo.bindingInstrumentList();
if (res.data.code === 200) {
this.setState({ bindingInstrumentList: res.data.data })
this.setState({ bindingInstrumentList: res.data.data });
}
}
// 获取护理历程
async getRecord(id) {
let data = {}
let data = {};
if (id != null) {
data['instrumentId'] = id
data["instrumentId"] = id;
}
let res = await InstrumentInfo.apiNursingLog.getRecord(data)
let res = await InstrumentInfo.apiNursingLog.getRecord(data);
if (res.data.code === 200) {
res.data.rows.map(item => {
item.nursingTime = this.getTime(item.nursingTime)
item.createTime = getdates(item.createTime).replace(/-/g, '.')
})
this.setState({ recordList: res.data.rows })
res.data.rows.map((item) => {
item.nursingTime = this.getTime(item.nursingTime);
item.createTime = getdates(item.createTime).replace(/-/g, ".");
});
this.setState({ recordList: res.data.rows });
}
}
// 查询用户当天最新的一条打卡记录
async getLatestClockRecord() {
let res = await InstrumentInfo.apiClock.getLatestClockRecord()
let res = await InstrumentInfo.apiClock.getLatestClockRecord();
if (res.data.code === 200) {
if (!res.data.data) {
this.setShow(true)
this.setShow(true);
} else {
let punchInInfo = {
clockImageList: res.data.data.clockImg,
clockContent: res.data.data.clockContent,
}
this.setState({ punchInInfo })
};
this.setState({ punchInInfo });
}
}
}
@ -113,34 +122,34 @@ export default class Recording extends Component<any, any> {
online: 1,
modeId: 100,
modeName: "护理记录测试",
nursingTime: "00:15:00"
}
nursingTime: "00:15:00",
};
let res = await InstrumentInfo.apiNursingLog.addLog(data)
let res = await InstrumentInfo.apiNursingLog.addLog(data);
if (res.data.code === 200) {
}
}
/**分页获取用户的打卡记录 page size*/
async getClockStatistics(year = this.state.year) {
let res = await InstrumentInfo.apiClock.getClockStatistics({ year })
let res = await InstrumentInfo.apiClock.getClockStatistics({ year });
if (res.data.code === 200) {
res.data.data.reverse()
res.data.data.reverse();
if (res.data.data.length > 0) {
res.data.data.map((item, index) => {
item.isMore = false
item.detail = []
item.isMore = false;
item.detail = [];
if (index === 0) {
item.isMore = true
this.getList(item.id, item.year, item.month)
item.isMore = true;
this.getList(item.id, item.year, item.month);
}
this.state.monthTime.map(monthItem => {
this.state.monthTime.map((monthItem) => {
if (monthItem.month == item.month) {
monthItem.time = item.clockNum
monthItem.time = item.clockNum;
}
})
})
this.setState({ monthTime: this.state.monthTime })
});
});
this.setState({ monthTime: this.state.monthTime });
} else {
let monthTime = [
{ month: 1, time: 0 },
@ -155,87 +164,86 @@ export default class Recording extends Component<any, any> {
{ month: 10, time: 0 },
{ month: 11, time: 0 },
{ month: 12, time: 0 },
]
this.setState({ monthTime })
];
this.setState({ monthTime });
}
this.setState({ clockStatistics: res.data.data })
this.setState({ clockStatistics: res.data.data });
}
}
// 文本框输入文字
handleTextareaInput(e) {
const punchInInfo = this.state.punchInInfo
punchInInfo.clockContent = e.detail.value
this.setState({ punchInInfo })
const punchInInfo = this.state.punchInInfo;
punchInInfo.clockContent = e.detail.value;
this.setState({ punchInInfo });
}
// 打开/关闭弹窗
setShow(show: boolean) {
this.setState({ show })
this.setState({ show });
}
// 选择仪器
onChangeProduct(id) {
this.setState({ curIndex: id })
this.getRecord(id)
this.addLog()
};
this.setState({ curIndex: id });
this.getRecord(id);
this.addLog();
}
// 展开收起
onChangeMore(id, year, month) {
this.state.clockStatistics.map(item => {
this.state.clockStatistics.map((item) => {
if (item.id === id) {
item.isMore = !item.isMore
item.isMore = !item.isMore;
if (item.isMore && item.detail.length === 0) {
this.getList(id, year, month)
this.getList(id, year, month);
}
}
})
this.setState({ clockStatistics: this.state.clockStatistics })
});
this.setState({ clockStatistics: this.state.clockStatistics });
}
// 获取当月打卡记录
async getList(id, year, month) {
let data = {
year, month
}
let res = await InstrumentInfo.apiClock.getList(data)
year,
month,
};
let res = await InstrumentInfo.apiClock.getList(data);
if (res.data.code === 200) {
console.log(this.state.clockStatistics, 88888);
this.state.clockStatistics.map(item => {
this.state.clockStatistics.map((item) => {
if (item.id === id) {
item.detail = res.data.data
item.detail.map(obj => {
obj.updateTime = getdates(obj.updateTime).replace(/-/g, '.')
})
item.detail = res.data.data;
item.detail.map((obj) => {
obj.updateTime = getdates(obj.updateTime).replace(/-/g, ".");
});
}
})
this.setState({ clockStatistics: this.state.clockStatistics })
});
this.setState({ clockStatistics: this.state.clockStatistics });
}
}
async onLoad() {
this.getRecord(null)
this.getBindingInstrumentList()
this.getLatestClockRecord()
this.getClockStatistics()
this.getRecord(null);
this.getBindingInstrumentList();
this.getLatestClockRecord();
this.getClockStatistics();
}
componentDidShow() { }
componentDidShow() {}
componentDidHide() { }
componentDidHide() {}
async initData() { }
async initData() {}
// 选择年份
onChangeYear(event) {
this.setState({ year: event.detail.value })
this.getClockStatistics(event.detail.value)
this.setState({ year: event.detail.value });
this.getClockStatistics(event.detail.value);
}
// 点击tab栏
onTab = async (event) => {
const { current } = event.currentTarget.dataset;
this.setState({ current });
if (current === 1) {
this.getClockStatistics()
this.getClockStatistics();
}
};
// 跳转到护理报告
@ -246,72 +254,87 @@ export default class Recording extends Component<any, any> {
handleChooseImage() {
Taro.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
mediaType: ["image"],
sourceType: ["album", "camera"],
success: (res) => {
const tempFilePaths = res.tempFiles.map((item) => item.tempFilePath)
const tempFilePaths = res.tempFiles.map((item) => item.tempFilePath);
tempFilePaths?.forEach((item) => {
// eslint-disable-next-line @typescript-eslint/no-shadow
InstrumentInfo.apiClock.clockFileUpload({ clockImg: item }).then((res) => {
const currentImage = res.data.url
const newImageList =
this.state.punchInInfo.clockImageList.length >= 3
? this.state.punchInInfo.clockImageList
: [... this.state.punchInInfo.clockImageList, currentImage]
const punchInInfo = this.state.punchInInfo
punchInInfo.clockImageList = newImageList
this.setState({ punchInInfo })
})
})
InstrumentInfo.apiClock
.clockFileUpload({ clockImg: item })
.then((res) => {
const currentImage = res.data.url;
const newImageList =
this.state.punchInInfo.clockImageList.length >= 3
? this.state.punchInInfo.clockImageList
: [...this.state.punchInInfo.clockImageList, currentImage];
const punchInInfo = this.state.punchInInfo;
punchInInfo.clockImageList = newImageList;
this.setState({ punchInInfo });
});
});
},
fail: (err) => {
console.info('err', err)
console.info("err", err);
},
})
});
}
// 删除打卡图片
delImg(i) {
const punchInInfo = this.state.punchInInfo
punchInInfo.clockImageList.splice(i, 1)
this.setState({ punchInInfo })
const punchInInfo = this.state.punchInInfo;
punchInInfo.clockImageList.splice(i, 1);
this.setState({ punchInInfo });
}
async submit() {
let punchInInfo = this.state.punchInInfo || {}
let punchInInfo = this.state.punchInInfo || {};
if (!punchInInfo.clockImageList.length) {
Taro.showToast({
title: '请上传图片',
icon: 'none',
})
return
title: "请上传图片",
icon: "none",
});
return;
}
if (!punchInInfo.clockContent) {
Taro.showToast({
title: '请输入打卡心得',
icon: 'none',
})
return
title: "请输入打卡心得",
icon: "none",
});
return;
}
InstrumentInfo.apiClock.postInsertClockLog(punchInInfo).then((res) => {
showModal({
t2: '您已完成今日打卡',
t2: "您已完成今日打卡",
btn1show: false,
}).then(() => {
this.setShow(false)
})
})
this.setShow(false);
});
});
}
back() {
Taro.navigateBack({
delta: 1,
})
});
}
render() {
let { current, array, name, recordList, bindingInstrumentList, curIndex, clockStatistics, statistics, year, today, monthTime, show, punchInInfo } = this.state;
let {
current,
array,
name,
recordList,
bindingInstrumentList,
curIndex,
clockStatistics,
statistics,
year,
today,
monthTime,
show,
punchInInfo,
} = this.state;
return (
<Block>
<Navbar isBack titleSlot='护理记录'></Navbar>
<View className='tabs'>
<Navbar isBack titleSlot="护理记录"></Navbar>
<View className="tabs">
<View
className={classnames("tab", {
tab_active: current === 0,
@ -331,42 +354,48 @@ export default class Recording extends Component<any, any> {
</View>
</View>
{current === 0 && <ScrollView className='products_list' scroll-x='true' >
<View className={classnames("all", {
products_item_active: !curIndex,
})} onClick={this.onChangeProduct.bind(this, null)}
>
</View>
{bindingInstrumentList.map((item: any, index: any) => (
<View key={item.id}
className={classnames("products_item", {
products_item_active: curIndex === item.id,
{current === 0 && (
<ScrollView className="products_list" scroll-x="true">
<View
className={classnames("all", {
products_item_active: !curIndex,
})}
onClick={this.onChangeProduct.bind(this, item.id)}
onClick={this.onChangeProduct.bind(this, null)}
>
<Image className='products_cover'
src={require("../../img/test/1706692819894.jpg")} mode='aspectFit'
></Image>
<View className='products_title'></View>
</View>
))}
</ScrollView>}
{current === 0 &&
recordList.length ===
0 && (
<View>
<View className='nodata'>
{bindingInstrumentList.map((item: any, index: any) => (
<View
key={item.id}
className={classnames("products_item", {
products_item_active: curIndex === item.id,
})}
onClick={this.onChangeProduct.bind(this, item.id)}
>
<Image
className='nodata_img'
src={require("../../img/nodata.png")}
className="products_cover"
src={require("../../img/test/1706692819894.jpg")}
mode="aspectFit"
></Image>
<View className='nodata_text'></View>
<View className="products_title"></View>
</View>
))}
</ScrollView>
)}
{current === 0 && recordList.length === 0 && (
<View>
<View className="nodata">
<Image
className="nodata_img"
src={require("../../img/nodata.png")}
></Image>
<View className="nodata_text"></View>
</View>
)}
</View>
)}
{current === 0 && (
<View style='padding-bottom:200px'>
<View style="padding-bottom:200px">
{/* <View className='instrument_item' >
<View className='instrument_top flex sb aitems'>
<View className='time_box flex aitems'>
@ -393,35 +422,50 @@ export default class Recording extends Component<any, any> {
</View>
</View> */}
<View className='instrument_list '>
<View className="instrument_list ">
{recordList.map((item: any, index: any) => (
<View className='recording-box' key={item.id}>
<View className='box-top'>
<View className='top-left'>
<View className='date'>{item.createTime}</View>
<View className={classnames("tip", {
tag_active: item.online === 2,
})}
>{item.online ? '在线' : '离线'}</View>
<View className="recording-box" key={item.id}>
<View className="box-top">
<View className="top-left">
<View className="date">{item.createTime}</View>
<View
className={classnames("tip", {
tag_active: item.online === 2,
})}
>
{item.online ? "在线" : "离线"}
</View>
</View>
{item.instrumentType === 2 &&
<View className='top-right' onClick={this.toReport.bind(this, item.instrumentId, item.id)}>
{item.instrumentType === 2 && (
<View
className="top-right"
onClick={this.toReport.bind(
this,
item.instrumentId,
item.id
)}
>
<Image className='arrow_icon' src={require("../../img/index/right.png")} mode='aspectFill'></Image>
<Image
className="arrow_icon"
src={require("../../img/index/right.png")}
mode="aspectFill"
></Image>
</View>
}
)}
</View>
<View className='box-bottom'>
<View className="box-bottom">
<Image
className='recording_img'
className="recording_img"
src={item.modeImage}
></Image>
<View className='bottom-right'>
<View className='title'>{item.instrumentName}</View>
<View className='subtitle-box'>
<View className='subtitle'>{item.modeName}</View>
<View className='subtitle'>{item.nursingTime}</View>
<View className="bottom-right">
<View className="title">{item.instrumentName}</View>
<View className="subtitle-box">
<View className="subtitle">{item.modeName}</View>
<View className="subtitle">
{item.nursingTime}
</View>
</View>
</View>
</View>
@ -431,7 +475,7 @@ export default class Recording extends Component<any, any> {
</View>
)}
{current === 1 && (
<View style='padding-bottom:200px'>
<View style="padding-bottom:200px">
{/* <View className='nodata'>
<Image
className='nodata_img'
@ -439,139 +483,198 @@ export default class Recording extends Component<any, any> {
></Image>
<View className='nodata_text'></View>
</View> */}
<View style='height: 30rpx; background: #F8F8F8'></View>
<View className='clock_in_statistics m-x-30 flex sb'>
<View className='flex sb ab'>
<View className='clock_in_statistics_title'></View>
<Picker mode='date' fields='year' onChange={this.onChangeYear.bind(this)} value='{{year}}' end='{{today}}'>
<View className='clock_in_statistics_date flex aitems'>
<View style="height: 30rpx; background: #F8F8F8"></View>
<View className="clock_in_statistics m-x-30 flex sb">
<View className="flex sb ab">
<View className="clock_in_statistics_title"></View>
<Picker
mode="date"
fields="year"
onChange={this.onChangeYear.bind(this)}
value="{{year}}"
end="{{today}}"
>
<View className="clock_in_statistics_date flex aitems">
<View>{year}</View>
<Image className='more_icon' src={require('../../img/arrow-down.png')} mode='widthFix'></Image>
<Image
className="more_icon"
src={require("../../img/arrow-down.png")}
mode="widthFix"
></Image>
</View>
</Picker>
</View>
<View className='chart flex sb'>
{
monthTime.map(item => (
<View className='flex fc aitems' key={item.month}>
{
item.time > 0 && <View className='buoy' >{item.time}</View>
}
<View className='column' style={{ height: `calc(186/31*${item.time}rpx)` }}></View>
<View className='month'>{item.month}</View>
</View>
))
}
<View className="chart flex sb">
{monthTime.map((item) => (
<View className="flex fc aitems" key={item.month}>
{item.time > 0 && (
<View className="buoy">{item.time}</View>
)}
<View
className="column"
style={{ height: `calc(186/31*${item.time}rpx)` }}
></View>
<View className="month">{item.month}</View>
</View>
))}
</View>
</View>
<View style='padding-bottom: env(safe-area-inset-bottom)' >
<View className='month_box m-x-30'>
{clockStatistics.map(item => (
<View className='month_statistics' key={item.id}>
<View className='flex aitems sb'>
<View className='time'>{item.year}{item.month}</View>
<View className='more_box flex aitems' onClick={this.onChangeMore.bind(this, item.id, item.year, item.month)}>
<View className='more_text'> {!item.isMore ? '展开更多' : '收起更多'}</View>
<Image style={{ transform: (item.isMore) ? 'rotate(180deg)' : 'rotate(0deg)' }} className='more_icon'
src={require("../../img/arrow-down.png")} mode='widthFix'
<View style="padding-bottom: env(safe-area-inset-bottom)">
<View className="month_box m-x-30">
{clockStatistics.map((item) => (
<View className="month_statistics" key={item.id}>
<View className="flex aitems sb">
<View className="time">
{item.year}{item.month}
</View>
<View
className="more_box flex aitems"
onClick={this.onChangeMore.bind(
this,
item.id,
item.year,
item.month
)}
>
<View className="more_text">
{" "}
{!item.isMore ? "展开更多" : "收起更多"}
</View>
<Image
style={{
transform: item.isMore
? "rotate(180deg)"
: "rotate(0deg)",
}}
className="more_icon"
src={require("../../img/arrow-down.png")}
mode="widthFix"
></Image>
</View>
</View>
<View style='height: 59rpx'></View>
<View className='statistic'>
<View className='statistic_item'>
<View className='statistic_num'>{item.clockNum}</View>
<View className='statistic_desc'></View>
<View style="height: 59rpx"></View>
<View className="statistic">
<View className="statistic_item">
<View className="statistic_num">{item.clockNum}</View>
<View className="statistic_desc"></View>
</View>
<View className='statistic_item'>
<View className='statistic_num'>{(item.percentage * 100).toFixed(2)}%</View>
<View className='statistic_desc'></View>
<View className="statistic_item">
<View className="statistic_num">
{(item.percentage * 100).toFixed(2)}%
</View>
<View className="statistic_desc"></View>
</View>
<View className='border'></View>
<View className="border"></View>
</View>
{item.isMore && item.detail && <View>
{
item.detail.map(obj => (
{item.isMore && item.detail && (
<View>
{item.detail.map((obj) => (
<View key={obj}>
<View style='height: 57rpx' ></View>
<View className='month_item'>
<View className='month_item_date'>{obj.updateTime}</View>
<View className='month_image_box flex sb'>
{obj.clockImg.map(img => (<Image key={img} className='month_item_cover' src={img} ></Image>))}
<View style="height: 57rpx"></View>
<View className="month_item">
<View className="month_item_date">
{obj.updateTime}
</View>
<View className="month_image_box flex sb">
{obj.clockImg.map((img) => (
<Image
key={img}
className="month_item_cover"
src={img}
></Image>
))}
</View>
<View className="month_item_date">
PRO{" "}
</View>
<View className="month_item_note">
{obj.clockContent}
</View>
<View className='month_item_date'>PRO </View>
<View className='month_item_note'>{obj.clockContent}</View>
</View>
</View>))}
</View>
}
</View>
))}
</View>
)}
</View>
))
}
))}
</View>
</View>
</View>
)
}
<View className='footer flex aitems' >
<View className='btn' onClick={this.setShow.bind(this, true)}></View>
)}
<View className="footer flex aitems">
<View className="btn" onClick={this.setShow.bind(this, true)}>
</View>
<View className="text" onClick={this.back}>
>
&gt;
</View>
</View>
<Popup show={show} onClose={() => this.setState({ show: false })}>
<View className='popBox'>
<Image className='close_icon'
src={require("../../img/close.png")} mode='widthFix' onClick={this.setShow.bind(this, false)}
<View className="popBox">
<Image
className="close_icon"
src={require("../../img/close.png")}
mode="widthFix"
onClick={this.setShow.bind(this, false)}
></Image>
<View className='popTitle'></View>
<View className='popSubtitle'><View className='bold'>{clockStatistics[0]?.clockNum}</View> <View className='bold'>{(clockStatistics[0]?.percentage * 100).toFixed(1)}%</View></View>
<View className='img_box'>
{
punchInInfo.clockImageList.map((item, index) => (
<View key={item} className='img'>
<Image className='showImg'
src={item} mode='widthFix'
></Image>
<Image className='closeImg'
src={require('../../img/close1.png')}
mode='widthFix'
onClick={this.delImg.bind(this, index)}
></Image>
</View>
))
}
{punchInInfo.clockImageList.length < 3 &&
<View className='addBox' onClick={this.handleChooseImage.bind(this)}>
<Image className='showImg'
src={require("../../img/clock_in_upload/add-image.png")} mode='widthFix'
<View className="popTitle"></View>
<View className="popSubtitle">
<View className="bold">{clockStatistics[0]?.clockNum}</View>{" "}
<View className="bold">
{(clockStatistics[0]?.percentage * 100).toFixed(1)}%
</View>
</View>
<View className="img_box">
{punchInInfo.clockImageList.map((item, index) => (
<View key={item} className="img">
<Image className="showImg" src={item} mode="widthFix"></Image>
<Image
className="closeImg"
src={require("../../img/close1.png")}
mode="widthFix"
onClick={this.delImg.bind(this, index)}
></Image>
</View>
))}
{punchInInfo.clockImageList.length < 3 && (
<View
className="addBox"
onClick={this.handleChooseImage.bind(this)}
>
<Image
className="showImg"
src={require("../../img/clock_in_upload/add-image.png")}
mode="widthFix"
></Image>
</View>
}
)}
</View>
<View className='info4'>
<View className='content'>
<View className="info4">
<View className="content">
<Textarea
placeholderStyle='color: #ccc; font-size: 26rpx;font-weight: 400;font-family: PingFang SC;'
placeholder='请记录一下今天的护理心得吧'
placeholderStyle="color: #ccc; font-size: 26rpx;font-weight: 400;font-family: PingFang SC;"
placeholder="请记录一下今天的护理心得吧"
maxlength={120}
onInput={this.handleTextareaInput.bind(this)}
value={punchInInfo.clockContent}
></Textarea>
</View>
<View className='tip'>
{'' + (punchInInfo.clockContent.length || 0) + '/120'}
<View className="tip">
{"" + (punchInInfo.clockContent.length || 0) + "/120"}
</View>
</View>
<View className='popbtnbox flex aitems jcenter'>
<View className='btn1' onClick={this.submit.bind(this)}>
<View className="popbtnbox flex aitems jcenter">
<View className="btn1" onClick={this.submit.bind(this)}>
</View>
</View>
</View>
</Popup>
</Block >
</Block>
);
}
}
}

@ -40,7 +40,6 @@ class Register extends Component<any, any> {
// isRead: true,
fromUrl: "",
serial: Taro.getStorageSync("serial"),
};
}
@ -59,7 +58,7 @@ class Register extends Component<any, any> {
back() {
Taro.navigateBack({
delta: 1,
})
});
}
onDisagreeTap = () => {
// 关闭小程序
@ -153,13 +152,13 @@ class Register extends Component<any, any> {
go("/pages/userPolicy/userPolicy");
};
componentDidMount() { }
componentDidMount() {}
componentWillUnmount() { }
componentWillUnmount() {}
componentDidShow() { }
componentDidShow() {}
componentDidHide() { }
componentDidHide() {}
async initData() {
const { data } = await MpSplashDetail({
@ -199,8 +198,8 @@ class Register extends Component<any, any> {
</View>
</View>
{
serial && <View className='footer1' >
{serial && (
<View className="footer1">
<Button
type="primary"
disabled={!isChecked || isButtonDisabled}
@ -212,13 +211,12 @@ class Register extends Component<any, any> {
</Button>
<View className="text" onClick={this.back}>
>
&gt;
</View>
</View>
}
{
!serial && <Button
)}
{!serial && (
<Button
type="primary"
disabled={!isChecked || isButtonDisabled}
open-type="getPhoneNumber"
@ -228,7 +226,7 @@ class Register extends Component<any, any> {
>
</Button>
}
)}
<View className="checked_box">
{isChecked ? (

Loading…
Cancel
Save