fix:修复横向滚动条切换item,页面数据刷新导致横向滚动闪动回初始位置问题

master
blak-kong 2 years ago
parent 722482e8dd
commit 30b227b892

@ -71,9 +71,11 @@ export default defineAppConfig({
navigationBarBackgroundColor: "#fff", navigationBarBackgroundColor: "#fff",
navigationBarTitleText: "WeChat", navigationBarTitleText: "WeChat",
navigationBarTextStyle: "black", navigationBarTextStyle: "black",
// pageOrientation: "auto",
// enablePullDownRefresh: true // enablePullDownRefresh: true
}, },
requiredPrivateInfos: ["getLocation"], requiredPrivateInfos: ["getLocation"],
subPackages: [ subPackages: [
{ {
root: "moduleIOT", root: "moduleIOT",

@ -204,7 +204,7 @@ export default class InstrumentManage extends Component<any, any> {
<Block> <Block>
<View className="title"></View> <View className="title"></View>
<View className="scroll"> <View className="scroll">
<ScrollView scroll-x="true" className="un_bind_list"> <ScrollView scrollX={true} className="un_bind_list">
{unBindList.map((item, index) => { {unBindList.map((item, index) => {
if (item.status === 0) { if (item.status === 0) {
return ( return (

@ -508,7 +508,8 @@ class IotCarePlanFR200 extends Component<any, any> {
currentWorkModeType = 3; currentWorkModeType = 3;
} else if ( } else if (
data.modeType === "maskPenetration" || data.modeType === "maskPenetration" ||
data.modeType === "essence" data.modeType === "essence" ||
data.modeType === "led"
) { ) {
currentWorkModeType = 2; currentWorkModeType = 2;
} }
@ -1598,12 +1599,11 @@ class IotCarePlanFR200 extends Component<any, any> {
executePromises = async () => { executePromises = async () => {
let waterStepList = this.state.waterStepList; let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex; let waterStepIndex = this.state.waterStepIndex;
let that =this let that = this;
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
setTimeout(() => { setTimeout(() => {
waterStepList[waterStepIndex].schedule = 100; waterStepList[waterStepIndex].schedule = 100;
that.setState({ that.setState({
waterStepList, waterStepList,
}); });
@ -1620,13 +1620,8 @@ class IotCarePlanFR200 extends Component<any, any> {
}, 2000); }, 2000);
}); });
}); });
}; };
// 检测并控制工作状态 // 检测并控制工作状态
handleWorkStatus = async (isBtnClick: boolean, workStatus) => { handleWorkStatus = async (isBtnClick: boolean, workStatus) => {
const { DeviceConnectStatus, ActiveModeItem } = this.state; const { DeviceConnectStatus, ActiveModeItem } = this.state;
@ -1656,20 +1651,22 @@ class IotCarePlanFR200 extends Component<any, any> {
sendParams.testStatus = "standby"; // 切换为准备 sendParams.testStatus = "standby"; // 切换为准备
// 3秒定时器逻辑3秒把进度条弄成100再加2秒获取最后结果 // 3秒定时器逻辑3秒把进度条弄成100再加2秒获取最后结果
if (isBtnClick) { if (isBtnClick) {
that.setState({ that.setState({
isRuningTest: 2, isRuningTest: 2,
}); });
this.executePromises() this.executePromises();
sendParams.testStatus = "start"; // 点击开始再开始 sendParams.testStatus = "start"; // 点击开始再开始
console.log("点击开始", isBtnClick); console.log("点击开始", isBtnClick);
} }
} }
if (ActiveModeItem.modeType === "maskPenetration") { // 面膜促渗和精华促渗
if (
ActiveModeItem.modeType === "maskPenetration" ||
ActiveModeItem.modeType === "essence"
) {
sendParams.gear = this.state.currentGear; // 点击开始再开始 sendParams.gear = this.state.currentGear; // 点击开始再开始
} }
@ -2120,7 +2117,12 @@ 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,
};
}; };
// 计算挡位 // 计算挡位
@ -2669,7 +2671,7 @@ class IotCarePlanFR200 extends Component<any, any> {
showFullscreenBtn={false} showFullscreenBtn={false}
onLoadedMetaData={this.GetVideosTime} onLoadedMetaData={this.GetVideosTime}
/> />
<button onClick={this.executePromises}></button> {/* <Button onClick={this.executePromises}>点击按钮</Button> */}
{errorTips && ( {errorTips && (
<Block> <Block>
<View className="msg-tips"> <View className="msg-tips">
@ -2683,6 +2685,7 @@ class IotCarePlanFR200 extends Component<any, any> {
)} )}
</View> </View>
{ActiveModeItem.modeType !== "moistureTest" && (
<View className="fr200-iot-device"> <View className="fr200-iot-device">
<View className="item"> <View className="item">
<Text className="device-time"> <Text className="device-time">
@ -2691,7 +2694,11 @@ class IotCarePlanFR200 extends Component<any, any> {
</View> </View>
<View className="line" /> <View className="line" />
<View className="item"> <View className="item">
<Text className="gear">{currentGear}</Text>
<Text className="gear">
{ActiveModeItem.modeType === "led" ? "-" : currentGear}
</Text>
</View> </View>
<View className="line" /> <View className="line" />
<ElectricityView <ElectricityView
@ -2699,6 +2706,7 @@ class IotCarePlanFR200 extends Component<any, any> {
DeviceConnectStatus={DeviceConnectStatus} DeviceConnectStatus={DeviceConnectStatus}
/> />
</View> </View>
)}
</View> </View>
{ModeList.length > 0 && ( {ModeList.length > 0 && (
@ -2714,8 +2722,8 @@ class IotCarePlanFR200 extends Component<any, any> {
onModeLockOpen={this.onModeLockOpen} onModeLockOpen={this.onModeLockOpen}
/> />
)} )}
<button onClick={this.look.bind(this)}>echarts </button> {/* <button onClick={this.look.bind(this)}>echarts </button>
<button onClick={this.updata.bind(this)}> </button> <button onClick={this.updata.bind(this)}> </button> */}
<View className={classnames({ show: showEcharts })}> <View className={classnames({ show: showEcharts })}>
<Echarts data={echartsData}></Echarts> <Echarts data={echartsData}></Echarts>

@ -9,7 +9,7 @@ interface Props {
onEmitStartNurse: Function; // 每次点击item回调事件和数据给父组件 onEmitStartNurse: Function; // 每次点击item回调事件和数据给父组件
onEmitSwitchChange: Function; onEmitSwitchChange: Function;
onEmitEndPlan: Function; onEmitEndPlan: Function;
onsuccess:Function onsuccess: Function;
} }
function Index({ function Index({
currentWorkModeType, currentWorkModeType,
@ -18,7 +18,7 @@ function Index({
onEmitStartNurse, onEmitStartNurse,
onEmitSwitchChange, onEmitSwitchChange,
onEmitEndPlan, onEmitEndPlan,
onsuccess onsuccess,
}: Props) { }: Props) {
const onStartNurse = () => { const onStartNurse = () => {
onEmitStartNurse(); onEmitStartNurse();
@ -31,6 +31,9 @@ function Index({
const onEndPlan = () => { const onEndPlan = () => {
onEmitEndPlan(); onEmitEndPlan();
}; };
const onSuccessNurse = () => {
onsuccess();
};
return ( return (
<Block> <Block>
@ -44,9 +47,13 @@ function Index({
) : isRuningTest === 2 ? ( ) : isRuningTest === 2 ? (
<View className="btn">...</View> <View className="btn">...</View>
) : isRuningTest === 3 ? ( ) : isRuningTest === 3 ? (
<View className="btn" onClick={onStartNurse}></View> <View className="btn" onClick={onStartNurse}>
</View>
) : ( ) : (
<View className="btn" onClick={onsuccess}></View> <View className="btn" onClick={onSuccessNurse}>
</View>
)} )}
</Block> </Block>
)} )}

@ -85,7 +85,9 @@ function Index({
<View className="mode-info"> <View className="mode-info">
<View className="mode-info-title">{item.modeName}</View> <View className="mode-info-title">{item.modeName}</View>
<View className="mode-info-time"> <View className="mode-info-time">
{item.modeTimeStr} {item.modeTimeStr === "00:00"
? "--:--"
: item.modeTimeStr}
</View> </View>
<View <View
className={classnames("mode-info-select", { className={classnames("mode-info-select", {

@ -1,4 +1,5 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '首页', navigationBarTitleText: '首页',
enablePullDownRefresh: false, enablePullDownRefresh: false,
enablePageMeta: true
}) })

@ -11,6 +11,7 @@ import {
Swiper, Swiper,
SwiperItem, SwiperItem,
RichText, RichText,
PageMeta,
} from "@tarojs/components"; } from "@tarojs/components";
import { Popup } from "@antmjs/vantui"; import { Popup } from "@antmjs/vantui";
/*** redux ***/ /*** redux ***/
@ -943,6 +944,10 @@ class Index extends Component<any, any> {
// return; // return;
} }
goTest() {
go("/pages/consultant/consultant");
}
//连接完成时数据的回调 //连接完成时数据的回调
offlineChange = async (e) => { offlineChange = async (e) => {
console.log("offlineChange", e); console.log("offlineChange", e);
@ -1122,6 +1127,7 @@ class Index extends Component<any, any> {
return ( return (
<Block> <Block>
{/* <PageMeta pageOrientation="landscape"> */}
<View catchMove> <View catchMove>
<PopupAlert <PopupAlert
isShow={isCommonError} isShow={isCommonError}
@ -1446,6 +1452,13 @@ class Index extends Component<any, any> {
<Popup show={show} className="custom-popup" overlay={false}> <Popup show={show} className="custom-popup" overlay={false}>
<View className="popBox"></View> <View className="popBox"></View>
</Popup> </Popup>
{/* </PageMeta> */}
{/* <View
style="position:fixed;width:100vw;height:100vh"
onClick={this.goTest}
>
</View> */}
</Block> </Block>
); );
} }

@ -1,5 +1,6 @@
import Taro, { setStorageSync } from "@tarojs/taro"; import Taro, { setStorageSync } from "@tarojs/taro";
import classnames from "classnames"; import classnames from "classnames";
import dayjs from "dayjs";
import { Component, PropsWithChildren, useEffect, useState } from "react"; import { Component, PropsWithChildren, useEffect, useState } from "react";
import { import {
@ -40,8 +41,11 @@ export default class Recording extends Component<any, any> {
curIndex: null, curIndex: null,
clockStatistics: [], clockStatistics: [],
statistics: [], statistics: [],
yearValue: dayjs().format("YYYY-MM-DD"),
year: new Date().getFullYear(), year: new Date().getFullYear(),
today: new Date(),
startYear: "2000-01-01",
endYear: dayjs().format("YYYY-MM-DD"),
monthTime: [ monthTime: [
{ month: 1, time: 0 }, { month: 1, time: 0 },
{ month: 2, time: 0 }, { month: 2, time: 0 },
@ -264,21 +268,31 @@ export default class Recording extends Component<any, any> {
ViewAddInstrument: ViewAddInstrument, ViewAddInstrument: ViewAddInstrument,
}); });
this.getRecord(null); this.initData();
this.getBindingInstrumentList();
this.getLatestClockRecord();
this.getClockStatistics();
this.DayTime();
this.setStatusBar();
} }
componentDidShow() {} componentDidShow() {}
componentDidHide() {} componentDidHide() {}
async initData() {} initData = async () => {
this.getRecord(null);
Taro.showLoading({
title: "请求中...",
mask: true,
});
await Promise.all([
this.getBindingInstrumentList(),
this.getLatestClockRecord(),
this.getClockStatistics(),
this.DayTime(),
this.setStatusBar(),
]);
Taro.hideLoading();
};
// 选择年份 // 选择年份
onChangeYear(event) { onChangeYear(event) {
console.log("event", event);
this.setState({ year: event.detail.value }); this.setState({ year: event.detail.value });
this.getClockStatistics(event.detail.value); this.getClockStatistics(event.detail.value);
} }
@ -510,12 +524,13 @@ export default class Recording extends Component<any, any> {
clockStatistics, clockStatistics,
statistics, statistics,
year, year,
today,
monthTime, monthTime,
show, show,
punchInInfo, punchInInfo,
navigationBarHeight, navigationBarHeight,
statusBarHeight, statusBarHeight,
startYear,
endYear,
} = this.state; } = this.state;
const statusBarHeightRpx = statusBarHeight * 2; const statusBarHeightRpx = statusBarHeight * 2;
const navigationBarHeightRpx = navigationBarHeight * 2; const navigationBarHeightRpx = navigationBarHeight * 2;
@ -549,16 +564,23 @@ export default class Recording extends Component<any, any> {
</View> </View>
</View> </View>
<View>
{current === 0 && ( {current === 0 && (
<Block>
<ScrollView <ScrollView
className="products_list" className="products_list"
scroll-x="true" scrollX={true}
enhanced={true}
bounces={false}
// scrollIntoView={"products_item_" + curIndex}
style={{ style={{
top: height + 110 + "rpx", top: height + 110 + "rpx",
position: "sticky", position: "sticky",
}} }}
> >
<View>
<View <View
id={"products_item_0"}
className={classnames("all", { className={classnames("all", {
products_item_active: !curIndex, products_item_active: !curIndex,
})} })}
@ -566,9 +588,11 @@ export default class Recording extends Component<any, any> {
> >
</View> </View>
{bindingInstrumentList.map((item: any, index: any) => ( {bindingInstrumentList.map((item: any, index: any) => {
return (
<View <View
key={item.id} key={item.id}
id={"products_item_" + item.id}
className={classnames("products_item", { className={classnames("products_item", {
products_item_active: curIndex === item.id, products_item_active: curIndex === item.id,
})} })}
@ -581,11 +605,12 @@ export default class Recording extends Component<any, any> {
></Image> ></Image>
<View className="products_title">{item.name}</View> <View className="products_title">{item.name}</View>
</View> </View>
))} );
})}
</View>
</ScrollView> </ScrollView>
)} <View>
{recordList.length === 0 && (
{current === 0 && recordList.length === 0 && (
<View> <View>
<View className="nodata"> <View className="nodata">
<Image <Image
@ -596,34 +621,8 @@ export default class Recording extends Component<any, any> {
</View> </View>
</View> </View>
)} )}
{current === 0 && ( {recordList.length > 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'>
<View className='time'>2024.1.23</View>
<View className={classnames("tag", {
tag_active: current === 1,
})}
> 线</View>
</View>
<View className='report_btn flex'>
<View></View>
<Image className='arrow_icon' src={require("../../img/index/right.png")} mode='aspectFill'></Image>
</View>
</View>
<View className='instrument_middle flex'>
<Image className='instrument_cover' src={require("../../img/test/1706667011027.jpg")}></Image>
<View className='instrument_content'>
<View className='instrument_title'></View>
<View className='instrument_desc_box flex fc sb'>
<View className='instrument_desc'></View>
<View className='instrument_desc'>1500</View>
</View>
</View>
</View>
</View> */}
<View className="instrument_list "> <View className="instrument_list ">
{recordList.map((item: any, index: any) => ( {recordList.map((item: any, index: any) => (
<View className="recording-box" key={item.id}> <View className="recording-box" key={item.id}>
@ -663,9 +662,13 @@ export default class Recording extends Component<any, any> {
src={item.modeImage} src={item.modeImage}
></Image> ></Image>
<View className="bottom-right"> <View className="bottom-right">
<View className="title">{item.instrumentName}</View> <View className="title">
{item.instrumentName}
</View>
<View className="subtitle-box"> <View className="subtitle-box">
<View className="subtitle">{item.modeName}</View> <View className="subtitle">
{item.modeName}
</View>
<View className="subtitle"> <View className="subtitle">
{item.instrumentType === 2 && ( {item.instrumentType === 2 && (
<Text>{item.nursingTime}</Text> <Text>{item.nursingTime}</Text>
@ -679,6 +682,10 @@ export default class Recording extends Component<any, any> {
</View> </View>
</View> </View>
)} )}
</View>
</Block>
)}
</View>
{current === 1 && ( {current === 1 && (
<View style="padding-bottom:200px"> <View style="padding-bottom:200px">
{/* <View className='nodata'> {/* <View className='nodata'>
@ -693,11 +700,13 @@ export default class Recording extends Component<any, any> {
<View className="flex sb ab"> <View className="flex sb ab">
<View className="clock_in_statistics_title"></View> <View className="clock_in_statistics_title"></View>
<Picker <Picker
style="color:#000"
mode="date" mode="date"
fields="year" fields="year"
onChange={this.onChangeYear.bind(this)} onChange={this.onChangeYear.bind(this)}
value="{{year}}" value={this.state.yearValue}
end="{{today}}" start={startYear}
end={endYear}
> >
<View className="clock_in_statistics_date flex aitems"> <View className="clock_in_statistics_date flex aitems">
<View>{year}</View> <View>{year}</View>

Loading…
Cancel
Save