非iot设备的lock状态

master
blak-kong 2 years ago
parent b9563350a5
commit 29b59c23f2

@ -586,6 +586,10 @@ class Index extends Component<any, any> {
this.alertRegister(); this.alertRegister();
return false; return false;
} }
setTimeout(() => {
go("/pages/instrumentClickinUpload/index");
}, 10);
return;
if (this.state.connectInstrument.type === 1) { if (this.state.connectInstrument.type === 1) {
//非IOT //非IOT
setTimeout(() => { setTimeout(() => {

@ -217,6 +217,11 @@ page {
height: 100%; height: 100%;
flex-direction: column; flex-direction: column;
width: 134rpx; width: 134rpx;
.icon {
width: 30rpx;
height: 30rpx;
margin-top: 15rpx;
}
} }
} }
.info1_img { .info1_img {
@ -253,7 +258,7 @@ page {
background-color: #fff; background-color: #fff;
border-color: #fff; border-color: #fff;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.quan2 { .quan2 {
border-radius: 50%; border-radius: 50%;

@ -26,7 +26,6 @@ import { setStorageSync, getStorageSync, msg } from "@/utils/traoAPI";
import "./index.less"; import "./index.less";
export default class InstrumentClickInUpload extends Component<any, any> { export default class InstrumentClickInUpload extends Component<any, any> {
constructor(props) { constructor(props) {
super(props); super(props);
@ -90,7 +89,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
} }
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
const id = searchParams.get('id'); const id = searchParams.get("id");
setTimeout(() => { setTimeout(() => {
this.firstNurseInfo(); this.firstNurseInfo();
@ -303,113 +302,119 @@ export default class InstrumentClickInUpload extends Component<any, any> {
} = this.state; } = this.state;
return ( return (
<Block> <Block>
<Navbar titleSlot='打卡上传' isBack /> <Navbar titleSlot="打卡上传" isBack />
<Canvas <Canvas
style='height: 0' style="height: 0"
id='compressImage' id="compressImage"
canvasId='compressImage' canvasId="compressImage"
type='2d' type="2d"
></Canvas> ></Canvas>
<PopupAlert <PopupAlert
isShow={isModeLock} isShow={isModeLock}
title='提示' title="提示"
content='该模式即将上线,敬请期待' content="该模式即将上线,敬请期待"
confirmButtonText='知道了' confirmButtonText="知道了"
textAlgin='center' textAlgin="center"
isClose={false} isClose={false}
close={this.onModeLockClose} close={this.onModeLockClose}
confirm={this.onModeLockClose} confirm={this.onModeLockClose}
/> />
<PopupInstrumentUploadTips <PopupInstrumentUploadTips
isShow={isTipShow} isShow={isTipShow}
title='打卡介绍' title="打卡介绍"
data={nurseInfo} data={nurseInfo}
close={this.onTipShowClose} close={this.onTipShowClose}
confirm={this.onTipShowClose} confirm={this.onTipShowClose}
/> />
<View className='infobox1 flex aitems jcenter'> <View className="infobox1 flex aitems jcenter">
<View className='img'> <View className="img">
<Video <Video
src={currentInfo.modeVideo} src={currentInfo.modeVideo}
id='myVideo' id="myVideo"
enableProgressGesture={false} enableProgressGesture={false}
controls controls
// autoplay={false} // autoplay={false}
direction={0} direction={0}
loop={false} loop={false}
showMuteBtn showMuteBtn
referrerPolicy='origin' referrerPolicy="origin"
onTimeUpdate={this.videoBindTimeUpdate} onTimeUpdate={this.videoBindTimeUpdate}
onEnded={this.videoEnded} onEnded={this.videoEnded}
onPause={this.videoPause} onPause={this.videoPause}
onPlay={this.videoPlay} onPlay={this.videoPlay}
showCenterPlayBtn={false} showCenterPlayBtn={false}
onLoadedMetaData={this.videoLoadedMetaData} onLoadedMetaData={this.videoLoadedMetaData}
style='width: 100%; height: 100%;border-radius: 30rpx;' style="width: 100%; height: 100%;border-radius: 30rpx;"
/> />
{showVideoPlayBtn && ( {showVideoPlayBtn && (
<View className='video-cover'> <View className="video-cover">
<Image <Image
className='video-cover-icon' className="video-cover-icon"
src={require("../../img/fr200/play.png")} src={require("../../img/fr200/play.png")}
onClick={this.onPlayTap} onClick={this.onPlayTap}
></Image> ></Image>
{duration && ( {duration && (
<View className='video-cover-time'>{duration}</View> <View className="video-cover-time">{duration}</View>
)} )}
</View> </View>
)} )}
</View> </View>
</View> </View>
<View className='infobox3'> <View className="infobox3">
<ScrollView <ScrollView
style='white-space: nowrap; height: 100%;' style="white-space: nowrap; height: 100%;"
scroll-x scroll-x
scroll-left={scrollleft} scroll-left={scrollleft}
> >
{modeInfo.map((item, index) => { {modeInfo.map((item, index) => {
return ( return (
<View <View
className='info1' className="info1"
onClick={this.bindMoshi.bind(this, index)} onClick={this.bindMoshi.bind(this, index)}
key={index} key={index}
> >
<View <View
className='flex aitems modebox' className="flex aitems modebox"
style={{height: '100%', background: zkmoshiindex == index ?'linear-gradient(90deg, #EFDCC2, #FFF2DF)': ''}} style={{
height: "100%",
background:
zkmoshiindex == index
? "linear-gradient(90deg, #EFDCC2, #FFF2DF)"
: "",
}}
> >
<View className='block1'> <View className="block1">
<View <View
className='block1_1 flex aitems ' className="block1_1 flex aitems "
style='min-width: 80rpx' style="min-width: 80rpx"
> >
<View className='tip1'>{item.modeName}</View> <View className="tip1">{item.modeName}</View>
<View className='tip2'>{item.modeDesc}</View> <View className="tip2">{item.modeDesc}</View>
{!item.lock && zkmoshiindex !== index && ( {!item.lock && zkmoshiindex !== index && (
<View className='quan1'></View> <View className="quan1"></View>
)} )}
{!item.lock && zkmoshiindex == index && ( {!item.lock && zkmoshiindex == index && (
<View className='quan1 is-select flex aitems jcenter'> <View className="quan1 is-select flex aitems jcenter">
<View className='quan2'></View> <View className="quan2"></View>
</View> </View>
)} )}
{item.lock && ( {item.lock && (
<View className='icon'> <View className="icon">
<Image <Image
src='/img/fr200/suo.png' src={require("../../img/fr200/suo.png")}
mode='aspectFill' mode="aspectFill"
></Image> ></Image>
</View> </View>
)} )}
</View> </View>
</View> </View>
{item.modeBanner && index == zkmoshiindex &&( {item.modeBanner && index == zkmoshiindex && (
<View className='info1_img'> <View className="info1_img">
<Image src={item.modeBanner} mode='aspectFill' /> <Image src={item.modeBanner} mode="aspectFill" />
</View> </View>
)} )}
</View> </View>
@ -419,32 +424,32 @@ export default class InstrumentClickInUpload extends Component<any, any> {
</ScrollView> </ScrollView>
</View> </View>
<View className='infobox2'> <View className="infobox2">
<View className='infobox2_info'> <View className="infobox2_info">
<View className='info4'> <View className="info4">
<View className='upload_header flex aitems sb'> <View className="upload_header flex aitems sb">
<View className='upload_title'></View> <View className="upload_title"></View>
<View className='icon' onClick={this.onTipShowOpen}> <View className="icon" onClick={this.onTipShowOpen}>
<Image <Image
src={require("../../img/clock_in_upload/info.png")} src={require("../../img/clock_in_upload/info.png")}
mode='aspectFill' mode="aspectFill"
></Image> ></Image>
</View> </View>
</View> </View>
<View className='imgbox flex aitems'> <View className="imgbox flex aitems">
{punchInInfo.clockImageList.length > 0 && {punchInInfo.clockImageList.length > 0 &&
punchInInfo.clockImageList.map((item, index) => { punchInInfo.clockImageList.map((item, index) => {
return ( return (
<View className='img' key={"clickin_" + index}> <View className="img" key={"clickin_" + index}>
<Image src={item}></Image> <Image src={item}></Image>
<View <View
className='close flex aitems jcenter' className="close flex aitems jcenter"
data-index='{{index}}' data-index={index}
onClick={this.handleDeleteImage} onClick={this.handleDeleteImage}
> >
<Image <Image
src={require("../../img/fr200/close_white.png")} src={require("../../img/fr200/close_white.png")}
mode='widthFix' mode="widthFix"
></Image> ></Image>
</View> </View>
</View> </View>
@ -453,23 +458,23 @@ export default class InstrumentClickInUpload extends Component<any, any> {
{punchInInfo.clockImageList.length < 3 && ( {punchInInfo.clockImageList.length < 3 && (
<View <View
className='img2 flex aitems jcenter' className="img2 flex aitems jcenter"
onClick={this.handleChooseImage} onClick={this.handleChooseImage}
> >
<Image <Image
src={require("../../img/fr200/add-Image.png")} src={require("../../img/fr200/add-Image.png")}
mode='aspectFill' mode="aspectFill"
></Image> ></Image>
</View> </View>
)} )}
</View> </View>
<View className='content'> <View className="content">
<Textarea <Textarea
placeholder-className='placeholder' placeholder-className="placeholder"
maxlength={100} maxlength={100}
onInput={this.handleTextareaInput} onInput={this.handleTextareaInput}
value={punchInInfo.clockContent} value={punchInInfo.clockContent}
placeholder='请记录一下今天打卡的心得吧~' placeholder="请记录一下今天打卡的心得吧~"
></Textarea> ></Textarea>
{/* {tipshow && ( {/* {tipshow && (
<View className="Textarea"> <View className="Textarea">
@ -478,7 +483,7 @@ export default class InstrumentClickInUpload extends Component<any, any> {
: "请记录一下今天打卡的心得吧~"} : "请记录一下今天打卡的心得吧~"}
</View> </View>
)} */} )} */}
<View className='tips-num'> <View className="tips-num">
{punchInInfo.clockContent.length}/100 {punchInInfo.clockContent.length}/100
</View> </View>
</View> </View>
@ -486,16 +491,16 @@ export default class InstrumentClickInUpload extends Component<any, any> {
</View> </View>
</View> </View>
<View style='height: 150rpx'></View> <View style="height: 150rpx"></View>
{!isSubmit && ( {!isSubmit && (
<View className='confirm_btn flex aitems' onClick={this.handleSubmit}> <View className="confirm_btn flex aitems" onClick={this.handleSubmit}>
<View className='btn'></View> <View className="btn"></View>
</View> </View>
)} )}
{isSubmit && ( {isSubmit && (
<View className='confirm_btn flex aitems'> <View className="confirm_btn flex aitems">
<View className='btn'></View> <View className="btn"></View>
</View> </View>
)} )}
</Block> </Block>

@ -46,10 +46,12 @@ import {
bleCommandSamples, bleCommandSamples,
} from "@/components/bluetoot/connection/test"; } from "@/components/bluetoot/connection/test";
import { import {
hourMinSecToS,
minSecToS, minSecToS,
s_to_h,
s_to_hs,
s_to_s, s_to_s,
s_to_m,
s_to_ms,
s_to_hms,
isNeedToUpdate, isNeedToUpdate,
} from "@/utils/util"; } from "@/utils/util";
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
@ -97,12 +99,18 @@ const WORK_MODE_ENGLISH_NAME = {
26: "MixNurse", 26: "MixNurse",
27: "ScalpCare", 27: "ScalpCare",
}; };
// 组合模式:分别对应的是哪几个模式类型
// 黄光590nm
// 红光630nm
// 近红外光830nm
// 模式类型中文名 // 模式类型中文名
const WORK_MODE_Chinese_NAME = { const WORK_MODE_Chinese_NAME = {
: "powerfulSoothing", : "powerfulSoothing",
: "Stability", : "Stability", // 黄光?近红外光?
: "Brighten", : "Brighten", // 黄光?近红外光?
: "FirmSkin", : "FirmSkin", // 黄光?近红外光?
: "MaskCustom", : "MaskCustom",
Pro: "BrightenStand", Pro: "BrightenStand",
Pro: "FirmSkinStand", Pro: "FirmSkinStand",
@ -173,7 +181,7 @@ class IotCarePlan extends Component<any, any> {
modelActiveIndex: 0, //模式下标 modelActiveIndex: 0, //模式下标
sliderProgress: 22, sliderProgress: 22,
isStandStatus: false, // 支架开启状态(支架就是舱体) isStandStatus: false, // 支架开启状态(支架就是舱体)
facialMaskConnectStatus: 0, // 面膜?暂时认为是面罩连接状态 0未连接 1已连接 facialMaskConnectStatus: 0, // 面罩连接状态 0未连接 1已连接
workStatus: "", // 工作状态 workStatus: "", // 工作状态
Electricity: 0, // WL200电量 Electricity: 0, // WL200电量
matrixElectricity: 0, // matrix电量 matrixElectricity: 0, // matrix电量
@ -229,6 +237,7 @@ class IotCarePlan extends Component<any, any> {
// 最后执行步骤位置 // 最后执行步骤位置
endPlace: "", endPlace: "",
currentTime: "00:01:00",
}; };
} }
@ -586,36 +595,17 @@ class IotCarePlan extends Component<any, any> {
case "DeviceControl": case "DeviceControl":
console.log("小程序控制设备,给设备发送指令", jsonStatus); console.log("小程序控制设备,给设备发送指令", jsonStatus);
if ( // if (
jsonStatus.responseStatus == "OK" && // jsonStatus.responseStatus == "OK" &&
this.state.isSendModeCombination // this.state.isSendModeCombination
) { // ) {
// 发送启动指令 // // 发送启动指令
this.startCombinationMode(); // this.startCombinationMode();
// const totalTime = this.state.combinationList.reduce( // setTimeout(() => {
// (total, item) => { // console.log("currentTime", this.state.currentTime);
// return total + minSecToS(item.time); // });
// }, // }
// 0
// );
// 设备启动后小程序操作
// this.setState({
// showCombinationModeDialog: false,
// combinationModeInfo: {
// time: s_to_hs(totalTime),
// seconds: totalTime,
// },
// modelActiveIndex: -1,
// currentTime: s_to_hs(totalTime),
// isCurrentModeCombination: true,
// isSendModeCombination: false,
// });
setTimeout(() => {
console.log("currentTime", this.state.currentTime);
});
}
break; break;
//设备主动上报给小程序的指令 一般是工作状态改变 //设备主动上报给小程序的指令 一般是工作状态改变
case "DeviceStatusSync": case "DeviceStatusSync":
@ -846,20 +836,20 @@ class IotCarePlan extends Component<any, any> {
console.log("时间校准频率默认5秒一次", TIME_CALIBRATION_FREQUENCY); console.log("时间校准频率默认5秒一次", TIME_CALIBRATION_FREQUENCY);
//对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准
const currentScene = ActiveModeItem; // 获取当前的场景 const currentScene = ActiveModeItem; // 获取当前的场景
let sceneTime = minSecToS(currentScene.modeTime); // 场景时间 let sceneTime = hourMinSecToS(currentScene.modeTime); // 场景时间
const timeRemaining = sceneTime - minSecToS(currentTime); // 小程序上已运行的总秒数 const timeRemaining = sceneTime - hourMinSecToS(currentTime); // 小程序上已运行的总秒数
if ( if (
Math.abs(timeRemaining - totalTime) >= 2 && Math.abs(timeRemaining - totalTime) >= 2 &&
this.state.step == 2 && this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1 this.state.facialMaskConnectStatus == 1
) { ) {
this.setTimer(); this.resetTimer();
const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间 const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间
let { ActiveModeItem } = this.state; let { ActiveModeItem } = this.state;
ActiveModeItem.seconds = t; //修复时间跳变的问题 ActiveModeItem.seconds = t; //修复时间跳变的问题
this.setState({ this.setState({
currentTime: s_to_hs(t), currentTime: s_to_hms(t),
ActiveModeItem, ActiveModeItem,
}); });
} }
@ -1002,11 +992,11 @@ class IotCarePlan extends Component<any, any> {
// 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下 // 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下
const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus; const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus;
if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) { if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) {
const sceneTime = minSecToS(ActiveModeItem.modeTime); // 模式的总时长 const sceneTime = hourMinSecToS(ActiveModeItem.modeTime); // 模式的总时长
const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长 const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长
const timeRemaining = sceneTime - runTime; // 剩余未运行时间 const timeRemaining = sceneTime - runTime; // 剩余未运行时间
this.setState({ this.setState({
currentTime: s_to_hs(timeRemaining), currentTime: s_to_hms(timeRemaining),
}); });
} }
this.endnursing(null, true); this.endnursing(null, true);
@ -1130,7 +1120,8 @@ class IotCarePlan extends Component<any, any> {
return inTime; return inTime;
} }
setTimer() { // 重置计时器
resetTimer() {
// 切换模式后, 需要重新设置计时器, 以防进行中的计时器 // 切换模式后, 需要重新设置计时器, 以防进行中的计时器
timer && clearInterval(timer); timer && clearInterval(timer);
timer = setInterval(() => { timer = setInterval(() => {
@ -1145,14 +1136,14 @@ class IotCarePlan extends Component<any, any> {
// 组合模式逻辑 // 组合模式逻辑
// that.data.combinationModeInfo.seconds -= 1; // that.data.combinationModeInfo.seconds -= 1;
// that.setData({ // that.setData({
// currentTime: s_to_hs(that.data.combinationModeInfo.seconds) // currentTime: s_to_ms(that.data.combinationModeInfo.seconds)
// }) // })
// currentSeconds = that.data.combinationModeInfo.seconds // currentSeconds = that.data.combinationModeInfo.seconds
} else { } else {
const { ActiveModeItem, currentTime } = this.state; const { ActiveModeItem, currentTime } = this.state;
currentSeconds = minSecToS(currentTime); currentSeconds = hourMinSecToS(currentTime);
this.setState({ this.setState({
currentTime: s_to_hs(--currentSeconds), currentTime: s_to_hms(--currentSeconds),
}); });
console.log(ActiveModeItem.isCustomMode); console.log(ActiveModeItem.isCustomMode);
if (ActiveModeItem.isCustomMode) { if (ActiveModeItem.isCustomMode) {
@ -1167,7 +1158,7 @@ class IotCarePlan extends Component<any, any> {
} }
/*} else { /*} else {
that.data.standInfo.seconds -= 1; that.data.standInfo.seconds -= 1;
that.setData({ currentTime: s_to_hs(that.data.standInfo.seconds) }) that.setData({ currentTime: s_to_ms(that.data.standInfo.seconds) })
if(that.data.standInfo.seconds <= 0){ if(that.data.standInfo.seconds <= 0){
clearInterval(timer); clearInterval(timer);
this.showNurseSuccessDialog() this.showNurseSuccessDialog()
@ -1214,7 +1205,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({ this.setState({
workStatus: newWorkStatus, workStatus: newWorkStatus,
}); });
this.setTimer(); this.resetTimer();
console.info( console.info(
`handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`, `handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`,
sendParams sendParams
@ -1329,50 +1320,17 @@ class IotCarePlan extends Component<any, any> {
// 检查时间是否达标 // 检查时间是否达标
checkTime() { checkTime() {
const { curDeviceInfo, workStatus, ActiveModeItem } = this.state; const { curDeviceInfo, ActiveModeItem } = this.state;
const currentScene = ActiveModeItem; const currentScene = ActiveModeItem;
let sceneTime = minSecToS(currentScene.time); let sceneTime = hourMinSecToS(currentScene.modeTime);
const timeRemaining = sceneTime - minSecToS(this.state.currentTime); const timeRemaining = sceneTime - hourMinSecToS(this.state.currentTime);
if (timeRemaining >= Number(curDeviceInfo?.times) * 60) { if (timeRemaining >= Number(curDeviceInfo?.nursingTime) * 60) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
// 开始护理?
onPlayTap() {
const { ActiveModeItem, step } = this.state;
const modeItem = ActiveModeItem;
if (step == 1) {
this.state.videoContext.play();
this.setState({
showVideoPlayBtn: false,
});
} else if (modeItem.isStandMode && step == 2) {
this.setState({
standVideoContext: Taro.createVideoContext("standVideo"),
});
setTimeout(() => {
this.state.standVideoContext.play();
}, 100);
}
}
// 暂停护理?
onPauseTap() {
const { ActiveModeItem, step } = this.state;
const modeItem = ActiveModeItem;
if (step == 1) {
} else if (modeItem.isStandMode && step == 2) {
this.setState({
standVideoContext: Taro.createVideoContext("standVideo"),
});
setTimeout(() => {
this.state.standVideoContext.play();
}, 100);
}
}
// 删除WL200护理历史 // 删除WL200护理历史
rmWL200NursingHistory(WL200NursingHistory, hard = false) { rmWL200NursingHistory(WL200NursingHistory, hard = false) {
// const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); // const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
@ -1387,7 +1345,6 @@ class IotCarePlan extends Component<any, any> {
bluetoothDisconnectProcessing() { bluetoothDisconnectProcessing() {
clearInterval(timer); clearInterval(timer);
Taro.offBLEConnectionStateChange(this.listener); // 需传入与监听时同一个的函数对象 Taro.offBLEConnectionStateChange(this.listener); // 需传入与监听时同一个的函数对象
// this.state.innerAudioContext.destroy();
Taro.offBLECharacteristicValueChange((res) => { Taro.offBLECharacteristicValueChange((res) => {
console.log("offBLECharacteristicValueChange", res); console.log("offBLECharacteristicValueChange", res);
}); });
@ -1432,6 +1389,7 @@ class IotCarePlan extends Component<any, any> {
} }
} }
// 护理的错误提示
showTips(ctx) { showTips(ctx) {
if (!ctx) return; if (!ctx) return;
if (showTipsTimer) clearTimeout(showTipsTimer); if (showTipsTimer) clearTimeout(showTipsTimer);

@ -292,56 +292,69 @@ const ccrc8 = (str) => {
return (crc & 0xff).toString(16).padStart("2", 0); return (crc & 0xff).toString(16).padStart("2", 0);
}; };
/** 秒数转分秒,返回分秒 */ /** 秒数转分秒,返回分秒 */
const s_to_hs = (s) => { const s_to_hms = (s) => {
//计算分钟 //计算分钟
//算法将秒数除以60然后下舍入既得到分钟数 //算法将秒数除以60然后下舍入既得到分钟数
var m;
m = Math.floor(s / 60);
//算法将分钟除以60然后下舍入既得到小时数
var h; var h;
h = Math.floor(s / 60); h = Math.floor(m / 60);
//计算秒 //计算秒
//算法:取得秒%60的余数既得到秒数 //算法:取得秒%60的余数既得到秒数
s = s % 60; s = s % 60;
//将变量转换为字符串 // 将变量强制类型转换为字符串
h += ""; h += "";
m += "";
s += ""; s += "";
//如果只有一位数前面增加一个0 //如果只有一位数前面增加一个0
h = h.length == 1 ? "0" + h : h; h = h.length == 1 ? "0" + h : h;
m = m.length == 1 ? "0" + m : m;
s = s.length == 1 ? "0" + s : s; s = s.length == 1 ? "0" + s : s;
return h + ":" + s; return h + ":" + m + ":" + s;
}; };
/** 秒数转分钟,只返回分钟 */ /** 秒数转分秒,返回分秒 */
const s_to_h = (s) => { const s_to_ms = (s) => {
//计算分钟 //计算分钟
//算法将秒数除以60然后下舍入既得到分钟数 //算法将秒数除以60然后下舍入既得到分钟数
var h; var m;
h = Math.floor(s / 60); m = Math.floor(s / 60);
//计算秒 //计算秒
//算法:取得秒%60的余数既得到秒数 //算法:取得秒%60的余数既得到秒数
s = s % 60; s = s % 60;
//将变量转换为字符串 //将变量转换为字符串
h += ""; m += "";
s += ""; s += "";
//如果只有一位数前面增加一个0 //如果只有一位数前面增加一个0
h = h.length == 1 ? "0" + h : h; m = m.length == 1 ? "0" + m : m;
s = s.length == 1 ? "0" + s : s; s = s.length == 1 ? "0" + s : s;
return h; return m + ":" + s;
}; };
/** 秒数转分钟,只返回秒数 */ /** 秒数转分钟,只返回分钟 */
const s_to_s = (s) => { const s_to_m = (s) => {
//计算分钟 //计算分钟
//算法将秒数除以60然后下舍入既得到分钟数 //算法将秒数除以60然后下舍入既得到分钟数
var h; var h;
h = Math.floor(s / 60); h = Math.floor(s / 60);
//将变量转换为字符串
h += "";
//如果只有一位数前面增加一个0
h = h.length == 1 ? "0" + h : h;
return h;
};
/** 秒数转分钟,只返回秒数 */
const s_to_s = (s) => {
//计算秒 //计算秒
//算法:取得秒%60的余数既得到秒数 //算法:取得秒%60的余数既得到秒数
s = s % 60; s = s % 60;
//将变量转换为字符串 //将变量转换为字符串
h += "";
s += ""; s += "";
//如果只有一位数前面增加一个0 //如果只有一位数前面增加一个0
h = h.length == 1 ? "0" + h : h;
s = s.length == 1 ? "0" + s : s; s = s.length == 1 ? "0" + s : s;
return s; return s;
}; };
@ -354,6 +367,15 @@ const minSecToS = (minSecStr) => {
return strArr.length ? parseInt(strArr[0]) * 60 + parseInt(strArr[1]) : 0; return strArr.length ? parseInt(strArr[0]) * 60 + parseInt(strArr[1]) : 0;
}; };
/** 时分秒转秒数,返回秒数 */
const hourMinSecToS = (hourMinSecStr) => {
if (!hourMinSecStr) return 0;
let strArr = hourMinSecStr.split(":");
return strArr.length
? parseInt(strArr[0]) * 360 + parseInt(strArr[1]) * 60 + parseInt(strArr[2])
: 0;
};
// 将字符串转换成ArrayBufer // 将字符串转换成ArrayBufer
const string2buffer = (str) => { const string2buffer = (str) => {
let val = ""; let val = "";
@ -696,7 +718,6 @@ module.exports = {
filterData, filterData,
ccrc8, //crc8校验位 ccrc8, //crc8校验位
string2buffer, //将字符串转换成ArrayBufer string2buffer, //将字符串转换成ArrayBufer
s_to_hs, //秒转换成分秒
checkEnd, //相加和 checkEnd, //相加和
filterBleData, filterBleData,
getofflineData, getofflineData,
@ -709,9 +730,12 @@ module.exports = {
getimpedanceList, getimpedanceList,
DYNAMIC_BONES_OFFSETS, //阻抗获取值 DYNAMIC_BONES_OFFSETS, //阻抗获取值
getreportData, //解析上报数据 getreportData, //解析上报数据
s_to_h, s_to_m,
s_to_s, s_to_s,
s_to_ms, //秒转换成分秒
s_to_hms, //秒转换成时分秒
minSecToS, minSecToS,
hourMinSecToS,
getTimeCode, //同步时间指令 getTimeCode, //同步时间指令
isNeedToUpdate, isNeedToUpdate,
compareVersion, compareVersion,

Loading…
Cancel
Save