diff --git a/README.md b/README.md index d31ed73..101c39b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN 1. 电脑需要安装 node ,开发版本为 16.18.0 2. 下载项目依赖 - ```javascript npm i -f // 强制下载安装依赖 注意:请使用npm源,taobao源可能下载失败 ``` diff --git a/config/dev.ts b/config/dev.ts index d5e257e..61a8134 100644 --- a/config/dev.ts +++ b/config/dev.ts @@ -7,6 +7,8 @@ module.exports = { mini: { debugReact: true, webpackChain: (chain, webpack) => { + // chain.plugin('analyzer') + // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) chain.merge({ plugin: { install: { diff --git a/src/components/popup/popup-membraneList.tsx b/src/components/popup/popup-membraneList.tsx index 0ebf4f9..ec4720d 100644 --- a/src/components/popup/popup-membraneList.tsx +++ b/src/components/popup/popup-membraneList.tsx @@ -37,16 +37,16 @@ export default class PopupMembraneList extends Component { }; } - async onLoad() {} - componentDidMount() {} + async onLoad() { } + componentDidMount() { } - componentWillUnmount() {} + componentWillUnmount() { } - componentDidShow() {} + componentDidShow() { } - componentDidHide() {} + componentDidHide() { } - async initData() {} + async initData() { } onClose = () => { this.props.onClose(); @@ -70,10 +70,11 @@ export default class PopupMembraneList extends Component { - + > 膜布选择 { constructor(props) { super(props); this.state = { + isNursingTime:false, + ishandPause:false, //判断是否是自己暂停 isTest: false, name: "WE200", title: "WE200", // 页面标题 @@ -104,17 +106,9 @@ class IotCarePlanWE200 extends Component { model: "", }, modeVideo: "", + radarMax: 1, //echarts雷达图最大值 // 膜布类型 MembraneClothList: [ - { - modeName: "眼雕大师模式", - id: 1, - // file:[] - }, - { - modeName: "妆前急救模式", - id: 2, - }, ], radarData: [0, 2, 0, 2, 0, 2, 0, 0], // 电流定制-眼雕大师 @@ -291,17 +285,12 @@ class IotCarePlanWE200 extends Component { // 模式列表 currentWorkModeType: 1, // 现在的模式类型 isModeLock: false, // 模式是否锁定 - isSwitchActiveMode: false, // 是否显示弹窗切换模式 ModeList: [], ModeType: "all", // all 1基础护理 2专区护理 3专研促渗 4敏期护理 5智能测肤 - ActiveModeItem: { - openSourceData: [], - }, // 当前选中模式 + ActiveModeItem: {}, // 当前选中模式 SwitchActiveModeItem: {}, // 切换选中模式 ModeID: "mode_", // 模式KEY activeModeID: "", // 当前选中模式ID:用于高亮 - ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示 - ModeStepTimeArray: [], // 护理功效时间步骤,用于切换显示GIF currentServiceData: { // 当前展示的开启暂停GIF: 因为时间判断不方便,所以单独领出来 @@ -315,7 +304,6 @@ class IotCarePlanWE200 extends Component { // 是否结束护理 isEndCarePlan: false, currentTime: "10:00", // 倒计时时间:WR200以视频为准 - currentVideoTime: "10:00", // 当前视频时间 // 护理时间不够 isNotEnoughTime: false, @@ -362,16 +350,6 @@ class IotCarePlanWE200 extends Component { impedance: 107, // 阻抗/能量等级:1档<200 200<2档<280 280<3档<360 后面以此类推每加一档+80抗阻 }; // 1档 等于0<200,2档等于200<280,3档等于280<360 - /** FR200模式类型:名称 */ - ModeTypeArray: string[] = [ - "all", - "base", - "eyes", - "zone", - "permeation", - "sensitive", - "intelligence", - ]; async onLoad(option) { console.log(option, "跳转过来的数据"); @@ -390,7 +368,14 @@ class IotCarePlanWE200 extends Component { // 模拟 instrumentId仪器id,膜布id 模拟器可以使用这个假数据 // let instrumentId =119 // let liningId =2 - this.modeInfoList(instrument.id, Membrane.id); + + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + await this.modeInfoList(instrument.id, Membrane.id); + Taro.hideLoading(); + // this.modeInfoList(instrumentId,liningId) // this.getInstrumentOfflineSummary(); // this.getInstrumentOfflineDetail(); @@ -419,8 +404,13 @@ class IotCarePlanWE200 extends Component { instrumentId, liningId, }); - let { MembraneClothList, checkedMembraneCloth, WeCurrent, WeEyeCarving } = - that.state; + let { + MembraneClothList, + checkedMembraneCloth, + WeCurrent, + WeEyeCarving, + radarMax, + } = that.state; MembraneClothList = []; if (res.data?.code === 200 && res.data.data.length) { // 面部肌肉对位标准 @@ -452,6 +442,7 @@ class IotCarePlanWE200 extends Component { counterpointCalibrationData = faceCalibrationPopUpJson; // 准备页面视频 modeVideo = e.modeVideo; + // 护理页面视频 nursingList.nursing = nursingAdjustmentJson.nursingBaseFile; nursingList.errorImg = nursingAdjustmentJson.errorPrompt; @@ -468,6 +459,7 @@ class IotCarePlanWE200 extends Component { let customizationElectricQuestion = JSON.parse( e.customizationElectricQuestion ); + // 答题图片 WeCurrent[0].file = [customizationElectricQuestion.problemOneImg]; WeCurrent[1].file = [customizationElectricQuestion.problemTwoImg]; WeCurrent[2].file = [customizationElectricQuestion.problemThreeImg]; @@ -508,19 +500,22 @@ class IotCarePlanWE200 extends Component { let eyeNursingRadar = JSON.parse(e.eyeNursingRadar); eyeNursingRadar.radarChartTable.forEach((item) => { WeEyeCarving[0].ChekboxList.push(item.describe); + WeEyeCarving[0].min = eyeNursingRadar.min; }); + radarMax = eyeNursingRadar.max; } MembraneClothList.push({ modeVideo, modeName: e.modeName, - id: e.modeType, + id: e.modeType, // todo + modeType: e.modeType, counterpointCalibrationData, modeId: e.id, nursingList, }); }); - console.log(MembraneClothList, "MembraneClothList"); + console.log(MembraneClothList, "MembraneClothList", WeCurrent); // 默认初始值是选中第一个高亮 checkedMembraneCloth = MembraneClothList[0].id; @@ -531,8 +526,12 @@ class IotCarePlanWE200 extends Component { checkedMembraneCloth, WeEyeCarving, modeVideo: MembraneClothList[0].modeVideo, + // ActiveModeItem: res.data.data[0], + ModeList: res.data.data, + radarMax, }); }); + this.modeCurrentFun(res.data.data[0], true); } }; componentDidHide() { @@ -550,9 +549,6 @@ class IotCarePlanWE200 extends Component { title: obj.name, }); - // await this.GetModeList(obj.id); - // this.modeInfoList(instrumentId, liningId); - // 如果不存在设备模式值,则判断为首次进入,弹窗提示 let isFirstTipShow = getStorageSync("first_instrument_" + obj.id); if (!isFirstTipShow) { @@ -571,11 +567,6 @@ class IotCarePlanWE200 extends Component { async init() { // 监听蓝牙连接状态改变 Taro.onBLEConnectionStateChange(this.listener); - // this.bluetoothContainer = new BluetoothContainer( - // this.props.bluetoothInfo, - // deviceToolKitInstance, - // this - // ); this.bluetoothContainer = new BluetoothContainer( this.props.bluetoothInfo, @@ -673,6 +664,14 @@ class IotCarePlanWE200 extends Component { onMembrane = (item) => { console.log(item, "选中的模式"); + let modeItem = this.state.ModeList.find((ele) => ele.id === item.modeId); + console.log("modeItem", modeItem); + if (modeItem) { + this.setState({ + ActiveModeItem: modeItem, + }); + } + this.setState({ checkedMembraneCloth: item.id, modeVideo: item.modeVideo, @@ -697,39 +696,6 @@ class IotCarePlanWE200 extends Component { }); }; - // 获取模式列表 - GetModeList = async (id) => { - let params = { - instrumentId: id, - }; - let res = await InstrumentInfo.modeInfoList(params); - - if (res.data.code === 200) { - if (res.data.data.length > 0) { - this.setState({ - ModeList: res.data.data, // 模式列表 - ActiveModeItem: res.data.data[0], // 让模式列表正常显示 - ModeType: this.ModeTypeArray[res.data.data[0].modeClass], - }); - - if (this.state.activeModeID != "") { - let res1 = res.data.data.find((e) => e.id == this.state.activeModeID); - if (res1) { - setTimeout(() => { - this.modeCurrentFun(res1); - }, 100); - } - } else { - setTimeout(() => { - this.modeCurrentFun(res.data.data[0]); - }, 100); - } - } else { - this.setState({ ModeList: [] }); - } - } - }; - /** * 倒计时弹窗 * param 重置倒计时 @@ -771,9 +737,9 @@ class IotCarePlanWE200 extends Component { // 仅在未开始护理前,切换模式的时候提示模式弹窗 // WE200默认开始护理 - if (!isShowNurse) { - this.openStepTips(); - } + // if (!isShowNurse) { + // this.openStepTips(); + // } // 如果按钮不可点击则报错,内部自带检查底部按钮函数 // this.onEmitErrorTips(); @@ -782,20 +748,20 @@ class IotCarePlanWE200 extends Component { if (isReturn) return; } + let currentTime = data.modeTimeStr; this.setState({ // 设置选中 ActiveModeItem: data, activeModeID: data.id, ModeID: "mode_" + data.id, - // 设置重置步骤与模式类型 - ModeStepIndex: 0, - ModeType: this.ModeTypeArray[data.modeClass], + currentTime, }); // 开发中,暂时允许直接切换 // 每次切换模式时清空一下历史数据 this.changeItemUpdateWE200NursingHistory(); - this.stepNext(); // 仅切换模式,不执行开始逻辑 + + // this.stepNext(); // 仅切换模式,不执行开始逻辑 // 用于限制模式是否在切换后自动开始运行 // if () { @@ -838,52 +804,15 @@ class IotCarePlanWE200 extends Component { return false; } - /** 切换护理模式 */ - switchModeCurrentFun = async (data) => { - this.setState({ - SwitchActiveModeItem: data, - activeModeID: data.id, - ModeID: "mode_" + data.id, - }); - }; - // 打开模式切换弹窗 - openModeSwitch = () => { - console.log("openModeSwitch"); - this.setState({ - isSwitchActiveMode: true, - }); - }; - // 取消并关闭切换护理模式弹窗 - cancelModeSwitchBtn = () => { - this.setState({ - isSwitchActiveMode: false, - }); - }; - // 弹窗确定切换护理模式 - confirmModeSwitchBtn = () => { - let { SwitchActiveModeItem } = this.state; - this.cancelModeSwitchBtn(); - this.modeCurrentFun(SwitchActiveModeItem); - - this.setState({ - ModeType: this.ModeTypeArray[SwitchActiveModeItem.modeClass], - }); - }; - stepNext = () => { - let modeClass = this.state.ActiveModeItem.modeClass; this.workStatus = "pause"; this.isRuning = true; // 暂停也是运行中 this.setState({ - ModeType: this.ModeTypeArray[modeClass], isShowNurse: true, // isStopNurse: true, isWorkImg: true, + ishandPause:true, }); - // setTimeout(() => { - // console.log(this.state.isShowNurse,'cchaaaaaaa'); - - // }); setTimeout(() => { this.bluetoothContainer?.DeviceControl?.standby( this.state.ActiveModeItem.modeType @@ -935,13 +864,13 @@ class IotCarePlanWE200 extends Component { console.log("切换光照,", ActiveModeItem, isStopNurse); // 弹窗内容 - let pop = MembraneClothList.find((e) => e.id === checkedMembraneCloth); + // let pop = MembraneClothList.find((e) => e.id === checkedMembraneCloth); if (isStopNurse) { // 切换视频-切换成正在工作中 - this.setState({ isWorkImg: true, + ishandPause:true }); // 开始光照逻辑 this.onNursingTap(); @@ -949,6 +878,7 @@ class IotCarePlanWE200 extends Component { // 切换视频-切换成底图 this.setState({ isWorkImg: false, + ishandPause:false }); // 暂停光照逻辑 this.bluetoothContainer?.DeviceControl?.pause(ActiveModeItem.modeType); @@ -962,24 +892,24 @@ class IotCarePlanWE200 extends Component { /** * @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("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗 - } - this.setState({ isShowStepTips: false }); - }; + // 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("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗 + // } + // this.setState({ isShowStepTips: false }); + // }; /** 蓝牙连接相关 */ switchBLEMatch = (jsonStatus: any) => { @@ -1010,6 +940,8 @@ class IotCarePlanWE200 extends Component { /** 同步设备运行信息:运行时间 */ updateDeviceSyncData = (newData, jsonStatus) => { + console.log(newData,'查看最新的时间数据'); + DeviceSyncData = { ...DeviceSyncData, ...newData, @@ -1030,11 +962,16 @@ class IotCarePlanWE200 extends Component { //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 let sceneTime = ActiveModeItem?.breakTimeStr ? minSecToS(ActiveModeItem.breakTimeStr) - : minSecToS(this.state.currentVideoTime); // 场景时间 + : minSecToS(ActiveModeItem.modeTimeStr); // 场景时间 // console.log("场景时间 sceneTime", sceneTime); // console.log("当前显示时间 currentTime", currentTime); - console.log("设备运行时间 totalTime", totalTime); + console.log( + "设备运行时间 totalTime", + totalTime, + ActiveModeItem, + ActiveModeItem?.breakTimeStr,sceneTime + ); // 更新界面倒计时 this.resetTimer(); @@ -1086,7 +1023,7 @@ class IotCarePlanWE200 extends Component { * @params 工作状态 工作模式 */ judgementWorkStatus(nWorkStatus, nWorkMode) { - const { ActiveModeItem, ModeList, currentVideoTime } = this.state; + const { ActiveModeItem, ModeList } = this.state; const opts: any = {}; let nowModeItem; if (nWorkMode) { @@ -1096,7 +1033,7 @@ class IotCarePlanWE200 extends Component { } opts.workStatus = nWorkStatus; - let nowCurrentTime = currentVideoTime; + let nowCurrentTime = ActiveModeItem.modeTimeStr; // 完成重连同步则删除重连时间字段 if (ActiveModeItem?.breakTimeStr) { nowCurrentTime = ActiveModeItem?.breakTimeStr; @@ -1167,6 +1104,12 @@ class IotCarePlanWE200 extends Component { // 重置并同步计时器 resetTimer = () => { + // isNursingTime第2次就return掉 + if (this.state.currentTime === "00:00" && this.state.isNursingTime) { + currentTimeTimer && clearInterval(currentTimeTimer); + return; + } + // 切换模式后, 需要重新设置计时器, 以防进行中的计时器 currentTimeTimer && clearInterval(currentTimeTimer); currentTimeTimer = setInterval(() => { @@ -1174,8 +1117,13 @@ class IotCarePlanWE200 extends Component { DeviceConnectStatus, currentTime, ActiveModeItem, - currentVideoTime, + ModeStepTimeArray, } = this.state; + + if (currentTime === "00:00") { + return; + } + if ( this.workStatus == MODE_WORKING_ENUM.WORKING && this.isRuning && @@ -1183,22 +1131,26 @@ class IotCarePlanWE200 extends Component { ) { let totalSeconds = ActiveModeItem?.breakTimeStr ? minSecToS(ActiveModeItem.breakTimeStr) - : minSecToS(currentVideoTime); + : minSecToS(ActiveModeItem.modeTimeStr); // 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算 let currentSeconds = minSecToS(currentTime); let checkTime = totalSeconds - currentSeconds; // 缓存经过的时间:用于接口提交 this.elapsedTime = checkTime; - // fr200不需要加上中断的时间 // 如果存在中断时间,则要加上间隔的时间 - // if (ActiveModeItem?.breakTimeStr) { - // let intervalTime = - // minSecToS(ActiveModeItem.modeTimeStr) - - // minSecToS(ActiveModeItem.breakTimeStr); - // this.elapsedTime += intervalTime; - // } - console.log("this.elapsedTime", this.elapsedTime); + if (ActiveModeItem?.breakTimeStr) { + let intervalTime = + minSecToS(ActiveModeItem.modeTimeStr) - + minSecToS(ActiveModeItem.breakTimeStr); + this.elapsedTime += intervalTime; + } + console.log( + "this.elapsedTime", + this.elapsedTime, + ActiveModeItem, + ActiveModeItem?.breakTimeStr + ); // 判断剩余时间是否大于1 if (currentSeconds >= 1) { @@ -1212,6 +1164,7 @@ class IotCarePlanWE200 extends Component { clearInterval(currentTimeTimer); this.setState({ currentTime: "00:00", + isNursingTime:true }); this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束 } @@ -1260,7 +1213,7 @@ class IotCarePlanWE200 extends Component { async endNurseFun() { let { ActiveModeItem } = this.state; if (this.isCheckNurseTime()) { - // await this.PostNursingLogClock(); + await this.PostNursingLogClock(); this.bluetoothContainer?.DeviceControl?.end(ActiveModeItem.modeType); } else { // 时间不满足,直接提交回到主页 @@ -1274,8 +1227,8 @@ class IotCarePlanWE200 extends Component { /** 检查时间是否达标仪器最低护理时间 */ isCheckNurseTime() { - const { currentDevice, currentVideoTime } = this.state; - let sceneTime = minSecToS(currentVideoTime); + const { currentDevice, ActiveModeItem } = this.state; + let sceneTime = minSecToS(ActiveModeItem.modeTimeStr); const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间 let nursingTimeStr = currentDevice?.nursingTimeStr; @@ -1325,8 +1278,7 @@ class IotCarePlanWE200 extends Component { * */ checkInstrumentRecord = async (jsonStatus: any) => { console.log("检查护理记录"); - let { currentDevice, ActiveModeItem, ModeList, currentVideoTime } = - this.state; + let { currentDevice, ActiveModeItem, ModeList } = this.state; await sleep(2); @@ -1378,7 +1330,8 @@ class IotCarePlanWE200 extends Component { } let historyElapsedTime = - minSecToS(currentVideoTime) - minSecToS(WE200NursingHistory.currentTime); + minSecToS(ActiveModeItem.modeTimeStr) - + minSecToS(WE200NursingHistory.currentTime); this.elapsedTime = this.elapsedTime > historyElapsedTime @@ -1419,8 +1372,8 @@ class IotCarePlanWE200 extends Component { nursingTime: timeValue, }; this.bluetoothContainer?.DeviceControl?.end(ActiveModeItem.modeType); - // let res: any = await this.PostNursingLogClock(params); - // console.log("res", res); + let res: any = await this.PostNursingLogClock(params); + console.log("res", res); this.rmWE200NursingHistory(WE200NursingHistory); } else { // ID不一致,同步异常,统一提交一分钟 @@ -1432,8 +1385,8 @@ class IotCarePlanWE200 extends Component { nursingTime: "00:01:00", }; this.bluetoothContainer?.DeviceControl?.end(ActiveModeItem.modeType); - // let res: any = await this.PostNursingLogClock(params); - // console.log("res", res); + let res: any = await this.PostNursingLogClock(params); + console.log("res", res); this.rmWE200NursingHistory(WE200NursingHistory); } } else { @@ -1515,7 +1468,7 @@ class IotCarePlanWE200 extends Component { params.modeId = this.state.ActiveModeItem.id; params.modeName = this.state.ActiveModeItem.modeName; - console.log(jsonStatus, 555555555555); + console.log(jsonStatus, '每分钟数据'); } } else { params.jsonStatus = jsonStatus; @@ -1558,107 +1511,6 @@ class IotCarePlanWE200 extends Component { Taro.removeStorageSync("WE200NursingHistory"); }; - // 脸部one - todoPromise = async () => { - const nowWE200NursingHistory = Taro.getStorageSync("WE200NursingHistory"); - console.log(nowWE200NursingHistory, "nowWE200NursingHistory"); - - // 护理脸部 - if ( - [ - "face", - "eyes", - "nasolabialFold", - "mandibularLine", - "headLiftingPro", - ].includes(nowWE200NursingHistory.jsonStatus.workMode) - ) { - // 把working=工作中的状态数据筛选出来 - let filtered = nowWE200NursingHistory.dataArray.filter( - (item) => item.workStatus === "working" - ); - // 能量发数 - filtered = filtered.slice(0, 360); - // 脸部能量 - let faceEnergy = 0; - filtered.forEach((item) => { - faceEnergy += item.joulePerSecond; - }); - // 计算平均数 - // let sum = filtered.reduce((accumulator, currentValue) => accumulator + currentValue.impedance, 0); - // let average = sum / filtered.length; - - // 最大 - let max: any = Math.max(...filtered.map((item) => item.impedance)); - max = this.determineTier(max); - // 最小 - let min: any = Math.min(...filtered.map((item) => item.impedance)); - min = this.determineTier(min); - // 平均数最大等级处于2 - let average: any = max / 2; - average = this.determineTier(average); - - // 能量图里面的图谱每10秒为一个数组 - // 创建一个空数组用于存储分组后的结果 - // 创建一个空数组用于存储分组后的结果 - let groupedAa: any[] = []; - // 使用循环遍历数组 aa - for (let i = 0; i < filtered.length; i += 10) { - // 提取每组的三个对象 - let group = filtered.slice(i, i + 10); - - // 找到组中最大的 name 值 - let maxName = Math.max(...group.map((obj) => obj.impedance)); - - // 计算并存储每组的平均数 - let average: any = this.determineTier(maxName / 2); - // let average = maxName / 2; - if (average >= 1) { - average = average - 1; - average = average * 10; - } - // 将包含该组对象和平均数的对象添加到 groupedAa 数组中 - groupedAa.push(average); - } - - let nursingData = { - // nursingTime:result, - nursingData: JSON.stringify({ - faceEnergy, - max, - min, - average, - groupedAa, - filtered: filtered.length, - workMode: nowWE200NursingHistory.workMode, - }), - }; - - return nursingData; - } - return { - nursingData: JSON.stringify({ - workMode: nowWE200NursingHistory.workMode, - }), - showFace: true, - }; - }; - - // 计算挡位 - determineTier = (sun) => { - // 定义每档的范围 - const tiers = [0, 200, 280, 360, 440, 520, 600, 680, 760, 840]; - - // 遍历每一档的范围,找到 sun 所属的档 - for (let i = 0; i < tiers.length; i++) { - if (sun < tiers[i + 1]) { - return i + 1; - } - } - - // 如果 sun 不在任何一档范围内,返回默认档或处理错误 - return "10"; - }; // 模式选中后下一步 modeSelect = () => { let that = this; @@ -1692,7 +1544,7 @@ class IotCarePlanWE200 extends Component { { name: "下颚线", forehead: 5, Total: 10 }, ]; counterpointCalibrationData = pop; - if ("private_custom_current" === checkedMembraneCloth) { + if ("ShapeBeautyEssence_Custom" === checkedMembraneCloth) { // 获取私人定制 that.setState({ isCurrent: true, @@ -1718,20 +1570,14 @@ class IotCarePlanWE200 extends Component { counterpointCalibrationData, }); } else { - setTimeout(() => { - console.log( - "WaterLightEssence", - that.bluetoothContainer.DeviceControl - ); - that.bluetoothContainer.DeviceControl.workByPatitionSet( - checkedMembraneCloth - ); - }, 6000); - + // 从准备页面到护理页面 + that.stepNext(); + that.bluetoothContainer.DeviceControl.workByPatitionSet( + checkedMembraneCloth + ); setTimeout(() => { that.bluetoothContainer.DeviceControl.working(checkedMembraneCloth); - }, 9000); - that.stepNext(); + }, 1000); } } @@ -2029,6 +1875,7 @@ class IotCarePlanWE200 extends Component { WeEyeCarving, currentNursingEye, radarData, + radarMax, } = this.state; // 弹窗选中 @@ -2038,6 +1885,7 @@ class IotCarePlanWE200 extends Component { electricList: WeEyeCarving[0].Checkbox, //第一题选中的答案 electricLevel: WeEyeCarving[1].SliderVlue, //第二题选中的值 modeId: item.modeId, //模式id + min: WeEyeCarving[0].min, }; // radarData =[5,3,4,2,4,2,2,2] @@ -2057,16 +1905,11 @@ class IotCarePlanWE200 extends Component { if (newItem) { radarData.push(newItem.redarScore); } else { - radarData.push(0); + radarData.push(WeEyeCarving[0].min); } }); console.log(radarData, "radarDataradarData"); - // this.setState({ - // isCurrentEyeCarving:false, - // radarData, - // isCurrentEye:true, - // }) // // 清空数据 this.cleanEyeCarving(); this.setState({ @@ -2074,7 +1917,6 @@ class IotCarePlanWE200 extends Component { isCurrentEyeCarving: false, radarData, isCurrentEye: true, - // radarData }); let that = this; setTimeout(function () { @@ -2105,6 +1947,8 @@ class IotCarePlanWE200 extends Component { PostNursingLogClock = async (data: any = null, isJump = true) => { // todo 建议写一个Promise异步函数,用 await 执行,在提交前处理好数据 + // 获取设备上报 + this.bluetoothContainer?.DeviceControl?.getCurrentFacialReportInfo(); // return; let { currentDevice, ActiveModeItem } = this.state; let params = {}; @@ -2119,11 +1963,7 @@ class IotCarePlanWE200 extends Component { nursingTime: s_to_hms(this.elapsedTime), }; } - let res1: any = await this.todoPromise(); - if (!res1?.showFace) { - params = { ...params, ...res1 }; - } - console.log(res1, "查看返回数据"); + let res2: any = await InstrumentInfo.apiNursingLog.addLog(params); console.log("PostNursingLogClock", res2); @@ -2145,12 +1985,7 @@ class IotCarePlanWE200 extends Component { isShowNursingSuccess: false, }); - this.goFaceReport( - res1, - ActiveModeItem.id, - res2.data.data, - currentDevice.id - ); // 跳转 + this.goNursingPage(); // 跳转到护理页面 }, 2000); } } @@ -2161,6 +1996,7 @@ class IotCarePlanWE200 extends Component { PrepareSelect: !PrepareSelect, }); }; + // 面部校准弹窗确认 MuscleAlignmentCalibration = () => { let that = this; let { PrepareSelect, checkedMembraneCloth } = this.state; @@ -2169,21 +2005,19 @@ class IotCarePlanWE200 extends Component { if (PrepareSelect) { Taro.setStorageSync("WE200Tile", true); } + that.stepNext(); this.setState({ isPrepare: false, - isShowNurse: true, + // isShowNurse: true, isWorkImg: true, }); - setTimeout(() => { - console.log("WaterLightEssence", that.bluetoothContainer.DeviceControl); - that.bluetoothContainer.DeviceControl.workByPatitionSet( - checkedMembraneCloth - ); - }, 6000); + that.bluetoothContainer.DeviceControl.workByPatitionSet( + checkedMembraneCloth + ); setTimeout(() => { that.bluetoothContainer.DeviceControl.working(checkedMembraneCloth); - }, 9000); + }, 1000); }; /*** 护理记录 END ***/ @@ -2277,54 +2111,9 @@ class IotCarePlanWE200 extends Component { }; /** 完成护理提交:跳转护理报告页 */ - goFaceReport = async (data, id, deviceid, currentDevice) => { - let nursingData = JSON.parse(data.nursingData); - // 跳转前置空定时器,防止重复提交 - if (currentTimeTimer) clearInterval(currentTimeTimer); - if ( - [ - "face", - "eyes", - "nasolabialFold", - "mandibularLine", - "headLiftingPro", - ].includes(nursingData.workMode) - ) { - let ids = Number(deviceid); - // 获取echarts数据 这个是获取接口更新echarts页面 - let res2 = await InstrumentInfo.apiNursingLog.getStatiCDE(ids); - - let nursingDatas = JSON.parse(res2.data.data.nursingData); - let obj = { - modeName: res2.data.data.modeName, - data: nursingDatas, - }; - - let report = true; - go( - "/recoding/pages/face_report_one/face_report_one?id=" + - ids + - "&report=" + - report + - "&obj=" + - JSON.stringify(obj) - ); - } else if ("moistureTest" === nursingData.workMode) { - console.log("水分测试"); - } else { - console.log("跳转11111111"); - - let report = true; - - go( - "/recoding/pages/face_report/face_report?id=" + - deviceid + - "&recordId=" + - currentDevice + - "&report=" + - report - ); - } + goNursingPage = async () => { + console.log('进来护理页面次数'); + }; // 完成配对 @@ -2363,7 +2152,7 @@ class IotCarePlanWE200 extends Component { this.setState({ isShowTipsSave: false, }); - // this.PostNursingLogClock(null, false); // 先提交护理记录 + this.PostNursingLogClock(null, false); // 先提交护理记录 this.modeCurrentFun(this.tempModeCurrent, true); // 不进行校验 }; @@ -2414,16 +2203,6 @@ class IotCarePlanWE200 extends Component { this.setState({ isModeLock: false }); }; - // 获取并设置视频时间 - GetVideosTime = (event) => { - console.log("获取并设置视频时间GetVideosTime", event?.detail?.duration); - if (event?.detail?.duration) { - let duration = Math.floor(event?.detail?.duration); - let currentTime = s_to_ms(duration); - this.setState({ currentTime, currentVideoTime: currentTime }); - } - }; - render() { let { title, @@ -2436,7 +2215,6 @@ class IotCarePlanWE200 extends Component { ModeStepIndex, ActiveModeItem, currentWorkModeType, - isSwitchActiveMode, ModeID, activeModeID, isShowCountdown, @@ -2507,41 +2285,6 @@ class IotCarePlanWE200 extends Component { close={this.cancelEndBtn} confirm={this.confirmEndBtn} /> - - } - textAlgin="center" - cancelButtonText="取消" - confirmButtonText="确定" - close={this.cancelModeSwitchBtn} - confirm={this.confirmModeSwitchBtn} - /> - - {ActiveModeItem.openSourceData.length > 0 && ( - - )} { )} {/* 运行中图片 */} {this.state.isWorkImg && ( - + {" "} )} {/* 挡位图片 */} {isShowNurse && this.state.isgearImg && ( - + {" "} @@ -2665,9 +2408,9 @@ class IotCarePlanWE200 extends Component { {/* 错误页面图片 */} {isShowNurse && this.state.isError && ( - + {" "} @@ -2727,7 +2470,7 @@ class IotCarePlanWE200 extends Component { > )} - {/* step2 */} + {/* step2 挡位调节*/} {isShowNurse && ( @@ -2761,11 +2504,12 @@ class IotCarePlanWE200 extends Component { isStopNurse={isStopNurse} onEmitStartNurse={this.onStartNurse} onEmitSwitchChange={this.onSwitchChange} - onEmitEndPlan={this.onEndPlan} + onEmitEndPlan={this.onEndPlan} //结束 onEmitErrorTips={this.onEmitErrorTips} /> + {/* 定制电流答题 */} {this.state.isCurrent && ( { onChangeSlider={this.onChangeSlider} /> )} - {/* 专属电流配方弹窗 */} + {/* 专属电流配方3秒弹窗弹窗 */} 膜布选择 @@ -2822,7 +2566,7 @@ class IotCarePlanWE200 extends Component { /> )} - {/* 面部肌肉对位校准 */} + {/* 面部肌肉对位校准---公共 */} { - {/* 定制电流-眼雕大师 */} + {/* 定制电流-眼雕大师--答题页面 */} { ReCustomize={this.ReCustomizeEyeCarving} //重新定制 ReCare={this.ReCare} //开始护理 /> - {/* 专属电流配方弹窗--眼雕大师 */} + {/* 专属电流配方3秒弹窗--眼雕大师 */} {this.state.isCurrentEye && ( @@ -2914,6 +2658,7 @@ class IotCarePlanWE200 extends Component { series={this.state.radarData} height={"520rpx"} cancelFull={this.onisTest} + max={this.state.radarMax} > @@ -2941,6 +2686,7 @@ class IotCarePlanWE200 extends Component { series={this.state.radarData} height={"150prx"} cancelFull={this.onisTest} + max={this.state.radarMax} > } isShow={this.state.isEyeCurrent} diff --git a/src/moduleIOT/pages/iotCarePlan/components/Bluetoot/WE200.ts b/src/moduleIOT/pages/iotCarePlan/components/Bluetoot/WE200.ts index 0e385bd..245a039 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/Bluetoot/WE200.ts +++ b/src/moduleIOT/pages/iotCarePlan/components/Bluetoot/WE200.ts @@ -34,14 +34,18 @@ export default class BluetoothContainer { public DeviceControl = { /** @name 设置模式 */ workByPatitionSet: (workMode = '', gearTakeEffectOffline = false, partitionStatus = [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }]) => { - console.log(workMode,'查看模式'); + console.log(workMode, '查看模式'); let sendParams: any = { ...WE200DeviceControlCommand.workByPatitionSet, workMode: workMode, // 使用模式 gearTakeEffectOffline: gearTakeEffectOffline, // 是否离线生效 - partitionStatus: partitionStatus // 默认用官配模式 + partitionStatus: partitionStatus, // 默认用官配模式 + deviceSyncCommandType: 'onlySyncStatusToDevice', + totalWorkingMinutes: 0, + totalWorkingSeconds: 0, + // deviceSyncCommandType: "onlySyncStatusToDevice", }; - const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand( + const pauseArrayBuffer = this.deviceToolKitInstance?.toBleCommand( sendParams as any ); @@ -60,6 +64,11 @@ export default class BluetoothContainer { let sendParams: any = { ...WE200DeviceControlCommand.pause, workMode: workMode, // 使用模式 + workStatus: 'standby', + deviceSyncCommandType: 'onlySyncStatusToDevice', + totalWorkingMinutes: 0, + totalWorkingSeconds: 0, + // deviceSyncCommandType: "onlySyncStatusToDevice", }; const pauseArrayBuffer = this.deviceToolKitInstance?.toBleCommand( sendParams as any @@ -91,8 +100,8 @@ export default class BluetoothContainer { }, /** @name 设备控制:工作 */ working: (workMode = '', gearTakeEffectOffline = false, partitionStatus = [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }]) => { - console.log(workMode,'工作中模式',WE200DeviceControlCommand); - + console.log(workMode, '工作中模式', WE200DeviceControlCommand); + let sendParams: any = { ...WE200DeviceControlCommand.work, workMode: workMode, // 使用模式 @@ -100,14 +109,14 @@ export default class BluetoothContainer { partitionStatus }; // 根据不同模式进行控制传参处理 - switch (workMode) { - case "private_custom_current": - break; - case "official_specific_effective": - break; - case 'DiyFacial_Custom': - break; - } + // switch (workMode) { + // case "private_custom_current": + // break; + // case "official_specific_effective": + // break; + // case 'DiyFacial_Custom': + // break; + // } const pauseArrayBuffer = this.deviceToolKitInstance?.toBleCommand( sendParams as any @@ -124,21 +133,40 @@ export default class BluetoothContainer { }, /** @name 设备控制:结束 */ end: (workMode = '') => { - let sendParams: any = { - ...WE200DeviceControlCommand.pause, - workMode: workMode, // 使用模式 - }; - const pauseArrayBuffer = this.deviceToolKitInstance?.toBleCommand( - sendParams as any - ); + setTimeout(() => { + let sendParams: any = { + ...WE200DeviceControlCommand.end, + workMode: workMode, // 使用模式 + }; + const pauseArrayBuffer = this.deviceToolKitInstance?.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }).then(() => { + this.that.workStatus = 'end'; + this.that.resetTimer(); + console.info(`发送结束指令成功 参数为 =>`, sendParams); + }); + }, 2000) + }, + + // 查询设备护理报告 + getCurrentFacialReportInfo:(workMode = '') => { + const infoQueryComment = { + commandType: 'InfoQuery', + infoQueryType: 'currentFacialReportInfo', + workMode: workMode, + } + const value = this.deviceToolKitInstance?.toBleCommand(infoQueryComment); sendCommand({ - value: pauseArrayBuffer, + value: value }).then(() => { - this.that.workStatus = 'end'; - this.that.resetTimer(); - console.info(`发送结束指令成功 参数为 =>`, sendParams); - }); + console.info('下发指令查询护理报告==》', JSON.stringify(infoQueryComment)); + }) }, + + /** 离线记录汇总 */ syncOfflineSummary: () => { const queryOfflineSummary = this.deviceToolKitInstance?.toBleCommand({ ...WE200BleCommand.InfoQuery.offlineSummary @@ -147,6 +175,7 @@ export default class BluetoothContainer { value: queryOfflineSummary, }); }, + /** 最新一条离线记录详情 */ syncOfflineDetail: () => { const queryOfflineDetail = this.deviceToolKitInstance?.toBleCommand({ ...WE200BleCommand.InfoQuery.offlineDetail @@ -154,6 +183,18 @@ export default class BluetoothContainer { sendCommand({ value: queryOfflineDetail, }); + }, + + // 同步设备状态 + sendOnlySyncStatusToDevice() { + console.log('主动查询设备状态指令发送'); + const queryM01DeviceArrayBuffer = this.deviceToolKitInstance?.toBleCommand({ + commandType: "DeviceStatusSync", + deviceSyncCommandType: 'onlySyncStatusToDevice' + }) + sendCommand({ + value: queryM01DeviceArrayBuffer + }) } } @@ -168,20 +209,27 @@ export default class BluetoothContainer { } /** @name 设备响应:暂停 */ private syncPause(jsonStatus) { - console.log("上报暂停", jsonStatus) + console.log("上报暂停", jsonStatus,this.that.state) + let {ishandPause,checkedMembraneCloth} =this.that.state + // isHand为true的时候代表他正在运行中,正在运行中的时候,如果他自己暂停的情况下,需要我自己在次发送 + if(ishandPause){ + this.DeviceControl.working(checkedMembraneCloth) + } + let isDisconnect = false; // true代表暂停 if (isDisconnect) { // 发现蓝牙未连接时候打开有误图片 this.that.setState({ - isError:true + isError: true }); - }else{ - // 发现蓝牙链接成功后,关闭有误图片 + } else { + // 发现蓝牙链接成功后,关闭有误图片 this.that.setState({ - isError:false + isError: false }); } + } @@ -227,73 +275,75 @@ export default class BluetoothContainer { /** @name 设备响应:通用状态响应 */ private syncCommonStatus(jsonStatus) { + if (jsonStatus?.workMode) { + this.that.jsonStatus = jsonStatus; + } - } - - /** @name 设备响应:控制指令响应 */ - private syncDeviceControl(jsonStatus) { - console.log("设备控制响应", jsonStatus); - if (jsonStatus.responseStatus == "OK") { - console.log("发送控制指令成功"); - this.that.workJsonStatus = jsonStatus; - this.that.workStatus = jsonStatus.workStatus; + if (jsonStatus.battery) { + this.that.setState({ + Electricity: jsonStatus.matrixBattery, + }); + } - if (jsonStatus.battery) { - this.that.setState({ - Electricity: jsonStatus.battery, - }); + // 判断设备主动上报的关机事件 + if (jsonStatus.workStatus === 'end') { + // 判断id是否一致, 一致的话则生成护理报表, 并提示 + if (jsonStatus.id == this.that.WE200NursingHistory.id) { + debounce( + this.that.checkInstrumentRecord.bind(this, jsonStatus), + 500 + ); } + return; + } - // 判断设备主动上报的关机事件 - if (jsonStatus.workStatus === 'end') { - // 判断id是否一致, 一致的话则生成护理报表, 并提示 - if (jsonStatus.id == this.that.WE200NursingHistory.id) { - debounce( - this.that.checkInstrumentRecord.bind(this, jsonStatus), - 500 - ); - } - return; + if (jsonStatus?.workMode === this.that.state.ActiveModeItem?.modeType) { + this.that.setState({ + workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存 + }); + + // 判断是否在isRuning(护理中) + // 仅当设备模式与小程序是否一致,才允许更改设备运行时间 + if ( + this.that.state.DeviceConnectStatus === 1 && + this.that.isRuning && + jsonStatus.workStatus !== 'end' + ) { + this.that.updateDeviceSyncData( + { + totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + }, + jsonStatus + ); } + } - if (jsonStatus?.workMode === this.that.state.ActiveModeItem?.modeType) { + if ( + jsonStatus.workMode === 'working' && + this.that.isRuning + ) { + const { ActiveModeItem } = this.that.state; + const item = ActiveModeItem; + if (jsonStatus.workMode !== item?.modeType) { + // clearTimeout(loadingTipsTimer); this.that.setState({ - workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存 + isShowCountdown: false, }); - - // 判断是否在isRuning(护理中) - // 仅当设备模式与小程序是否一致,才允许更改设备运行时间 - if ( - this.that.state.DeviceConnectStatus === 1 && - this.that.isRuning && - jsonStatus.workStatus !== 'end' - ) { - this.that.updateDeviceSyncData( - { - totalWorkingMinutes: jsonStatus.totalWorkingMinutes, - totalWorkingSeconds: jsonStatus.totalWorkingSeconds, - }, - jsonStatus - ); - } - } - - if ( - jsonStatus.workMode === 'working' && - this.that.isRuning - ) { - const { ActiveModeItem } = this.that.state; - const item = ActiveModeItem; - if (jsonStatus.workMode !== item?.modeType) { - // clearTimeout(loadingTipsTimer); - this.that.setState({ - isShowCountdown: false, - }); - } } } } + /** @name 设备响应:控制指令响应 */ + private syncDeviceControl(jsonStatus) { + console.log("设备控制响应", jsonStatus); + // if (jsonStatus.responseStatus == "OK") { + // console.log("发送控制指令成功"); + // // this.that.workJsonStatus = jsonStatus; + // // this.that.workStatus = jsonStatus.workStatus; + // } + } + @@ -313,7 +363,7 @@ export default class BluetoothContainer { if (!jsonStatus || jsonStatus == null) { return; } - this.that.workStatus = jsonStatus.workStatus; // 记录工作状态 + // this.that.workStatus = jsonStatus.workStatus; // 记录工作状态 // end 和 endWork 都是护理结束, endWork不关机, end 关机, 对小程序而言处理流程都一样 if (jsonStatus.workStatus && jsonStatus.workStatus == "endWork") { @@ -346,7 +396,7 @@ export default class BluetoothContainer { if (jsonStatus.battery) { // 防止抖动 this.that.setState({ - Electricity: jsonStatus.battery, + Electricity: jsonStatus.matrixBattery, }); } @@ -370,6 +420,7 @@ export default class BluetoothContainer { //设备对控制指令的响应 case "DeviceControl": this.syncDeviceControl(jsonStatus); + this.syncCommonStatus(jsonStatus); break; // 设备对信息查询指令的响应 case "InfoQuery": @@ -451,6 +502,11 @@ export default class BluetoothContainer { // }); // }, 20000); } + + setTimeout(() => { + this.DeviceControl.sendOnlySyncStatusToDevice() + }, 1000) + }); } } \ No newline at end of file diff --git a/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx b/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx index 7e25d43..f63ba06 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx +++ b/src/moduleIOT/pages/iotCarePlan/components/Echart_face/index.tsx @@ -1,289 +1,255 @@ - -import { Block, View, Image, Text, Input } from "@tarojs/components"; -import { useRef } from "react"; +import { Block, View, Image } from "@tarojs/components"; +import { useEffect, useRef, useState, useCallback } from "react"; import Echarts, { EChartOption, EchartsHandle } from "taro-react-echarts"; -// import echarts from "@/utils/echarts.min.js"; -import * as echarts from "echarts"; +import echarts from "../echarts.min.js"; import "./index.less"; interface Props { - EchartsData: any + series: any; + full: any; + time: any; } -function Index({ - EchartsData -}: Props) { - - - let type = 0 - - - switch (EchartsData?.data?.workMode) { - case 'face': - type = 37 - break; - case 'eyes': - type = 25 - break; - case 'nasolabialFold': - type = 25 - break; - case 'mandibularLine': - type = 19 - break; - case 'headLiftingPro': - type = 13 - break; - default: - - } - - const echartsRef = useRef(null); - - function generateColorArray(startColor, endColor, steps) { - var startRGB = hexToRgb(startColor); - var endRGB = hexToRgb(endColor); - var colors = []; - for (var i = 0; i < steps; i++) { - var r = interpolate(startRGB.r, endRGB.r, steps, i); - var g = interpolate(startRGB.g, endRGB.g, steps, i); - var b = interpolate(startRGB.b, endRGB.b, steps, i); - colors.push(rgbToHex(r, g, b)); - } - return colors; +function Index({ series, full, time }: Props) { + const echartsRef = useRef(null); + const [options, setOptions] = useState({ + animation: false, + grid: { + // 让图表占满容器 + // containLabel: true, + top: "28rpx", + left: "18rpx", + right: "28rpx", + bottom: "17rpx", + }, + xAxis: { + type: "category", + axisLine: { + //坐标轴轴线相关设置。数学上的x轴 + show: true, + lineStyle: { + color: "#cccccc", + }, + }, + axisLabel: { + //坐标轴刻度标签的相关设置 + color: "#fff", + fontSize: 1, + }, + axisTick: { + show: false, + }, + }, + yAxis: { + type: "value", + min: 0, + max: 8, + splitNumber: 8, + splitLine: { + show: true, + lineStyle: { + color: "#cccccc", + type: [4, 2], + dashOffset: 4, + }, + }, + axisLine: { + show: false, + }, + axisLabel: { + show: false, + }, + axisTick: { + show: false, + }, + }, + visualMap: { + z: 1, + top: 0, + right: 0, + seriesIndex: 0, + show: false, + pieces: [ + { + gt: 0, + lte: 1, + color: "#f8f4f9", + }, + { + gt: 1, + lte: 2, + color: "#f5f1f8", + }, + { + gt: 2, + lte: 3, + color: "#f1edf6", + }, + { + gt: 3, + lte: 4, + color: "#ece9f5", + }, + { + gt: 4, + lte: 5, + color: "#e8e4f3", + }, + { + gt: 5, + lte: 6, + color: "#e3e0f1", + }, + { + gt: 6, + lte: 7, + color: "#e1ddf0", + }, + { + gt: 7, + lte: 8, + color: "#dedaef", + }, + ], + outOfRange: { + color: "#ff8410", + }, + }, + // series: [] + }); + + const level = [8, 7, 6, 5, 4, 3, 2]; + const [isFull, setIsfull] = useState(false); + const [data, setData] = useState([ + "00:01", + "00:02", + "00:03", + "00:04", + "00:05", + "00:06", + "00:07", + "00:08", + "00:09", + "00:10", + ]); + const [newOptions, setNewOptions] = useState(options); + + const updata = useCallback((res, times) => { + if (times.second == 0) { + return } - function hexToRgb(hex) { - var bigint = parseInt(hex.slice(1), 16); - var r = (bigint >> 16) & 255; - var g = (bigint >> 8) & 255; - var b = bigint & 255; - return { r: r, g: g, b: b }; - } - function rgbToHex(r, g, b) { - return ( - "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) - ); - } - function interpolate(start, end, steps, count) { - return start + ((end - start) / steps) * count; + // let option + // if (data) { + // option = JSON.parse(JSON.stringify(newParams)) + // } else { + // option = JSON.parse(JSON.stringify(options)) + // } + let option = JSON.parse(JSON.stringify(options)) + let datas = JSON.parse(JSON.stringify(data)) + if (series[0].data.length == 1) { + datas = [ + "00:01", + "00:02", + "00:03", + "00:04", + "00:05", + "00:06", + "00:07", + "00:08", + "00:09", + "00:10", + ] + } else { + if (times.min > 0 || times.second > 10) { + datas.splice(0, 1) + datas.push(formatTime(times)) + } } + setData(JSON.parse(JSON.stringify(datas))) + // option.xAxis.data = data + option.series = JSON.parse(JSON.stringify(res)) + // 更新图表数据 + setNewOptions(option); + }, [data]); - const startColor = "#FFFF00"; // 黄色 - const endColor = "#FF0000"; // 红色 - const steps = 81; // 80个颜色 - const colors = generateColorArray(startColor, endColor, steps); - // const xList = [...new Array(type).fill(0).map((item, key) => key)]; - let seriesData: any = [] - seriesData = EchartsData?.data?.groupedAa - const xList = [...new Array(type).fill(0).map((item, key) => key)]; - // const seriesData = [ - // ...xList.map((item) => { - // return Math.random() * 80; - // }), - // ]; - - - const option: EChartOption = { - grid: { - // 让图表占满容器 - top: "10rpx", - left: "45rpx", - right: "28rpx", - bottom: "17rpx", - }, - xAxis: { - type: "category", - data: [...xList], - axisLabel: { - interval: 5, - formatter: function (value, index) { - return value * 10 + 's'; - }, - textStyle: { - color: '#999999', // 文字颜色 - fontSize: 8 // 文字大小 - }, - }, - axisTick: { - // alignWithLabel: true, - show: false, - interval: 9, - }, - // axisLine: { - // show: false, - // }, - }, - yAxis: [ - { - min: 0, - max: 80, - splitNumber: 10, - axisLabel: { - formatter: function (value, index) { - const num = value / 10 + 1 - return num === 9 ? '' : num + '级'; - }, - textStyle: { - color: '#999999', // 文字颜色 - fontSize: 8 // 文字大小 - }, - }, - type: "value", - splitLine: { - lineStyle: { - color: ["#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#fff"], - type: 'dashed' - }, - } - }, - ], - series: [ - - { - barCategoryGap: '0%', - data: seriesData, - type: "bar", - // barWidth: 15, - gapWidth: "0%", - itemStyle: { - normal: { - color: function (params) { - var value = params.data; - return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { - offset: 0, - color: colors[parseInt(value)], // 红色 - }, - { - offset: 1, - color: colors[0], // 黄色 - }, - ]);; - }, - }, - }, - }, - ], + function formatTime(times: any) { + let mins; + if (times.min < 10) { + mins = "0" + times.min; + } else { + mins = times.min; } + let secs; + if (times.second < 10) { + secs = "0" + times.second; + } else { + secs = times.second; + } + return `${mins.toString()}:${secs.toString()}`; + } - // 基于 EchartsData 生成 ECharts 配置 - // const option: EChartOption ={ - // grid: { - // // 让图表占满容器 - // top: "10rpx", - // left: "45rpx", - // right: "28rpx", - // bottom: "17rpx", - // }, - // xAxis: { - // type: "category", - // data: [...xList], - // axisLabel: { - // interval: 5, - // formatter: function (value, index) { - // return value * 10 + 's'; - // }, - // textStyle: { - // color: '#999999', // 文字颜色 - // fontSize: 8 // 文字大小 - // }, - // }, - // axisTick: { - // // alignWithLabel: true, - // show: false, - // interval: 9, - // }, - // // axisLine: { - // // show: false, - // // }, - // }, - // yAxis: [ - // { - // min: 0, - // max: 80, - // splitNumber: 10, - // axisLabel: { - // formatter: function (value, index) { - // const num = value / 10 + 1 - // return num === 9 ? '' : num + '级'; - // }, - // textStyle: { - // color: '#999999', // 文字颜色 - // fontSize: 8 // 文字大小 - // }, - // }, - // type: "value", - // splitLine: { - // lineStyle: { - // color: ["#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#ccc", "#fff"], - // type: 'dashed' - // }, - // } - // }, - // ], - // series: [ + const cancelFull = useCallback( + (res) => { + full(); + setIsfull(!isFull); + }, + [isFull] + ); - // { - // barCategoryGap: '0%', - // data: seriesData, - // type: "bar", - // // barWidth: 15, - // gapWidth: "0%", - // itemStyle: { - // normal: { - // color: function (params) { - // var value = params.data; - // return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - // { - // offset: 0, - // color: colors[parseInt(value)], // 红色 - // }, - // { - // offset: 1, - // color: colors[0], // 黄色 - // }, - // ]);; - // }, - // }, - // }, - // }, - // ], - // }; + useEffect(() => { + setOptions(newOptions); + }, [newOptions]); + useEffect(() => { - return ( - - + updata(series, time); + }, [series]); - {/* + return ( + + - - */} - - - - ); + + + + 实时能量 + {level.map((item) => ( + + {item} + + + ))} + + 1 + + + {data.map((times, index) => ( + {times} + ))} + + 时间 + + + + ); } export default Index; diff --git a/src/moduleIOT/pages/iotCarePlan/components/MembraneList/index.less b/src/moduleIOT/pages/iotCarePlan/components/MembraneList/index.less index c1c927f..707432d 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/MembraneList/index.less +++ b/src/moduleIOT/pages/iotCarePlan/components/MembraneList/index.less @@ -1,6 +1,7 @@ .center_MembraneList { margin-bottom: 44rpx; - padding: 0 9px; + padding: 0rpx 9rpx; + box-sizing: border-box; .grey_item{ background: #f8f8f8; // position: relative; diff --git a/src/moduleIOT/pages/iotCarePlan/components/Radar/index.tsx b/src/moduleIOT/pages/iotCarePlan/components/Radar/index.tsx index 19fbe25..d9f1724 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/Radar/index.tsx +++ b/src/moduleIOT/pages/iotCarePlan/components/Radar/index.tsx @@ -12,62 +12,15 @@ import "./index.less"; interface Props { cancelFull:Function height:any, - series:any + series:any, + max:any } -function Index({cancelFull,height,series}:Props) { +function Index({cancelFull,height,series,max}:Props) { const echartsRef = useRef(null); - console.log(echartsRef,'echartsRef'); - - // const [options, setOptions] = useState({ - // animation: true, - // grid: { - // // 让图表占满容器 - // // containLabel: true, - // top: "20rpx", - // left: "20rpx", - // right: "20rpx", - // bottom: "20rpx", - // }, - // radar: { - // // shape: 'circle', - // axisName: { - // fontSize: 15, - // }, - // indicator: [ - // { name: '垂', max: 5, color: '#000' }, - // { name: '肿', max: 5, color: '#000' }, - // { name: '疲', max: 5, color: '#000' }, - // { name: '黑', max: 5, color: '#000' }, - // { name: '凹', max: 5, color: '#000' }, - // { name: '松', max: 5, color: '#000' }, - // { name: '纹', max: 5, color: '#000' }, - // { name: '垮', max: 5, color: '#000' } - // ] - // }, - // series: [ - // { - // type: 'radar', - // data: [ - // { - // value: series, - // itemStyle: { - // color: '#d8bb91', - // borderWidth: 1, - // }, - // symbolSize: 8, - // } - // ], - // areaStyle: { - // color: 'rgba(218, 190, 150, 0.2)' // 这里设置你想要的颜色 - // }, - // lineStyle: { - // color: '#d8bb91', - // width: 2 - // } - // } - // ] - // }) + console.log(max,'maxmaxmax'); + + let options :EChartOption={ animation: true, grid: { @@ -84,14 +37,14 @@ function Index({cancelFull,height,series}:Props) { fontSize: 10, }, indicator: [ - { name: '垂', max: 5, color: '#000' }, - { name: '肿', max: 5, color: '#000' }, - { name: '疲', max: 5, color: '#000' }, - { name: '黑', max: 5, color: '#000' }, - { name: '凹', max: 5, color: '#000' }, - { name: '松', max: 5, color: '#000' }, - { name: '纹', max: 5, color: '#000' }, - { name: '垮', max: 5, color: '#000' } + { name: '垂', max: max, color: '#000' }, + { name: '肿', max:max, color: '#000' }, + { name: '疲', max: max, color: '#000' }, + { name: '黑', max: max, color: '#000' }, + { name: '凹', max: max, color: '#000' }, + { name: '松', max: max, color: '#000' }, + { name: '纹', max: max, color: '#000' }, + { name: '垮', max: max, color: '#000' } ] }, series: [ diff --git a/src/pages/detect/detect.less b/src/pages/detect/detect.less index 4d7a306..3314da3 100644 --- a/src/pages/detect/detect.less +++ b/src/pages/detect/detect.less @@ -7,7 +7,6 @@ // font-size: 30rpx; // } - .message { position: relative; width: 40rpx; @@ -47,7 +46,7 @@ .main { position: relative; top: -130rpx; - background: #F7F8FA; + background: #f7f8fa; border-top-left-radius: 50rpx; border-top-right-radius: 50rpx; padding: 50rpx 30rpx; @@ -127,13 +126,11 @@ .container { width: 100%; - display: flex; - justify-content: space-between; margin-top: 50rpx; } .column { - width: calc(50% - 10rpx); + width: 100%; overflow: hidden; } @@ -141,7 +138,6 @@ width: 100%; background-color: #fff; border-radius: 30rpx; - margin-bottom: 23rpx; } .item_image { @@ -180,6 +176,47 @@ font-size: 32rpx; font-weight: bold; text-align: center; - color: #FFFFFF; + color: #ffffff; margin: 19rpx auto 44rpx; +} + + +.popup-box { + padding-bottom: env(safe-area-inset-bottom); +} + +.popup_title { + height: 34rpx; + font-size: 36rpx; + font-weight: bold; + text-align: center; + color: #030000; + margin: 49rpx auto 0; +} + +.popup_btn { + width: 690rpx; + height: 90rpx; + background: #000000; + border-radius: 45rpx; + color: #fff; + font-size: 32rpx; + font-weight: bold; + text-align: center; + line-height: 90rpx; + margin: 0 auto; +} +.service-textarea { + // width: 690rpx; + display: flex; + height: 330rpx; + background: #ffffff; + border: 1px solid #dddddd; + border-radius: 3rpx; + padding: 30rpx 30rpx; + width: auto; + font-size: 28rpx; + font-weight: 400; + color: #030000; + box-sizing: border-box; } \ No newline at end of file diff --git a/src/pages/detect/detect.tsx b/src/pages/detect/detect.tsx index c032ae4..d6b79fd 100644 --- a/src/pages/detect/detect.tsx +++ b/src/pages/detect/detect.tsx @@ -10,18 +10,21 @@ import { Video, Swiper, SwiperItem, + Textarea, } from "@tarojs/components"; import Navbar from "@/components/navbar/navbar"; -import { go } from "@/utils/traoAPI"; +import { go, msg } from "@/utils/traoAPI"; import { - InstrumentInfo, + InstrumentInfo,SaveMessage } from "../../utils/Interface"; +import { WaterfallFlow, Popup } from '@antmjs/vantui' import PopupAlert from "@/components/popup/popup-alert"; import "taro-ui/dist/style/components/button.scss"; // 按需引入 import "./detect.less"; import type CustomTabBar from "../../custom-tab-bar"; +import PopupDrawer from "@/components/popup/popup-drawer"; export default class Detect extends Component { pageCtx = Taro.getCurrentInstance().page; @@ -32,11 +35,17 @@ export default class Detect extends Component { isNotRegister: false, // 是否未注册 show: false, messageCount: Taro.getStorageSync("messageCount") || 0, - isRegisterBoolean: false + isRegisterBoolean: false, + carouselList: [], + strategyList: [], + isShow: false, + messageInfo: '' }; } - async onLoad() { this.showInit() } + async onLoad() { + + } showInit = async () => { // 判断是否登录 @@ -52,6 +61,9 @@ export default class Detect extends Component { componentDidShow() { const tabbar = Taro.getTabBar(this.pageCtx); tabbar?.setSelected(2); + this.showInit() + this.getCarouselList() + this.getStrategyList() } componentDidHide() { } @@ -71,6 +83,16 @@ export default class Detect extends Component { } return true; } + async getCarouselList() { + let res = await InstrumentInfo.find.CarouselList(); + this.setState({ carouselList: res.data.rows }) + } + + async getStrategyList() { + let res = await InstrumentInfo.find.StrategyList(); + this.setState({ strategyList: res.data.rows }) + + } public alertRegister = () => { this.setState({ isNotRegister: true }); // 打开弹窗 @@ -103,13 +125,47 @@ export default class Detect extends Component { } } }; + close() { + this.setState({ isShow: false }) + } + onChange() { + this.setState({ isShow: true }) + + } + submit = () => { + let { messageInfo } = this.state; + if (messageInfo.length) { + this.postSaveMessage(); + this.close(); + } else { + msg("留言内容不能为空!"); + // Toast_.fail({ + // message: "留言内容不能为空!", + // }); + } + }; + postSaveMessage = async () => { + let { messageInfo } = this.state; + let params = { + source: 1, + messageInfo: messageInfo, + }; + let res = await SaveMessage(params); + if (res.data.code === 200) { + msg("提交成功!"); + } else { + msg("提交失败!"); + } + }; closeAlert = () => { this.setState({ isNotRegister: false }); }; - + onInputTextarea = (e) => { + this.setState({ messageInfo: e.detail.value }); + }; render() { - let { name, show, isNotRegister, messageCount } = this.state; + let { isNotRegister, messageCount, carouselList, strategyList, isShow } = this.state; return ( { confirm={this.closeAlert} /> { transparent /> - - - + { + carouselList.map(item => ( + + + + )) + } + - + {/* 产品共创 @@ -157,38 +219,97 @@ export default class Detect extends Component { - - - - + { + carouselList.map(item => ( + + + + + )) + } - + - + */} - 用户心声 + 产品攻略 - - - - - - + { + return ( + + + + + + {item.title} + + + - - - + ) + }} + /> - 留言反馈 - 填写反馈 + 留言箱 + 如果以上内容没能解决您的问题,或您有其他的建议,可以在留言箱给小助理留言噢! + 点击留言 + + {/* + + 留言箱 + + 提交 + + */} + + + + + + } + confirmButtonText='提交' + textAlgin='left' + close={this.close} + confirm={this.submit.bind(this)} + /> ); } diff --git a/src/pages/index/index.less b/src/pages/index/index.less index 3dbfc01..081756f 100644 --- a/src/pages/index/index.less +++ b/src/pages/index/index.less @@ -525,8 +525,11 @@ page { padding: 52rpx 20rpx 46rpx; box-sizing: border-box; .site-close-MembraneCloth{ - right: 7px; - top: 24px; + right: 29rpx; + top: 34rpx; + width: 48rpx; + height: 48rpx; + position: absolute; } .title { diff --git a/src/recoding/pages/moisture_test_report/Echarts/index.tsx b/src/recoding/pages/moisture_test_report/Echarts/index.tsx index a61f8ff..a358a6b 100644 --- a/src/recoding/pages/moisture_test_report/Echarts/index.tsx +++ b/src/recoding/pages/moisture_test_report/Echarts/index.tsx @@ -4,11 +4,12 @@ import { Block, View, Image, Text, Input } from "@tarojs/components"; import { Popup, Progress, Slider } from "@antmjs/vantui"; import { useEffect, useRef } from "react"; import Echarts, { EChartOption, EchartsHandle } from "taro-react-echarts"; -import * as echarts from "echarts"; +// import * as echarts from "echarts"; +import "../../../../moduleIOT/pages/iotCarePlan/components/echarts.min.js"; import "./index.less"; interface Props { - echartsData: any + echartsData: any; } function Index(echartsData: Props) { @@ -23,66 +24,65 @@ function Index(echartsData: Props) { bottom: "38rpx", }, title: { - left: 'center', + left: "center", }, xAxis: { - type: 'category', + type: "category", boundaryGap: false, splitLine: { show: true, }, - data:eDate, + data: eDate, axisTick: { - show: false + show: false, }, axisLine: { lineStyle: { - color: '#ccc' - } + color: "#ccc", + }, }, axisLabel: { - fontSize: 9 - } + fontSize: 9, + }, }, yAxis: { - type: 'value', - show: false + type: "value", + show: false, }, series: [ { - type: 'line', + type: "line", itemStyle: { - color: 'rgb(168, 222, 244)' + color: "rgb(168, 222, 244)", }, symbolSize: 0, label: { show: true, distance: 8, formatter: function (params) { - return params.value + '级'; - } + return params.value + "级"; + }, }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, - color: 'rgb(220, 240, 248)' - + color: "rgb(220, 240, 248)", }, { offset: 1, - color: 'rgb(248, 253, 255)' - } - ]) + color: "rgb(248, 253, 255)", + }, + ]), }, data: gears, - } - ] + }, + ], }; return ( - + { }; } - componentDidMount() { } + componentDidMount() {} - componentWillUnmount() { } + componentWillUnmount() {} // 格式化时间 getTime(time) { const hour = time.slice(0, 2); @@ -271,9 +271,9 @@ export default class Recording extends Component { this.initData(); } - componentDidShow() { } + componentDidShow() {} - componentDidHide() { } + componentDidHide() {} initData = async () => { this.getRecord(null); @@ -340,11 +340,11 @@ export default class Recording extends Component { go( "/recoding/pages/face_report_one/face_report_one?id=" + - item.id + - "&report=" + - report + - "&obj=" + - JSON.stringify(obj) + item.id + + "&report=" + + report + + "&obj=" + + JSON.stringify(obj) ); }; // 打开第二种类型 @@ -353,11 +353,11 @@ export default class Recording extends Component { let report = false; go( "/recoding/pages/face_report/face_report?id=" + - item.id + - "&recordId=" + - item.instrumentId + - "&report=" + - report + item.id + + "&recordId=" + + item.instrumentId + + "&report=" + + report ); }; // 打开第三种类型 @@ -409,8 +409,10 @@ export default class Recording extends Component { setStorageSync("moistureEachtsData", JSON.stringify(echartsData)); let report = false; go( - `/recoding/pages/moisture_test_report/moisture_test_report?data=${allData.nursingData - }&date=${allData.createTime}&modeId=${allData.modeId}&id=${allData.instrumentId + `/recoding/pages/moisture_test_report/moisture_test_report?data=${ + allData.nursingData + }&date=${allData.createTime}&modeId=${allData.modeId}&id=${ + allData.instrumentId }&echartsData=${JSON.stringify(echartsData)}&report=${report}` ); } @@ -673,9 +675,10 @@ export default class Recording extends Component { 模式:{item.modeName} - {item.instrumentType === 2 && item.modeId !== 155 && ( - 护理时间:{item.nursingTime} - )} + {item.instrumentType === 2 && + item.modeId !== 155 && ( + 护理时间:{item.nursingTime} + )} diff --git a/src/store/features/globalStore.js b/src/store/features/globalStore.js index 989eab2..9d178e2 100644 --- a/src/store/features/globalStore.js +++ b/src/store/features/globalStore.js @@ -5,8 +5,8 @@ import { createSlice } from "@reduxjs/toolkit"; const globalStoreReducer = createSlice({ name: "globalStore", // store的名字 initialState: { - domain: "https://flossom.yq-h5.cn/prod-api/hzwx", // 请求地址 - // domain: "http://192.168.10.147:8080/hzwx", // 请求地址 + // domain: "https://flossom.yq-h5.cn/prod-api/hzwx", // 请求地址 + domain: "http://127.0.0.1:8080/hzwx", // 请求地址 // 是否首次进入首页 isShowIndexFlag: false, }, diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 5fa6f8c..f5c0215 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -454,7 +454,7 @@ export const InstrumentInfo = { }); }, }, - // 根据定制电流返回配方和频率 + // 根据定制电流返回配方和频率 // WE200:{ // CustomizedCurrentFrequency: (data) => { // return Ajax({ @@ -477,22 +477,37 @@ export const InstrumentInfo = { // 电流定制护理频率与时间 CustomizedCurrentFrequency: (data) => { return Ajax({ - url: "/lining/electric/formula", data, method: "post", }); }, - // 眼雕大师雷达图 - RadarChart: (data) => { + // 眼雕大师雷达图 + RadarChart: (data) => { return Ajax({ - - url: "/instrument/answerResult" , + url: "/instrument/answerResult", data, method: "post", }); }, }, + // 发现页 + find: { + // 顶部轮播图 + CarouselList: () => { + return Ajax({ + url: "/carousel/list", + method: "get", + }); + }, + StrategyList: () => { + console.log('进来了'); + return Ajax({ + url: "/strategy/list", + method: "get", + }); + }, + }, }; //localhost:9204/instrument/getInstrumentInfoBySerial