From 737904ce25bc14ca737930d7f679b37ec2b1c878 Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Wed, 13 Mar 2024 20:07:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BC=B9=E7=AA=97=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BA=8F=E5=88=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.tsx | 96 +++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 0cce1be..6eb5dac 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -174,15 +174,20 @@ class Index extends Component { componentDidShow() { const tabbar = Taro.getTabBar(this.$instance.page); tabbar?.setSelected(0); - - // 判断是否跳过了注册 - if (Taro.getStorageSync("skipRegister")) { - this.setState({ showEquipment: true }); - Taro.removeStorageSync("skipRegister"); - } else { - // 已注册且非跳过,正常执行逻辑 - this.showInit(); + console.log(this.state.instrumentInfo, '查看', this.state.instrumentList, Taro.getStorageSync("skipRegister")); + const handleAsyncLogic = async () => { + // 判断是否跳过了注册 + if (Taro.getStorageSync("skipRegister")) { + await this.EquipmentNo(); // 扫码序列号查询:注册后才调用,因为扫码未注册直接跳转注册页 + this.setState({ showEquipment: true }); + Taro.removeStorageSync("skipRegister"); + + } else { + // 已注册且非跳过,正常执行逻辑 + this.showInit(); + } } + handleAsyncLogic() } componentDidHide() { @@ -210,6 +215,7 @@ class Index extends Component { } // 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,先缓存序列号,再检测隐私弹窗 let serial = Taro.getStorageSync("serial"); + console.log(this.$instance, '2222', serial); let url = this.$instance.router?.params?.q || ""; if (!url) { // 非扫码或扫码已跳转的返回进入 @@ -224,7 +230,10 @@ class Index extends Component { // 是否可以运行扫码逻辑:每次扫码后设为真, Taro.setStorageSync("isScanRun", true); if (url) { + + let _url = decodeURIComponent(url); + if (_url.indexOf("?")) { let ids = _url.split("?"); if (ids.length > 1) { @@ -259,6 +268,7 @@ class Index extends Component { // 页面初始化 initData = async () => { let token = getStorageSync("token"); + if (!token) { // 如果token过期,先登录,登录完成后自动初始化 await this.WCUserLogin(); @@ -267,7 +277,60 @@ class Index extends Component { this.initPageData(); } }; + // 查看设备序号与仪器 + EquipmentNo = async () => { + let serial = Taro.getStorageSync("serial"); // 扫码可能跳转注册页,所以先缓存 + + let { data } = await InstrumentInfo.getInstrumentInfoBySerial({ + serial: serial, + }); + if (data.code === 200) { + let instrumentInfo = data.data; + // 更新扫码进入仪器信息 + this.setState({ instrumentInfo: instrumentInfo }); + + // 1有效 0无效 + // if (instrumentInfo.validStatus === 0) { + // this.setState({ isBindingError: true }); + // return; + // } + // // 0已绑定 1未绑定 2已解绑 + // if (instrumentInfo.bindingStatus === 0) { + // setTimeout(() => { + // this.isBindingSerial(); + // }, 100); + // let isBind = this.state.instrumentList.find( + // (item) => item.id === instrumentInfo.id + // ); + // if (isBind) { + // this.setState({ + // isBeforeBindingError: true, + // BeforeBindingErrorText: "序列号已绑定", + // }); + // } else { + // this.setState({ + // isBeforeBindingError: true, + // BeforeBindingErrorText: "序列号已被其他用户绑定", + // }); + // } + + // return; + // } else if ( + // instrumentInfo.bindingStatus === 1 || + // instrumentInfo.bindingStatus === 2 + // ) { + // // 判断是否已绑定同名仪器,如果已绑定,判断序列号是否一致 + // // 如果自己已绑定,判断扫码序列号和已绑定序列号是否一致,如果一致:忽略 + // // 如果自己已绑定,判断扫码序列号和已绑定序列号是否一致,如果不一致:提示换绑 + // // 以上逻辑交给后端处理,直接查询是否绑定或换绑 + // setTimeout(() => { + // this.isBindingSerial(); + // }, 100); + // } + } + // this.removeScanFun(); + } initPageData = async () => { const mobile = Taro.getStorageSync("mobile"); const isToken = getStorageSync("token"); @@ -275,11 +338,15 @@ class Index extends Component { // 防止逻辑出错没有token await this.onlyLogin(); } - console.log("initPageData"); + console.log("initPageData", Taro.getStorageSync("serial")); // 如果是扫码且已有token则跳转 if (Taro.getStorageSync("serial")) { + console.log(mobile, 'mobile'); + // 如果已注册绑定手机号不用跳转 if (!mobile) { + + setTimeout(() => { go("/pages/register/register"); }, 300); @@ -431,19 +498,19 @@ class Index extends Component { if (url === '/pages/instrument/instrument') { let { data } = await InstrumentInfo.unbindingInstrumentInfoList(); console.log(data, '查看未绑定设备'); - if(data.data.length === 0){ + if (data.data.length === 0) { this.setState( { - show:true + show: true } ) setTimeout(() => { this.setState({ show: false }); }, 1000); // 2秒后将 show 变量置为 false - }else{ + } else { go(url); } - + } else { go(url); } @@ -591,6 +658,7 @@ class Index extends Component { }; // 根据扫码的序列号获取仪器信息 getInstrumentInfoBySerial = async () => { + let url = this.$instance.router?.params?.q || ""; let isScan = Taro.getStorageSync("isScan"); // 判断是否扫码进入 let serial = Taro.getStorageSync("serial"); // 扫码可能跳转注册页,所以先缓存 @@ -598,6 +666,8 @@ class Index extends Component { let { data } = await InstrumentInfo.getInstrumentInfoBySerial({ serial: serial, }); + console.log(data, '查看赋值'); + if (data.code === 200) { let instrumentInfo = data.data; // 更新扫码进入仪器信息 From 4a60d242636d261b8ecbea8c2ebf1e759a0e0f4a Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Wed, 13 Mar 2024 20:59:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=9D=E6=AC=A1=E6=8A=A4=E7=90=86?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E9=85=8D=E7=BD=AE=E8=A7=86=E9=A2=91=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=92=AD=E6=94=BE=EF=BC=8C=E4=B8=94=E8=8B=A5?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=85=8D=E7=BD=AE=E8=A7=86=E9=A2=91=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=BA=94=E8=AF=A5=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=89=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx index cdc576e..313ec7c 100644 --- a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx @@ -1887,13 +1887,20 @@ class IotCarePlan extends Component { let res = await InstrumentInfo.firstNurseInfo({ instrumentId: currentDevice.id, }); + console.log(res,'接口'); + if (res.data.code === 200) { let isFirstTipShow = getStorageSync( "first_instrument_" + currentDevice.id ); + console.log(isFirstTipShow,'查看返回值'); + if (!isFirstTipShow) { - // 首次进入页面:自动打开打卡介绍弹窗 - this.setState({ nurseInfo: res.data.data, isFirstTipShow: true }); + if(res.data.length !== 0){ + // 首次进入页面:自动打开打卡介绍弹窗 + this.setState({ nurseInfo: res.data.data, isFirstTipShow: true }); + } + setStorageSync("first_instrument_" + currentDevice.id, true); } else { this.setState({ nurseInfo: res.data.data }); From b39a8ceda466fdd564554a26f802e7ef74ad7d30 Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Wed, 13 Mar 2024 21:20:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx index 313ec7c..bb4e3c1 100644 --- a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx @@ -1896,7 +1896,7 @@ class IotCarePlan extends Component { console.log(isFirstTipShow,'查看返回值'); if (!isFirstTipShow) { - if(res.data.length !== 0){ + if(res.data.data.length !== 0){ // 首次进入页面:自动打开打卡介绍弹窗 this.setState({ nurseInfo: res.data.data, isFirstTipShow: true }); }