代码优化,样式修改

master
qsj 2 years ago
parent 4c77ad357c
commit 041822f2dd

@ -718,8 +718,6 @@ class IotCarePlanFR200 extends Component<any, any> {
let gears: any = [] let gears: any = []
let eDate: any = [] let eDate: any = []
echartsData?.map(item => { echartsData?.map(item => {
console.log(item,'查看数据');
const result = item.createTime.split(' ')[0].substring(5); const result = item.createTime.split(' ')[0].substring(5);
eDate.push(result) eDate.push(result)
item.nursingData = JSON.parse(item.nursingData) item.nursingData = JSON.parse(item.nursingData)
@ -901,34 +899,32 @@ class IotCarePlanFR200 extends Component<any, any> {
if (jsonStatus.workMode === "moistureTest") { if (jsonStatus.workMode === "moistureTest") {
if ("success" === jsonStatus.testStatus) { if ("success" === jsonStatus.testStatus) {
let waterStepList = this.state.waterStepList; let waterStepList = this.state.waterStepList;
// 到达第几个step
let waterStepIndex = this.state.waterStepIndex; let waterStepIndex = this.state.waterStepIndex;
let timerIdSuccess = this.state.timerIdSuccess;
let timerIdSchedule = this.state.timerIdSchedule; // 代表5秒以后最后拿到的结果
if (waterStepList[waterStepIndex].finish) { if (waterStepList[waterStepIndex].finish) {
// 获取等级
waterStepList[waterStepIndex].forehead = waterStepList[waterStepIndex].forehead =
jsonStatus.waterLevel; jsonStatus.waterLevel;
// 检测完成
if (waterStepIndex === 2) { if (waterStepIndex === 2) {
this.setState({ this.setState({
isRuningTest: 4, isRuningTest: 4,
}); });
} else { } else {
// 启动检测
this.setState({ this.setState({
isRuningTest: 1, isRuningTest: 1,
}); });
} }
// 一共有3条数据
clearTimeout(timerIdSuccess);
clearTimeout(timerIdSchedule);
console.log("成功拿到", jsonStatus, waterStepIndex);
let num = waterStepIndex; let num = waterStepIndex;
if (waterStepIndex < 2) { if (waterStepIndex < 2) {
num = waterStepIndex + 1; num = waterStepIndex + 1;
this.waterTestNext(num) this.waterTestNext(num)
} }
this.setState({ this.setState({
timerIdSuccess: null,
timerIdSchedule: null,
waterStepIndex: num, waterStepIndex: num,
waterStepList, waterStepList,
}); });
@ -936,11 +932,9 @@ class IotCarePlanFR200 extends Component<any, any> {
} else { } else {
let waterStepList = this.state.waterStepList; let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex; let waterStepIndex = this.state.waterStepIndex;
let timerIdSuccess = this.state.timerIdSuccess; // 5秒后获取的结果
let timerIdSchedule = this.state.timerIdSchedule;
if (waterStepList[waterStepIndex].finish) { if (waterStepList[waterStepIndex].finish) {
clearTimeout(timerIdSuccess); // 获取失败后把进度条清理0
clearTimeout(timerIdSchedule);
waterStepList[waterStepIndex].schedule = 0; waterStepList[waterStepIndex].schedule = 0;
waterStepList[waterStepIndex].finish = false; waterStepList[waterStepIndex].finish = false;
this.setState({ this.setState({
@ -1584,8 +1578,40 @@ class IotCarePlanFR200 extends Component<any, any> {
}); });
}; };
executePromises = async () => {
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex;
let that =this
await new Promise<void>((resolve) => {
setTimeout(() => {
waterStepList[waterStepIndex].schedule = 100;
that.setState({
waterStepList,
});
resolve();
}, 3000);
}).then(() => {
return new Promise<void>((resolve) => {
setTimeout(() => {
waterStepList[waterStepIndex].finish = true;
that.setState({
waterStepList,
});
resolve();
}, 2000);
});
});
};
// 检测并控制工作状态 // 检测并控制工作状态
handleWorkStatus = (isBtnClick: boolean, workStatus) => { handleWorkStatus = async (isBtnClick: boolean, workStatus) => {
const { DeviceConnectStatus, ActiveModeItem } = this.state; const { DeviceConnectStatus, ActiveModeItem } = this.state;
let newWorkStatus = let newWorkStatus =
workStatus || workStatus ||
@ -1611,30 +1637,16 @@ class IotCarePlanFR200 extends Component<any, any> {
if (ActiveModeItem.modeType === "moistureTest") { if (ActiveModeItem.modeType === "moistureTest") {
let that = this let that = this
sendParams.testStatus = "standby"; // 切换为准备 sendParams.testStatus = "standby"; // 切换为准备
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex; // 3秒定时器逻辑3秒把进度条弄成100再加2秒获取最后结果
let timerIdSchedule = this.state.timerIdSchedule;
let timerIdSuccess = this.state.timerIdSuccess;
if (isBtnClick) {
timerIdSchedule = setTimeout(function () {
waterStepList[waterStepIndex].schedule = 100;
timerIdSuccess = setTimeout(function () { if (isBtnClick) {
waterStepList[waterStepIndex].finish = true;
that.setState({
waterStepList,
});
}, 2000);
that.setState({
waterStepList,
timerIdSuccess,
});
}, 3000);
that.setState({ that.setState({
isRuningTest: 2, isRuningTest: 2,
timerIdSchedule,
}); });
// 水分测试启动 this.executePromises()
sendParams.testStatus = "start"; // 点击开始再开始 sendParams.testStatus = "start"; // 点击开始再开始
console.log("点击开始", isBtnClick); console.log("点击开始", isBtnClick);
} }
@ -2089,7 +2101,7 @@ class IotCarePlanFR200 extends Component<any, any> {
return nursingData; return nursingData;
} }
return { nursingData: JSON.stringify({ workMode: nowFR200NursingHistory.workMode, }),showFace:true } return { nursingData: JSON.stringify({ workMode: nowFR200NursingHistory.workMode, }), showFace: true }
}; };
// 计算挡位 // 计算挡位
@ -2127,7 +2139,7 @@ class IotCarePlanFR200 extends Component<any, any> {
} }
let res1: any = await this.todoPromise(); let res1: any = await this.todoPromise();
if (!res1?.showFace) { if (!res1?.showFace) {
params = { ...params, ...res1 }; params = { ...params, ...res1 };
} }
console.log(res1, "查看返回数据"); console.log(res1, "查看返回数据");
@ -2634,7 +2646,7 @@ class IotCarePlanFR200 extends Component<any, any> {
showFullscreenBtn={false} showFullscreenBtn={false}
onLoadedMetaData={this.GetVideosTime} onLoadedMetaData={this.GetVideosTime}
/> />
<button onClick={this.executePromises}></button>
{errorTips && ( {errorTips && (
<Block> <Block>
<View className="msg-tips"> <View className="msg-tips">

@ -11,12 +11,12 @@
// padding-bottom: env(safe-area-inset-bottom); // padding-bottom: env(safe-area-inset-bottom);
box-sizing: border-box; box-sizing: border-box;
.btn { .btn {
width: 690rpx; width: 695rpx;
height: 90rpx; height: 75rpx;
background: #000; background: #000;
border-radius: 45rpx; border-radius: 45rpx;
color: #fff; color: #fff;
line-height: 90rpx; line-height: 75rpx;
text-align: center; text-align: center;
margin: 21rpx 49rpx 42rpx 30rpx; margin: 21rpx 49rpx 42rpx 30rpx;
font-size: 32rpx; font-size: 32rpx;

@ -211,8 +211,7 @@ export default class Index extends Component<any, any> {
}; };
let res = await InstrumentInfo.apiClock.getList(data); let res = await InstrumentInfo.apiClock.getList(data);
if (res.data.code === 200) { 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) { if (item.id === id) {
item.detail = res.data.data; item.detail = res.data.data;
@ -293,7 +292,6 @@ export default class Index extends Component<any, any> {
init(options){ init(options){
let obj =JSON.parse(options.obj) let obj =JSON.parse(options.obj)
console.log(obj,'obj111111111111111');
let recordData =this.state.recordData let recordData =this.state.recordData
let modeImage =this.state.modeImage let modeImage =this.state.modeImage

@ -480,13 +480,13 @@ page {
} }
.btn { .btn {
width: 540rpx; width: 695rpx;
height: 90rpx; height: 75rpx;
background: #000000; background: #000000;
border-radius: 45rpx; border-radius: 45rpx;
color: #fff; color: #fff;
text-align: center; text-align: center;
line-height: 90rpx; line-height: 75rpx;
font-weight: bold; font-weight: bold;
font-size: 32rpx; font-size: 32rpx;
} }

@ -357,8 +357,6 @@ export default class Recording extends Component<any, any> {
instrumentId: allData.instrumentId instrumentId: allData.instrumentId
} }
let res = await InstrumentInfo.fr200.moistureTest(data); let res = await InstrumentInfo.fr200.moistureTest(data);
console.log(res,'查看返回数据');
let echartsData = res.data.rows let echartsData = res.data.rows
for (let i = 0; i < echartsData.length; i++) { for (let i = 0; i < echartsData.length; i++) {
for (let j = i + 1; j < echartsData.length; j++) { for (let j = i + 1; j < echartsData.length; j++) {
@ -374,10 +372,8 @@ export default class Recording extends Component<any, any> {
} }
let gears: any = [] let gears: any = []
let eDate: any = [] let eDate: any = []
console.log(echartsData,'echartsDataechartsData');
echartsData.map(item => { echartsData.map(item => {
const result = item.createTime.split(' ')[0].substring(5); const result = item.createTime.split(' ')[0].substring(5);
eDate.push(result) eDate.push(result)
item.nursingData = JSON.parse(item.nursingData) item.nursingData = JSON.parse(item.nursingData)

Loading…
Cancel
Save